Java 类org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest 实例源码

项目:Smack    文件:IBBTransferNegotiator.java   
InputStream negotiateIncomingStream(Stanza streamInitiation) throws NotConnectedException {
    // build In-Band Bytestream request
    InBandBytestreamRequest request = new ByteStreamRequest(this.manager,
                    (Open) streamInitiation);

    // always accept the request
    InBandBytestreamSession session = request.accept();
    session.setCloseBothStreamsEnabled(true);
    return session.getInputStream();
}
项目:EIM    文件:IBBTransferNegotiator.java   
InputStream negotiateIncomingStream(Packet streamInitiation) throws XMPPException {
    // build In-Band Bytestream request
    InBandBytestreamRequest request = new ByteStreamRequest(this.manager,
                    (Open) streamInitiation);

    // always accept the request
    InBandBytestreamSession session = request.accept();
    session.setCloseBothStreamsEnabled(true);
    return session.getInputStream();
}
项目:androidPN-client.    文件:IBBTransferNegotiator.java   
InputStream negotiateIncomingStream(Packet streamInitiation) throws XMPPException {
    // build In-Band Bytestream request
    InBandBytestreamRequest request = new ByteStreamRequest(this.manager,
                    (Open) streamInitiation);

    // always accept the request
    InBandBytestreamSession session = request.accept();
    session.setCloseBothStreamsEnabled(true);
    return session.getInputStream();
}
项目:xmppsupport_v2    文件:IBBTransferNegotiator.java   
InputStream negotiateIncomingStream(Packet streamInitiation)
        throws XMPPException {
    // build In-Band Bytestream request
    InBandBytestreamRequest request = new ByteStreamRequest(this.manager,
            (Open) streamInitiation);

    // always accept the request
    InBandBytestreamSession session = request.accept();
    session.setCloseBothStreamsEnabled(true);
    return session.getInputStream();
}
项目:java-bells    文件:IBBTransferNegotiator.java   
InputStream negotiateIncomingStream(Packet streamInitiation) throws XMPPException {
    // build In-Band Bytestream request
    InBandBytestreamRequest request = new ByteStreamRequest(this.manager,
                    (Open) streamInitiation);

    // always accept the request
    InBandBytestreamSession session = request.accept();
    session.setCloseBothStreamsEnabled(true);
    return session.getInputStream();
}
项目:telegraph    文件:IBBTransferNegotiator.java   
InputStream negotiateIncomingStream(Packet streamInitiation) throws XMPPException {
    // build In-Band Bytestream request
    InBandBytestreamRequest request = new ByteStreamRequest(this.manager,
                    (Open) streamInitiation);

    // always accept the request
    InBandBytestreamSession session = request.accept();
    session.setCloseBothStreamsEnabled(true);
    return session.getInputStream();
}
项目:Smack    文件:InBandBytestreamTest.java   
/**
 * An In-Band Bytestream should be successfully established using IQ stanzas.
 * 
 * @throws Exception should not happen
 */
public void testInBandBytestreamWithIQStanzas() throws Exception {

    XMPPConnection initiatorConnection = getConnection(0);
    XMPPConnection targetConnection = getConnection(1);

    // test data
    Random rand = new Random();
    final byte[] data = new byte[dataSize];
    rand.nextBytes(data);
    final SynchronousQueue<byte[]> queue = new SynchronousQueue<byte[]>();

    InBandBytestreamManager targetByteStreamManager = InBandBytestreamManager.getByteStreamManager(targetConnection);

    InBandBytestreamListener incomingByteStreamListener = new InBandBytestreamListener() {

        public void incomingBytestreamRequest(InBandBytestreamRequest request) {
            InputStream inputStream;
            try {
                inputStream = request.accept().getInputStream();
                byte[] receivedData = new byte[dataSize];
                int totalRead = 0;
                while (totalRead < dataSize) {
                    int read = inputStream.read(receivedData, totalRead, dataSize - totalRead);
                    totalRead += read;
                }
                queue.put(receivedData);
            }
            catch (Exception e) {
                fail(e.getMessage());
            }
        }

    };
    targetByteStreamManager.addIncomingBytestreamListener(incomingByteStreamListener);

    InBandBytestreamManager initiatorByteStreamManager = InBandBytestreamManager.getByteStreamManager(initiatorConnection);

    OutputStream outputStream = initiatorByteStreamManager.establishSession(
                    targetConnection.getUser()).getOutputStream();

    // verify stream
    outputStream.write(data);
    outputStream.flush();
    outputStream.close();

    assertEquals("received data not equal to sent data", data, queue.take());

}
项目:Smack    文件:InBandBytestreamTest.java   
/**
 * An In-Band Bytestream should be successfully established using message stanzas.
 * 
 * @throws Exception should not happen
 */
