Examples of BytestreamSession


Examples of org.jivesoftware.smackx.bytestreams.BytestreamSession

        if (inSession == null && outSession == null)
            throw new IOException(prefix()
                + "Neither connection could be established. ");

        BytestreamSession session = testAndGetMediatedBidirectionalBytestream(
            inSession, outSession, true);
        return new BinaryChannel(session, NetTransferMode.SOCKS5_MEDIATED);
    }
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.BytestreamSession

                        exception);
                else
                    log.debug(msg);
            }

            BytestreamSession session = testAndGetMediatedBidirectionalBytestream(
                inSession, outSession, false);
            return new BinaryChannel(session, NetTransferMode.SOCKS5_MEDIATED);

        } finally {
            runningConnects.remove(peer);
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.BytestreamSession

     * @throws InterruptedException
     */
    protected BinaryChannel establishBinaryChannel(String peer,
        SubMonitor progress) throws XMPPException, IOException,
        InterruptedException {
        BytestreamSession session = manager.establishSession(peer.toString());

        return new BinaryChannel(session, getDefaultNetTransferMode());
    }
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.BytestreamSession

     * @throws IOException
     */
    protected BinaryChannel acceptRequest(BytestreamRequest request)
        throws InterruptedException, Exception {

        BytestreamSession session = request.accept();
        BinaryChannel channel = new BinaryChannel(session,
            getDefaultNetTransferMode());

        return channel;
    }
View Full Code Here

Examples of rocks.xmpp.extensions.bytestreams.ByteStreamSession

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

                        try {
                            ibbSession = e.accept();

                            new Thread() {
                                @Override
                                public void run() {

                                    InputStream inputStream;
                                    try {
                                        inputStream = ibbSession.getInputStream();

                                        int b;
                                        while ((b = inputStream.read()) > -1) {
                                            outputStream.write(b);
                                        }
                                        outputStream.flush();
                                        outputStream.close();
                                        inputStream.close();

                                    } catch (IOException e1) {
                                        e1.printStackTrace();
                                    } finally {
                                        try {
                                            lock.lock();
                                            condition.signal();
                                        } finally {
                                            lock.unlock();
                                        }
                                    }
                                }
                            }.start();
                        } catch (IOException e1) {
                            e1.printStackTrace();
                        }
                    }
                });

                InBandByteStreamManager inBandBytestreamManager1 = xmppSession1.getExtensionManager(InBandByteStreamManager.class);
                ByteStreamSession ibbSession;
                try {
                    ibbSession = inBandBytestreamManager1.initiateSession(JULIET, "sid", 4096);
                    OutputStream os = ibbSession.getOutputStream();
                    os.write(new byte[]{1, 2, 3, 4});
                    os.flush();
                    os.close();
                } catch (IOException | XmppException e) {
                    e.printStackTrace();
View Full Code Here

Examples of rocks.xmpp.extensions.bytestreams.ByteStreamSession

        FeatureNegotiation featureNegotiation = streamInitiation.getFeatureNegotiation();
        // Get the stream method which has been chosen by the recipient.
        String streamMethod = featureNegotiation.getDataForm().findField(STREAM_METHOD).getValues().get(0);

        ByteStreamSession byteStreamSession;
        // Choose the stream method to be used based on the recipient's choice.
        switch (streamMethod) {
            case Socks5ByteStream.NAMESPACE:
                try {
                    byteStreamSession = socks5ByteStreamManager.initiateSession(receiver, sessionId);
                } catch (Exception e) {
                    // As fallback, if SOCKS5 negotiation failed, try IBB.
                    byteStreamSession = inBandByteStreamManager.initiateSession(receiver, sessionId, 4096);
                }
                break;
            case InBandByteStream.NAMESPACE:
                byteStreamSession = inBandByteStreamManager.initiateSession(receiver, sessionId, 4096);
                break;
            default:
                throw new IOException("Receiver returned unsupported stream method.");
        }
        return byteStreamSession.getOutputStream();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.