/** * Returns true if the debugger's connection with the server is up and running. * * @return true if the connection with the server is active. */ boolean isConnectionActive() { return connection.isConnected(); }
/** * Returns true if the reconnection mechanism is enabled. * * @return true if automatic reconnection is allowed. */ private boolean isReconnectionPossible(XMPPConnection connection) { return !done && !connection.isConnected() && isAutomaticReconnectEnabled(); }
public static String getPublicIP(XMPPConnection xmppConnection) throws NotConnectedException, InterruptedException { if (!xmppConnection.isConnected()) { return null;
XMPPErrorException, NotConnectedException, InterruptedException { if (!connection.isConnected()) { return false;
/** * Check if the server support STUN Service. * * @param connection the connection * @return true if the server support STUN * @throws SmackException * @throws XMPPException * @throws InterruptedException */ public static boolean serviceAvailable(XMPPConnection connection) throws XMPPException, SmackException, InterruptedException { if (!connection.isConnected()) { return false; } LOGGER.fine("Service listing"); ServiceDiscoveryManager disco = ServiceDiscoveryManager.getInstanceFor(connection); DiscoverItems items = disco.discoverItems(connection.getXMPPServiceDomain()); for (DiscoverItems.Item item : items.getItems()) { DiscoverInfo info = disco.discoverInfo(item.getEntityID()); for (DiscoverInfo.Identity identity : info.getIdentities()) { if (identity.getCategory().equals("proxy") && identity.getType().equals("stun")) if (info.containsFeature(NAMESPACE)) return true; } LOGGER.fine(item.getName() + "-" + info.getType()); } return false; }
/** * Get a new RTPBridge Candidate from the server. * If a error occurs or the server don't support RTPBridge Service, null is returned. * * @param connection * @param sessionID * @return the new RTPBridge * @throws NotConnectedException * @throws InterruptedException */ @SuppressWarnings("deprecation") public static RTPBridge getRTPBridge(XMPPConnection connection, String sessionID) throws NotConnectedException, InterruptedException { if (!connection.isConnected()) { return null; } RTPBridge rtpPacket = new RTPBridge(sessionID); rtpPacket.setTo(RTPBridge.NAME + "." + connection.getXMPPServiceDomain()); StanzaCollector collector = connection.createStanzaCollectorAndSend(rtpPacket); RTPBridge response = collector.nextResult(); // Cancel the collector. collector.cancel(); return response; }
/** * Get a new STUN Server Address and port from the server. * If a error occurs or the server don't support STUN Service, null is returned. * * @param connection * @return the STUN server address * @throws NotConnectedException * @throws InterruptedException */ @SuppressWarnings("deprecation") public static STUN getSTUNServer(XMPPConnection connection) throws NotConnectedException, InterruptedException { if (!connection.isConnected()) { return null; } STUN stunPacket = new STUN(); stunPacket.setTo(DOMAIN + "." + connection.getXMPPServiceDomain()); StanzaCollector collector = connection.createStanzaCollectorAndSend(stunPacket); STUN response = collector.nextResult(); // Cancel the collector. collector.cancel(); return response; }
if (!connection.isConnected()) { throw new NotConnectedException(connection, packetFilter);
/** * Check if the server support RTPBridge Service. * * @param connection * @return the RTPBridge * @throws NotConnectedException * @throws InterruptedException */ @SuppressWarnings("deprecation") public static RTPBridge relaySession(XMPPConnection connection, String sessionID, String pass, TransportCandidate proxyCandidate, TransportCandidate localCandidate) throws NotConnectedException, InterruptedException { if (!connection.isConnected()) { return null; } RTPBridge rtpPacket = new RTPBridge(sessionID, RTPBridge.BridgeAction.change); rtpPacket.setTo(RTPBridge.NAME + "." + connection.getXMPPServiceDomain()); rtpPacket.setType(Type.set); rtpPacket.setPass(pass); rtpPacket.setPortA(localCandidate.getPort()); rtpPacket.setPortB(proxyCandidate.getPort()); rtpPacket.setHostA(localCandidate.getIp()); rtpPacket.setHostB(proxyCandidate.getIp()); // LOGGER.debug("Relayed to: " + candidate.getIp() + ":" + candidate.getPort()); StanzaCollector collector = connection.createStanzaCollectorAndSend(rtpPacket); RTPBridge response = collector.nextResult(); // Cancel the collector. collector.cancel(); return response; }
@Override protected void handleMessageInternal(Message<?> message) throws Exception { Assert.state(this.initialized, this.getComponentName() + " must be initialized"); Object payload = message.getPayload(); Assert.state(payload instanceof Presence, "Payload must be of type 'org.jivesoftware.smack.packet.Presence', was: " + payload.getClass().getName()); if (!this.xmppConnection.isConnected() && this.xmppConnection instanceof AbstractXMPPConnection) { ((AbstractXMPPConnection) this.xmppConnection).connect(); } this.xmppConnection.sendStanza((Presence) payload); }
if ((getConnection() != null) && getConnection().isConnected()) getConnection().sendStanza(jout);
if (!this.xmppConnection.isConnected() && this.xmppConnection instanceof AbstractXMPPConnection) { ((AbstractXMPPConnection) this.xmppConnection).connect();
@Test public void testCompleteConfiguration() { ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("XmppConnectionParserTests-complete.xml", this.getClass()); XMPPConnection connection = ac.getBean("connection", XMPPConnection.class); assertEquals("foogle.com", connection.getXMPPServiceDomain().toString()); assertFalse(connection.isConnected()); XmppConnectionFactoryBean xmppFb = ac.getBean("&connection", XmppConnectionFactoryBean.class); assertEquals("happy.user", TestUtils.getPropertyValue(xmppFb, "user")); assertEquals("blah", TestUtils.getPropertyValue(xmppFb, "password")); assertEquals("SpringSource", TestUtils.getPropertyValue(xmppFb, "resource")); assertEquals("reject_all", TestUtils.getPropertyValue(xmppFb, "subscriptionMode").toString()); ac.close(); }
/** * Returns true if the debugger's connection with the server is up and running. * * @return true if the connection with the server is active. */ boolean isConnectionActive() { return connection.isConnected(); }
@Test public void testSimpleConfiguration() { ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("XmppConnectionParserTests-simple.xml", this.getClass()); XMPPConnection connection = ac.getBean("connection", XMPPConnection.class); assertEquals("my.domain", connection.getXMPPServiceDomain().toString()); assertFalse(connection.isConnected()); XmppConnectionFactoryBean xmppFb = ac.getBean("&connection", XmppConnectionFactoryBean.class); assertEquals("happy.user@my.domain", TestUtils.getPropertyValue(xmppFb, "user")); assertEquals("blah", TestUtils.getPropertyValue(xmppFb, "password")); assertNull(TestUtils.getPropertyValue(xmppFb, "resource")); assertEquals("accept_all", TestUtils.getPropertyValue(xmppFb, "subscriptionMode").toString()); xmppFb = ac.getBean("&connectionWithResource", XmppConnectionFactoryBean.class); assertEquals("Smack", TestUtils.getPropertyValue(xmppFb, "resource")); assertNull(TestUtils.getPropertyValue(xmppFb, "subscriptionMode")); ac.close(); }
public void sendPacket(Packet packet) { if (!isConnected()) { throw new IllegalStateException("Not connected to server."); } if (packet == null) { throw new NullPointerException("Packet is null."); } packetWriter.sendPacket(packet); }
public void sendPacket(Packet packet) { if (!isConnected()) { throw new IllegalStateException("Not connected to server."); } if (packet == null) { throw new NullPointerException("Packet is null."); } packetWriter.sendPacket(packet); }
/** * is connection to kenai xmpp up and living? * @return */ public boolean isConnected() { return connection != null && connection.isConnected() && connection.isAuthenticated(); }
public void destroy() { if(xmppConnection != null && xmppConnection.isConnected()){ xmppConnection.disconnect(); } }
private void join(MultiUserChat chat) { try { assert connection.isConnected(); assert connection.isAuthenticated(); chat.addParticipantListener(new PresenceIndicator.PresenceListener()); chat.addParticipantListener(new PresenceListener()); chat.join(getUserName()); } catch (XMPPException ex) { XMPPLOG.log(Level.INFO, "Cannot join " + chat.getRoom(), ex); } }