Java 类org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamSession 实例源码

项目:lider    文件:XMPPClientImpl.java   
/**
 * Send file to provided JID via a SOCKS5 Bytestream session (XEP-0065).
 * 
 * @param file
 * @param jid
 * @throws SmackException
 * @throws InterruptedException
 * @throws IOException
 * @throws XMPPException
 */
public void sendFile(byte[] file, String jid)
        throws XMPPException, IOException, InterruptedException, SmackException {
    String jidFinal = getFullJid(jid);
    jidFinal += "/receiver";
    Socks5BytestreamManager bytestreamManager = Socks5BytestreamManager.getBytestreamManager(connection);
    OutputStream outputStream = null;
    try {
        Socks5BytestreamSession session = bytestreamManager.establishSession(jidFinal);
        outputStream = session.getOutputStream();
        outputStream.write(file);
        outputStream.flush();
    } finally {
        if (outputStream != null) {
            try {
                outputStream.close();
            } catch (IOException e) {
                logger.error(e.getMessage(), e);
            }
        }
    }
}
项目:Smack    文件:Socks5TransferNegotiator.java   
@Override
InputStream negotiateIncomingStream(Stanza streamInitiation) throws InterruptedException,
                SmackException, XMPPErrorException {
    // build SOCKS5 Bytestream request
    Socks5BytestreamRequest request = new ByteStreamRequest(this.manager,
                    (Bytestream) streamInitiation);

    // always accept the request
    Socks5BytestreamSession session = request.accept();

    // test input stream
    try {
        PushbackInputStream stream = new PushbackInputStream(session.getInputStream());
        int firstByte = stream.read();
        stream.unread(firstByte);
        return stream;
    }
    catch (IOException e) {
        throw new SmackException("Error establishing input stream", e);
    }
}
项目:EIM    文件:Socks5TransferNegotiator.java   
@Override
InputStream negotiateIncomingStream(Packet streamInitiation) throws XMPPException,
                InterruptedException {
    // build SOCKS5 Bytestream request
    Socks5BytestreamRequest request = new ByteStreamRequest(this.manager,
                    (Bytestream) streamInitiation);

    // always accept the request
    Socks5BytestreamSession session = request.accept();

    // test input stream
    try {
        PushbackInputStream stream = new PushbackInputStream(session.getInputStream());
        int firstByte = stream.read();
        stream.unread(firstByte);
        return stream;
    }
    catch (IOException e) {
        throw new XMPPException("Error establishing input stream", e);
    }
}
项目:androidPN-client.    文件:Socks5TransferNegotiator.java   
@Override
InputStream negotiateIncomingStream(Packet streamInitiation) throws XMPPException,
                InterruptedException {
    // build SOCKS5 Bytestream request
    Socks5BytestreamRequest request = new ByteStreamRequest(this.manager,
                    (Bytestream) streamInitiation);

    // always accept the request
    Socks5BytestreamSession session = request.accept();

    // test input stream
    try {
        PushbackInputStream stream = new PushbackInputStream(session.getInputStream());
        int firstByte = stream.read();
        stream.unread(firstByte);
        return stream;
    }
    catch (IOException e) {
        throw new XMPPException("Error establishing input stream", e);
    }
}
项目:xmppsupport_v2    文件:Socks5TransferNegotiator.java   
@Override
InputStream negotiateIncomingStream(Packet streamInitiation)
        throws XMPPException, InterruptedException {
    // build SOCKS5 Bytestream request
    Socks5BytestreamRequest request = new ByteStreamRequest(this.manager,
            (Bytestream) streamInitiation);

    // always accept the request
    Socks5BytestreamSession session = request.accept();

    // test input stream
    try {
        PushbackInputStream stream = new PushbackInputStream(
                session.getInputStream());
        int firstByte = stream.read();
        stream.unread(firstByte);
        return stream;
    } catch (IOException e) {
        throw new XMPPException("Error establishing input stream", e);
    }
}
项目:java-bells    文件:Socks5TransferNegotiator.java   
@Override
InputStream negotiateIncomingStream(Packet streamInitiation) throws XMPPException,
                InterruptedException {
    // build SOCKS5 Bytestream request
    Socks5BytestreamRequest request = new ByteStreamRequest(this.manager,
                    (Bytestream) streamInitiation);

    // always accept the request
    Socks5BytestreamSession session = request.accept();

    // test input stream
    try {
        PushbackInputStream stream = new PushbackInputStream(session.getInputStream());
        int firstByte = stream.read();
        stream.unread(firstByte);
        return stream;
    }
    catch (IOException e) {
        throw new XMPPException("Error establishing input stream", e);
    }
}
项目:telegraph    文件:Socks5TransferNegotiator.java   
@Override
InputStream negotiateIncomingStream(Packet streamInitiation) throws XMPPException,
                InterruptedException {
    // build SOCKS5 Bytestream request
    Socks5BytestreamRequest request = new ByteStreamRequest(this.manager,
                    (Bytestream) streamInitiation);

    // always accept the request
    Socks5BytestreamSession session = request.accept();

    // test input stream
    try {
        PushbackInputStream stream = new PushbackInputStream(session.getInputStream());
        int firstByte = stream.read();
        stream.unread(firstByte);
        return stream;
    }
    catch (IOException e) {
        throw new XMPPException("Error establishing input stream", e);
    }
}