Package rocks.xmpp.core.session

Examples of rocks.xmpp.core.session.XmppSession


    //@Test
    public void testInBandBytestreamManager() throws IOException {
        MockServer mockServer = new MockServer();
        final Lock lock = new ReentrantLock();
        final XmppSession xmppSession1 = new TestXmppSession(ROMEO, mockServer);
        final XmppSession xmppSession2 = new TestXmppSession(JULIET, mockServer);
        final Condition condition = lock.newCondition();
        final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

        new Thread() {
            @Override
            public void run() {
                InBandByteStreamManager inBandBytestreamManager2 = xmppSession2.getExtensionManager(InBandByteStreamManager.class);
                inBandBytestreamManager2.addByteStreamListener(new ByteStreamListener() {
                    @Override
                    public void byteStreamRequested(final ByteStreamEvent e) {
                        final ByteStreamSession ibbSession;
View Full Code Here


                .build();

        long start = System.currentTimeMillis();

        for (int i = 0; i < 500; i++) {
            XmppSession xmppSession = new XmppSession("christihudtsmbp.fritz.box", boshConnectionConfiguration);
            System.out.println(i);
            try {
                xmppSession.connect();
                xmppSession.login("admin", "admin", null);
                //xmppSession.send(new Presence());
                //xmppSession.getRosterManager().requestRoster();
                xmppSession.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        System.out.println(System.currentTimeMillis() - start);
View Full Code Here

        connections.put(xmppSession.getConnectedResource(), xmppSession);
    }

    public void receive(Stanza stanza) {

        XmppSession toXmppSession = connections.get(stanza.getTo());
        if (toXmppSession != null) {
            try {
                toXmppSession.handleElement(stanza);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (stanza instanceof IQ) {
            connections.get(stanza.getFrom()).send(((IQ) stanza).createResult());
View Full Code Here

                    XmppSessionConfiguration configuration = XmppSessionConfiguration.builder()
                            .debugger(VisualDebugger.class)
                            .defaultResponseTimeout(5000)
                            .build();

                    XmppSession xmppSession = new XmppSession("localhost", configuration, tcpConfiguration);

                    // Connect
                    xmppSession.connect();
                    // Login
                    xmppSession.login("111", "111", "filetransfer");
                    // Send initial presence
                    xmppSession.send(new Presence());

                    FileTransferManager fileTransferManager = xmppSession.getExtensionManager(FileTransferManager.class);
                    FileTransfer fileTransfer = fileTransferManager.offerFile(new File("info.png"), "Description", new Jid("222", xmppSession.getDomain(), "filetransfer"), 5000);
                    fileTransfer.transfer();

                } catch (Exception e) {
                    e.printStackTrace();
                }
View Full Code Here

        Assert.assertEquals(DatatypeConverter.printBase64Binary(scramSaslClient.hi("test".getBytes(), "salt".getBytes(), 4096)), "suIjHg0e14CDoom6wmHKz3naWOc=");
    }

    @Test
    public void testSasl() throws SaslException {
        XmppSession xmppSession = new TestXmppSession();
        String[] preferredMechanisms = xmppSession.getAuthenticationManager().getPreferredMechanisms().toArray(new String[xmppSession.getAuthenticationManager().getPreferredMechanisms().size()]);
        SaslClient sc = Sasl.createSaslClient(preferredMechanisms, "authorizationId", "xmpp", "localhost", null, new CallbackHandler() {
            @Override
            public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
                for (Callback callback : callbacks) {
                    if (callback instanceof NameCallback) {
View Full Code Here

                    XmppSessionConfiguration configuration = XmppSessionConfiguration.builder()
                            .debugger(VisualDebugger.class)
                            .defaultResponseTimeout(5000)
                            .build();

                    XmppSession xmppSession = new XmppSession("localhost", configuration, tcpConfiguration);

                    // Connect
                    xmppSession.connect();
                    // Login
                    xmppSession.login("222", "222", "muc");
                    // Send initial presence
                    xmppSession.send(new Presence());

                    MultiUserChatManager multiUserChatManager = xmppSession.getExtensionManager(MultiUserChatManager.class);
                    ChatService chatService = multiUserChatManager.createChatService(Jid.valueOf("conference." + xmppSession.getDomain()));
                    ChatRoom chatRoom = chatService.createRoom("test");
                    chatRoom.addOccupantListener(new OccupantListener() {
                        @Override
                        public void occupantChanged(OccupantEvent e) {
                            if (e.getType() == OccupantEvent.Type.ENTERED) {
View Full Code Here

                    TcpConnectionConfiguration tcpConfiguration = TcpConnectionConfiguration.builder()
                            .port(5222)
                            .secure(false)
                            .build();

                    XmppSession xmppSession = new XmppSession("localhost", tcpConfiguration);

                    // Connect
                    xmppSession.connect();
                    // Login
                    xmppSession.login("222", "222", "geolocation");

//                    GeoLocationManager geoLocationManager = xmppSession.getExtensionManager(GeoLocationManager.class);
//                    geoLocationManager.setEnabled(true);
//                    geoLocationManager.addGeoLocationListener(new GeoLocationListener() {
//                        @Override
//                        public void geoLocationUpdated(GeoLocationEvent e) {
//                            System.out.println(e.getPublisher() + " updated his location: " + e.getGeoLocation());
//                        }
//                    });

                    // Send initial presence
                    xmppSession.send(new Presence());

                } catch (IOException | LoginException e) {
                    e.printStackTrace();
                }
            }
View Full Code Here

                    XmppSessionConfiguration configuration = XmppSessionConfiguration.builder()
                            .debugger(VisualDebugger.class)
                            .defaultResponseTimeout(5000)
                            .build();

                    XmppSession xmppSession = new XmppSession("localhost", configuration, tcpConfiguration);

                    // Connect
                    xmppSession.connect();
                    // Login
                    xmppSession.login("111", "111", "muc");
                    // Send initial presence
                    xmppSession.send(new Presence());

                    MultiUserChatManager multiUserChatManager = xmppSession.getExtensionManager(MultiUserChatManager.class);
                    ChatService chatService = multiUserChatManager.createChatService(Jid.valueOf("conference." + xmppSession.getDomain()));
                    ChatRoom chatRoom = chatService.createRoom("test");
                    chatRoom.addOccupantListener(new OccupantListener() {
                        @Override
                        public void occupantChanged(OccupantEvent e) {
                            if (e.getType() == OccupantEvent.Type.ENTERED) {
View Full Code Here

                    XmppSessionConfiguration configuration = XmppSessionConfiguration.builder()
                            .debugger(VisualDebugger.class)
                            .defaultResponseTimeout(5000)
                            .build();

                    XmppSession xmppSession = new XmppSession("localhost", configuration, tcpConfiguration);

                    // Listen for incoming messages.
                    xmppSession.addMessageListener(new MessageListener() {
                        @Override
                        public void handle(MessageEvent e) {
                            if (e.isIncoming()) {
                                System.out.println(e.getMessage());
                            }
                        }
                    });

                    // Connect
                    xmppSession.connect();
                    // Login
                    xmppSession.login("111", "111", "geolocation");
                    // Send initial presence
                    xmppSession.send(new Presence());

//                    GeoLocationManager geoLocationManager = xmppSession.getExtensionManager(GeoLocationManager.class);
//                    geoLocationManager.publish(new GeoLocation(123, 321));

                } catch (IOException | LoginException e) {
View Full Code Here

                    XmppSessionConfiguration configuration = XmppSessionConfiguration.builder()
                            .debugger(VisualDebugger.class)
                            .defaultResponseTimeout(5000)
                            .build();

                    XmppSession xmppSession = new XmppSession("localhost", configuration, tcpConfiguration);

                    // Connect
                    xmppSession.connect();
                    // Login
                    xmppSession.login("222", "222", "filetransfer");
                    // Send initial presence
                    xmppSession.send(new Presence());

                    FileTransferManager fileTransferManager = xmppSession.getExtensionManager(FileTransferManager.class);
                    fileTransferManager.addFileTransferOfferListener(new FileTransferOfferListener() {
                        @Override
                        public void fileTransferOffered(FileTransferOfferEvent e) {
                            try {
                                FileTransfer fileTransfer = e.accept(new FileOutputStream(new File("test.png")));
View Full Code Here

TOP

Related Classes of rocks.xmpp.core.session.XmppSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.