public void testInBandBytestreamWithMessageStanzas() throws Exception {

    XMPPConnection initiatorConnection = getConnection(0);
    XMPPConnection targetConnection = getConnection(1);

    // test data
    Random rand = new Random();
    final byte[] data = new byte[dataSize];
    rand.nextBytes(data);
    final SynchronousQueue<byte[]> queue = new SynchronousQueue<byte[]>();

    InBandBytestreamManager targetByteStreamManager = InBandBytestreamManager.getByteStreamManager(targetConnection);

    InBandBytestreamListener incomingByteStreamListener = new InBandBytestreamListener() {

        public void incomingBytestreamRequest(InBandBytestreamRequest request) {
            InputStream inputStream;
            try {
                inputStream = request.accept().getInputStream();
                byte[] receivedData = new byte[dataSize];
                int totalRead = 0;
                while (totalRead < dataSize) {
                    int read = inputStream.read(receivedData, totalRead, dataSize - totalRead);
                    totalRead += read;
                }
                queue.put(receivedData);
            }
            catch (Exception e) {
                fail(e.getMessage());
            }
        }

    };
    targetByteStreamManager.addIncomingBytestreamListener(incomingByteStreamListener);

    InBandBytestreamManager initiatorByteStreamManager = InBandBytestreamManager.getByteStreamManager(initiatorConnection);
    initiatorByteStreamManager.setStanza(StanzaType.MESSAGE);

    OutputStream outputStream = initiatorByteStreamManager.establishSession(
                    targetConnection.getUser()).getOutputStream();

    // verify stream
    outputStream.write(data);
    outputStream.flush();
    outputStream.close();

    assertEquals("received data not equal to sent data", data, queue.take());

}
项目:java-bells    文件:InBandBytestreamTest.java   
/**
 * An In-Band Bytestream should be successfully established using IQ stanzas.
 * 
 * @throws Exception should not happen
 */
public void testInBandBytestreamWithIQStanzas() throws Exception {

    Connection initiatorConnection = getConnection(0);
    Connection targetConnection = getConnection(1);

    // test data
    Random rand = new Random();
    final byte[] data = new byte[dataSize];
    rand.nextBytes(data);
    final SynchronousQueue<byte[]> queue = new SynchronousQueue<byte[]>();

    InBandBytestreamManager targetByteStreamManager = InBandBytestreamManager.getByteStreamManager(targetConnection);

    InBandBytestreamListener incomingByteStreamListener = new InBandBytestreamListener() {

        public void incomingBytestreamRequest(InBandBytestreamRequest request) {
            InputStream inputStream;
            try {
                inputStream = request.accept().getInputStream();
                byte[] receivedData = new byte[dataSize];
                int totalRead = 0;
                while (totalRead < dataSize) {
                    int read = inputStream.read(receivedData, totalRead, dataSize - totalRead);
                    totalRead += read;
                }
                queue.put(receivedData);
            }
            catch (Exception e) {
                fail(e.getMessage());
            }
        }

    };
    targetByteStreamManager.addIncomingBytestreamListener(incomingByteStreamListener);

    InBandBytestreamManager initiatorByteStreamManager = InBandBytestreamManager.getByteStreamManager(initiatorConnection);

    OutputStream outputStream = initiatorByteStreamManager.establishSession(
                    targetConnection.getUser()).getOutputStream();

    // verify stream
    outputStream.write(data);
    outputStream.flush();
    outputStream.close();

    assertEquals("received data not equal to sent data", data, queue.take());

}
项目:java-bells    文件:InBandBytestreamTest.java   
/**
 * An In-Band Bytestream should be successfully established using message stanzas.
 * 
 * @throws Exception should not happen
 */
public void testInBandBytestreamWithMessageStanzas() throws Exception {

    Connection initiatorConnection = getConnection(0);
    Connection targetConnection = getConnection(1);

    // test data
    Random rand = new Random();
    final byte[] data = new byte[dataSize];
    rand.nextBytes(data);
    final SynchronousQueue<byte[]> queue = new SynchronousQueue<byte[]>();

    InBandBytestreamManager targetByteStreamManager = InBandBytestreamManager.getByteStreamManager(targetConnection);

    InBandBytestreamListener incomingByteStreamListener = new InBandBytestreamListener() {

        public void incomingBytestreamRequest(InBandBytestreamRequest request) {
            InputStream inputStream;
            try {
                inputStream = request.accept().getInputStream();
                byte[] receivedData = new byte[dataSize];
                int totalRead = 0;
                while (totalRead < dataSize) {
                    int read = inputStream.read(receivedData, totalRead, dataSize - totalRead);
                    totalRead += read;
                }
                queue.put(receivedData);
            }
            catch (Exception e) {
                fail(e.getMessage());
            }
        }

    };
    targetByteStreamManager.addIncomingBytestreamListener(incomingByteStreamListener);

    InBandBytestreamManager initiatorByteStreamManager = InBandBytestreamManager.getByteStreamManager(initiatorConnection);
    initiatorByteStreamManager.setStanza(StanzaType.MESSAGE);

    OutputStream outputStream = initiatorByteStreamManager.establishSession(
                    targetConnection.getUser()).getOutputStream();

    // verify stream
    outputStream.write(data);
    outputStream.flush();
    outputStream.close();

    assertEquals("received data not equal to sent data", data, queue.take());

}