Package rocks.xmpp.extensions.bytestreams.s5b.model

Examples of rocks.xmpp.extensions.bytestreams.s5b.model.Socks5ByteStream


            @Override
            public void handle(IQEvent e) {
                IQ iq = e.getIQ();
                if (e.isIncoming() && isEnabled() && !e.isConsumed() && iq.getType() == IQ.Type.SET) {

                    Socks5ByteStream socks5ByteStream = iq.getExtension(Socks5ByteStream.class);
                    if (socks5ByteStream != null) {
                        if (socks5ByteStream.getSessionId() == null) {
                            // If the request is malformed (e.g., the <query/> element does not include the 'sid' attribute), the Target MUST return an error of <bad-request/>.
                            xmppSession.send(iq.createError(new StanzaError(new BadRequest())));
                        } else {
                            notifyByteStreamEvent(new S5bEvent(Socks5ByteStreamManager.this, socks5ByteStream.getSessionId(), xmppSession, iq, socks5ByteStream.getStreamHosts()));
                        }
                        e.consume();
                    }
                }
            }
View Full Code Here


    public List<StreamHost> discoverProxies() throws XmppException {
        ItemNode itemNode = serviceDiscoveryManager.discoverItems(null);
        for (Item item : itemNode.getItems()) {
            InfoNode infoNode = serviceDiscoveryManager.discoverInformation(item.getJid());
            if (infoNode.getFeatures().contains(new Feature(Socks5ByteStream.NAMESPACE))) {
                IQ result = xmppSession.query(new IQ(item.getJid(), IQ.Type.GET, new Socks5ByteStream()));
                Socks5ByteStream socks5ByteStream = result.getExtension(Socks5ByteStream.class);
                if (socks5ByteStream != null) {
                    return socks5ByteStream.getStreamHosts();
                }
            }
        }
        return Collections.emptyList();
    }
View Full Code Here

        localSocks5Server.allowedAddresses.add(hash);

        try {
            // 5.3.1 Requester Initiates S5B Negotiation
            // 6.3.1 Requester Initiates S5B Negotiation
            IQ result = xmppSession.query(new IQ(target, IQ.Type.SET, new Socks5ByteStream(sessionId, streamHosts, hash)));

            // 5.3.3 Target Acknowledges Bytestream
            // 6.3.3 Target Acknowledges Bytestream
            Socks5ByteStream socks5ByteStream = result.getExtension(Socks5ByteStream.class);
            StreamHost usedStreamHost = null;
            for (StreamHost streamHost : streamHosts) {
                if (socks5ByteStream.getStreamHostUsed() != null && socks5ByteStream.getStreamHostUsed().equals(streamHost.getJid())) {
                    usedStreamHost = streamHost;
                    break;
                }
            }
View Full Code Here

                "        host='24.24.24.1'\n" +
                "        jid='streamer.example.com'\n" +
                "        port='7625'/>\n" +
                "  </query>\n";

        Socks5ByteStream data = unmarshal(xml, Socks5ByteStream.class);
        Assert.assertNotNull(data);
        Assert.assertEquals(data.getStreamHosts().size(), 1);
        Assert.assertEquals(data.getStreamHosts().get(0).getHost(), "24.24.24.1");
        Assert.assertEquals(data.getStreamHosts().get(0).getJid(), Jid.valueOf("streamer.example.com"));
        Assert.assertEquals(data.getStreamHosts().get(0).getPort(), 7625);
    }
View Full Code Here

TOP

Related Classes of rocks.xmpp.extensions.bytestreams.s5b.model.Socks5ByteStream

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.