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

项目:Smack    文件:OpenIQProvider.java   
@Override
public Open parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
    String sessionID = parser.getAttributeValue("", "sid");
    int blockSize = Integer.parseInt(parser.getAttributeValue("", "block-size"));

    String stanzaValue = parser.getAttributeValue("", "stanza");
    StanzaType stanza = null;
    if (stanzaValue == null) {
        stanza = StanzaType.IQ;
    }
    else {
        stanza = StanzaType.valueOf(stanzaValue.toUpperCase(Locale.US));
    }

    parser.next();

    return new Open(sessionID, blockSize, stanza);
}
项目:Smack    文件:InBandBytestreamSession.java   
/**
 * Constructor.
 * 
 * @param connection the XMPP connection
 * @param byteStreamRequest the In-Band Bytestream open request for this session
 * @param remoteJID JID of the remote peer
 */
protected InBandBytestreamSession(XMPPConnection connection, Open byteStreamRequest,
                String remoteJID) {
    this.connection = connection;
    this.byteStreamRequest = byteStreamRequest;
    this.remoteJID = remoteJID;

    // initialize streams dependent to the uses stanza type
    switch (byteStreamRequest.getStanza()) {
    case IQ:
        this.inputStream = new IQIBBInputStream();
        this.outputStream = new IQIBBOutputStream();
        break;
    case MESSAGE:
        this.inputStream = new MessageIBBInputStream();
        this.outputStream = new MessageIBBOutputStream();
        break;
    }

}
项目:Smack    文件:InBandBytestreamTest.java   
/**
 * Target should respond with not-acceptable error if no listeners for incoming In-Band
 * Bytestream requests are registered.
 * 
 * @throws XMPPException should not happen
 */
public void testRespondWithErrorOnInBandBytestreamRequest() throws XMPPException {
    XMPPConnection targetConnection = getConnection(0);

    XMPPConnection initiatorConnection = getConnection(1);

    Open open = new Open("sessionID", 1024);
    open.setFrom(initiatorConnection.getUser());
    open.setTo(targetConnection.getUser());

    PacketCollector collector = initiatorConnection.createPacketCollector(new PacketIDFilter(
                    open.getStanzaId()));
    initiatorConnection.sendStanza(open);
    Packet result = collector.nextResult();

    assertNotNull(result.getError());
    assertEquals(XMPPError.Condition.no_acceptable.toString(), result.getError().getCondition());

}
项目:Smack    文件:InitiationListenerTest.java   
/**
 * Initialize fields used in the tests.
 */
@Before
public void setup() {

    // mock connection
    connection = mock(XMPPConnection.class);

    // initialize InBandBytestreamManager to get the InitiationListener
    byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);

    // get the InitiationListener from InBandByteStreamManager
    initiationListener = Whitebox.getInternalState(byteStreamManager, InitiationListener.class);

    // create a In-Band Bytestream open packet
    initBytestream = new Open(sessionID, 4096);
    initBytestream.setFrom(initiatorJID);
    initBytestream.setTo(targetJID);

}
项目:Smack    文件:InBandBytestreamManagerTest.java   
@Test
public void shouldUseConfiguredStanzaType() throws SmackException {
    InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
    byteStreamManager.setStanza(StanzaType.MESSAGE);

    protocol.addResponse(null, new Verification<Open, IQ>() {

        public void verify(Open request, IQ response) {
            assertEquals(StanzaType.MESSAGE, request.getStanza());
        }

    });

    try {
        // start In-Band Bytestream
        byteStreamManager.establishSession(targetJID);
    }
    catch (XMPPException e) {
        protocol.verifyAll();
    }

}
项目:Smack    文件:InBandBytestreamRequestTest.java   
/**
 * Initialize fields used in the tests.
 */
@Before
public void setup() {

    // mock connection
    connection = mock(XMPPConnection.class);

    // initialize InBandBytestreamManager to get the InitiationListener
    byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);

    // create a In-Band Bytestream open packet
    initBytestream = new Open(sessionID, 4096);
    initBytestream.setFrom(initiatorJID);
    initBytestream.setTo(targetJID);

}
项目:EIM    文件:InBandBytestreamSession.java   
/**
 * Constructor.
 * 
 * @param connection the XMPP connection
 * @param byteStreamRequest the In-Band Bytestream open request for this session
 * @param remoteJID JID of the remote peer
 */
protected InBandBytestreamSession(Connection connection, Open byteStreamRequest,
                String remoteJID) {
    this.connection = connection;
    this.byteStreamRequest = byteStreamRequest;
    this.remoteJID = remoteJID;

    // initialize streams dependent to the uses stanza type
    switch (byteStreamRequest.getStanza()) {
    case IQ:
        this.inputStream = new IQIBBInputStream();
        this.outputStream = new IQIBBOutputStream();
        break;
    case MESSAGE:
        this.inputStream = new MessageIBBInputStream();
        this.outputStream = new MessageIBBOutputStream();
        break;
    }

}
项目:androidPN-client.    文件:InBandBytestreamSession.java   
/**
 * Constructor.
 * 
 * @param connection the XMPP connection
 * @param byteStreamRequest the In-Band Bytestream open request for this session
 * @param remoteJID JID of the remote peer
 */
protected InBandBytestreamSession(Connection connection, Open byteStreamRequest,
                String remoteJID) {
    this.connection = connection;
    this.byteStreamRequest = byteStreamRequest;
    this.remoteJID = remoteJID;

    // initialize streams dependent to the uses stanza type
    switch (byteStreamRequest.getStanza()) {
    case IQ:
        this.inputStream = new IQIBBInputStream();
        this.outputStream = new IQIBBOutputStream();
        break;
    case MESSAGE:
        this.inputStream = new MessageIBBInputStream();
        this.outputStream = new MessageIBBOutputStream();
        break;
    }

}
项目:xmppsupport_v2    文件:InBandBytestreamManager.java   
/**
 * Establishes an In-Band Bytestream with the given user using the given
 * session ID and returns the session to send/receive data to/from the user.
 * 
 * @param targetJID
 *            the JID of the user an In-Band Bytestream should be
 *            established
 * @param sessionID
 *            the session ID for the In-Band Bytestream request
 * @return the session to send/receive data to/from the user
 * @throws XMPPException
 *             if the user doesn't support or accept in-band bytestreams, or
 *             if the user prefers smaller block sizes
 */
public InBandBytestreamSession establishSession(String targetJID,
        String sessionID) throws XMPPException {
    Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize,
            this.stanza);
    byteStreamRequest.setTo(targetJID);

    // sending packet will throw exception on timeout or error reply
    SyncPacketSend.getReply(this.connection, byteStreamRequest);

    InBandBytestreamSession inBandBytestreamSession = new InBandBytestreamSession(
            this.connection, byteStreamRequest, targetJID);
    this.sessions.put(sessionID, inBandBytestreamSession);

    return inBandBytestreamSession;
}
项目:xmppsupport_v2    文件:InBandBytestreamSession.java   
/**
 * Constructor.
 * 
 * @param connection
 *            the XMPP connection
 * @param byteStreamRequest
 *            the In-Band Bytestream open request for this session
 * @param remoteJID
 *            JID of the remote peer
 */
protected InBandBytestreamSession(Connection connection,
        Open byteStreamRequest, String remoteJID) {
    this.connection = connection;
    this.byteStreamRequest = byteStreamRequest;
    this.remoteJID = remoteJID;

    // initialize streams dependent to the uses stanza type
    switch (byteStreamRequest.getStanza()) {
    case IQ:
        this.inputStream = new IQIBBInputStream();
        this.outputStream = new IQIBBOutputStream();
        break;
    case MESSAGE:
        this.inputStream = new MessageIBBInputStream();
        this.outputStream = new MessageIBBOutputStream();
        break;
    }

}
项目:java-bells    文件:InBandBytestreamSession.java   
/**
 * Constructor.
 * 
 * @param connection the XMPP connection
 * @param byteStreamRequest the In-Band Bytestream open request for this session
 * @param remoteJID JID of the remote peer
 */
protected InBandBytestreamSession(Connection connection, Open byteStreamRequest,
                String remoteJID) {
    this.connection = connection;
    this.byteStreamRequest = byteStreamRequest;
    this.remoteJID = remoteJID;

    // initialize streams dependent to the uses stanza type
    switch (byteStreamRequest.getStanza()) {
    case IQ:
        this.inputStream = new IQIBBInputStream();
        this.outputStream = new IQIBBOutputStream();
        break;
    case MESSAGE:
        this.inputStream = new MessageIBBInputStream();
        this.outputStream = new MessageIBBOutputStream();
        break;
    }

}
项目:java-bells    文件:InBandBytestreamTest.java   
/**
 * Target should respond with not-acceptable error if no listeners for incoming In-Band
 * Bytestream requests are registered.
 * 
 * @throws XMPPException should not happen
 */
public void testRespondWithErrorOnInBandBytestreamRequest() throws XMPPException {
    Connection targetConnection = getConnection(0);

    Connection initiatorConnection = getConnection(1);

    Open open = new Open("sessionID", 1024);
    open.setFrom(initiatorConnection.getUser());
    open.setTo(targetConnection.getUser());

    PacketCollector collector = initiatorConnection.createPacketCollector(new PacketIDFilter(
                    open.getPacketID()));
    initiatorConnection.sendPacket(open);
    Packet result = collector.nextResult();

    assertNotNull(result.getError());
    assertEquals(XMPPError.Condition.no_acceptable.toString(), result.getError().getCondition());

}
项目:telegraph    文件:InBandBytestreamSession.java   
/**
 * Constructor.
 * 
 * @param connection the XMPP connection
 * @param byteStreamRequest the In-Band Bytestream open request for this session
 * @param remoteJID JID of the remote peer
 */
protected InBandBytestreamSession(Connection connection, Open byteStreamRequest,
                String remoteJID) {
    this.connection = connection;
    this.byteStreamRequest = byteStreamRequest;
    this.remoteJID = remoteJID;

    // initialize streams dependent to the uses stanza type
    switch (byteStreamRequest.getStanza()) {
    case IQ:
        this.inputStream = new IQIBBInputStream();
        this.outputStream = new IQIBBOutputStream();
        break;
    case MESSAGE:
        this.inputStream = new MessageIBBInputStream();
        this.outputStream = new MessageIBBOutputStream();
        break;
    }

}
项目:Smack    文件:InitiationListener.java   
private void processRequest(Stanza packet) throws NotConnectedException {
    Open ibbRequest = (Open) packet;

    // validate that block size is within allowed range
    if (ibbRequest.getBlockSize() > this.manager.getMaximumBlockSize()) {
        this.manager.replyResourceConstraintPacket(ibbRequest);
        return;
    }

    StreamNegotiator.signal(ibbRequest.getFrom() + '\t' + ibbRequest.getSessionID(), ibbRequest);

    // ignore request if in ignore list
    if (this.manager.getIgnoredBytestreamRequests().remove(ibbRequest.getSessionID()))
        return;

    // build bytestream request from packet
    InBandBytestreamRequest request = new InBandBytestreamRequest(this.manager, ibbRequest);

    // notify listeners for bytestream initiation from a specific user
    BytestreamListener userListener = this.manager.getUserListener(ibbRequest.getFrom());
    if (userListener != null) {
        userListener.incomingBytestreamRequest(request);

    }
    else if (!this.manager.getAllRequestListeners().isEmpty()) {
        /*
         * if there is no user specific listener inform listeners for all initiation requests
         */
        for (BytestreamListener listener : this.manager.getAllRequestListeners()) {
            listener.incomingBytestreamRequest(request);
        }

    }
    else {
        /*
         * if there is no listener for this initiation request, reply with reject message
         */
        this.manager.replyRejectPacket(ibbRequest);
    }
}
项目:Smack    文件:InBandBytestreamManager.java   
/**
 * Establishes an In-Band Bytestream with the given user using the given session ID and returns
 * the session to send/receive data to/from the user.
 * 
 * @param targetJID the JID of the user an In-Band Bytestream should be established
 * @param sessionID the session ID for the In-Band Bytestream request
 * @return the session to send/receive data to/from the user
 * @throws XMPPErrorException if the user doesn't support or accept in-band bytestreams, or if the
 *         user prefers smaller block sizes
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException 
 */
public InBandBytestreamSession establishSession(String targetJID, String sessionID)
                throws NoResponseException, XMPPErrorException, NotConnectedException {
    Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize, this.stanza);
    byteStreamRequest.setTo(targetJID);

    // sending packet will throw exception on timeout or error reply
    connection.createPacketCollectorAndSend(byteStreamRequest).nextResultOrThrow();

    InBandBytestreamSession inBandBytestreamSession = new InBandBytestreamSession(
                    this.connection, byteStreamRequest, targetJID);
    this.sessions.put(sessionID, inBandBytestreamSession);

    return inBandBytestreamSession;
}
项目:Smack    文件:FaultTolerantNegotiator.java   
private StreamNegotiator determineNegotiator(Stanza streamInitiation) {
    if (streamInitiation instanceof Bytestream) {
        return primaryNegotiator;
    } else if (streamInitiation instanceof Open){
        return secondaryNegotiator;
    } else {
        throw new IllegalStateException("Unknown stream initation type");
    }
}
项目: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();
}
项目:Smack    文件:OpenIQProviderTest.java   
@Test
public void shouldCorrectlyParseIQStanzaAttribute() throws Exception {
    String control = XMLBuilder.create("open")
        .a("xmlns", "http://jabber.org/protocol/ibb")
        .a("block-size", "4096")
        .a("sid", "i781hf64")
        .a("stanza", "iq")
        .asString(outputProperties);

    OpenIQProvider oip = new OpenIQProvider();
    Open open = oip.parse(getParser(control));

    assertEquals(StanzaType.IQ, open.getStanza());
}
项目:Smack    文件:OpenIQProviderTest.java   
@Test
public void shouldCorrectlyParseMessageStanzaAttribute() throws Exception {
    String control = XMLBuilder.create("open")
        .a("xmlns", "http://jabber.org/protocol/ibb")
        .a("block-size", "4096")
        .a("sid", "i781hf64")
        .a("stanza", "message")
        .asString(outputProperties);

    OpenIQProvider oip = new OpenIQProvider();
    Open open = oip.parse(getParser(control));

    assertEquals(StanzaType.MESSAGE, open.getStanza());
}
项目:Smack    文件:InBandBytestreamSessionMessageTest.java   
/**
 * Initialize fields used in the tests.
 * @throws XMPPException 
 * @throws SmackException 
 */
@Before
public void setup() throws XMPPException, SmackException {

    // build protocol verifier
    protocol = new Protocol();

    // create mocked XMPP connection
    connection = ConnectionUtils.createMockedConnection(protocol, initiatorJID, xmppServer);

    // initialize InBandBytestreamManager to get the InitiationListener
    byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);

    // create a In-Band Bytestream open packet with message stanza
    initBytestream = new Open(sessionID, blockSize, StanzaType.MESSAGE);
    initBytestream.setFrom(initiatorJID);
    initBytestream.setTo(targetJID);

    incrementingSequence = new Verification<Message, IQ>() {

        long lastSeq = 0;

        public void verify(Message request, IQ response) {
            DataPacketExtension dpe = (DataPacketExtension) request.getExtension(
                            DataPacketExtension.ELEMENT, DataPacketExtension.NAMESPACE);
            assertEquals(lastSeq++, dpe.getSeq());
        }

    };

}
项目:Smack    文件:InBandBytestreamSessionTest.java   
/**
 * Initialize fields used in the tests.
 * @throws XMPPException 
 * @throws SmackException 
 */
@Before
public void setup() throws XMPPException, SmackException {

    // build protocol verifier
    protocol = new Protocol();

    // create mocked XMPP connection
    connection = ConnectionUtils.createMockedConnection(protocol, initiatorJID, xmppServer);

    // initialize InBandBytestreamManager to get the InitiationListener
    byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);

    // create a In-Band Bytestream open packet
    initBytestream = new Open(sessionID, blockSize);
    initBytestream.setFrom(initiatorJID);
    initBytestream.setTo(targetJID);

    incrementingSequence = new Verification<Data, IQ>() {

        long lastSeq = 0;

        public void verify(Data request, IQ response) {
            assertEquals(lastSeq++, request.getDataPacketExtension().getSeq());
        }

    };

}
项目:EIM    文件:InitiationListener.java   
private void processRequest(Packet packet) {
    Open ibbRequest = (Open) packet;

    // validate that block size is within allowed range
    if (ibbRequest.getBlockSize() > this.manager.getMaximumBlockSize()) {
        this.manager.replyResourceConstraintPacket(ibbRequest);
        return;
    }

    // ignore request if in ignore list
    if (this.manager.getIgnoredBytestreamRequests().remove(ibbRequest.getSessionID()))
        return;

    // build bytestream request from packet
    InBandBytestreamRequest request = new InBandBytestreamRequest(this.manager, ibbRequest);

    // notify listeners for bytestream initiation from a specific user
    BytestreamListener userListener = this.manager.getUserListener(ibbRequest.getFrom());
    if (userListener != null) {
        userListener.incomingBytestreamRequest(request);

    }
    else if (!this.manager.getAllRequestListeners().isEmpty()) {
        /*
         * if there is no user specific listener inform listeners for all initiation requests
         */
        for (BytestreamListener listener : this.manager.getAllRequestListeners()) {
            listener.incomingBytestreamRequest(request);
        }

    }
    else {
        /*
         * if there is no listener for this initiation request, reply with reject message
         */
        this.manager.replyRejectPacket(ibbRequest);
    }
}
项目:EIM    文件:InBandBytestreamManager.java   
/**
 * Establishes an In-Band Bytestream with the given user using the given session ID and returns
 * the session to send/receive data to/from the user.
 * 
 * @param targetJID the JID of the user an In-Band Bytestream should be established
 * @param sessionID the session ID for the In-Band Bytestream request
 * @return the session to send/receive data to/from the user
 * @throws XMPPException if the user doesn't support or accept in-band bytestreams, or if the
 *         user prefers smaller block sizes
 */
public InBandBytestreamSession establishSession(String targetJID, String sessionID)
                throws XMPPException {
    Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize, this.stanza);
    byteStreamRequest.setTo(targetJID);

    // sending packet will throw exception on timeout or error reply
    SyncPacketSend.getReply(this.connection, byteStreamRequest);

    InBandBytestreamSession inBandBytestreamSession = new InBandBytestreamSession(
                    this.connection, byteStreamRequest, targetJID);
    this.sessions.put(sessionID, inBandBytestreamSession);

    return inBandBytestreamSession;
}
项目:EIM    文件:OpenIQProvider.java   
public IQ parseIQ(XmlPullParser parser) throws Exception {
    String sessionID = parser.getAttributeValue("", "sid");
    int blockSize = Integer.parseInt(parser.getAttributeValue("", "block-size"));

    String stanzaValue = parser.getAttributeValue("", "stanza");
    StanzaType stanza = null;
    if (stanzaValue == null) {
        stanza = StanzaType.IQ;
    }
    else {
        stanza = StanzaType.valueOf(stanzaValue.toUpperCase());
    }

    return new Open(sessionID, blockSize, stanza);
}
项目: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();
}
项目:EIM    文件:IBBTransferNegotiator.java   
public IBBOpenSidFilter(String sessionID) {
    super(Open.class);
    if (sessionID == null) {
        throw new IllegalArgumentException("StreamID cannot be null");
    }
    this.sessionID = sessionID;
}
项目:EIM    文件:IBBTransferNegotiator.java   
public boolean accept(Packet packet) {
    if (super.accept(packet)) {
        Open bytestream = (Open) packet;

        // packet must by of type SET and contains the given session ID
        return this.sessionID.equals(bytestream.getSessionID())
                        && IQ.Type.SET.equals(bytestream.getType());
    }
    return false;
}
项目:androidPN-client.    文件:InitiationListener.java   
private void processRequest(Packet packet) {
    Open ibbRequest = (Open) packet;

    // validate that block size is within allowed range
    if (ibbRequest.getBlockSize() > this.manager.getMaximumBlockSize()) {
        this.manager.replyResourceConstraintPacket(ibbRequest);
        return;
    }

    // ignore request if in ignore list
    if (this.manager.getIgnoredBytestreamRequests().remove(ibbRequest.getSessionID()))
        return;

    // build bytestream request from packet
    InBandBytestreamRequest request = new InBandBytestreamRequest(this.manager, ibbRequest);

    // notify listeners for bytestream initiation from a specific user
    BytestreamListener userListener = this.manager.getUserListener(ibbRequest.getFrom());
    if (userListener != null) {
        userListener.incomingBytestreamRequest(request);

    }
    else if (!this.manager.getAllRequestListeners().isEmpty()) {
        /*
         * if there is no user specific listener inform listeners for all initiation requests
         */
        for (BytestreamListener listener : this.manager.getAllRequestListeners()) {
            listener.incomingBytestreamRequest(request);
        }

    }
    else {
        /*
         * if there is no listener for this initiation request, reply with reject message
         */
        this.manager.replyRejectPacket(ibbRequest);
    }
}
项目:androidPN-client.    文件:InBandBytestreamManager.java   
/**
 * Establishes an In-Band Bytestream with the given user using the given session ID and returns
 * the session to send/receive data to/from the user.
 * 
 * @param targetJID the JID of the user an In-Band Bytestream should be established
 * @param sessionID the session ID for the In-Band Bytestream request
 * @return the session to send/receive data to/from the user
 * @throws XMPPException if the user doesn't support or accept in-band bytestreams, or if the
 *         user prefers smaller block sizes
 */
public InBandBytestreamSession establishSession(String targetJID, String sessionID)
                throws XMPPException {
    Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize, this.stanza);
    byteStreamRequest.setTo(targetJID);

    // sending packet will throw exception on timeout or error reply
    SyncPacketSend.getReply(this.connection, byteStreamRequest);

    InBandBytestreamSession inBandBytestreamSession = new InBandBytestreamSession(
                    this.connection, byteStreamRequest, targetJID);
    this.sessions.put(sessionID, inBandBytestreamSession);

    return inBandBytestreamSession;
}
项目:androidPN-client.    文件:OpenIQProvider.java   
public IQ parseIQ(XmlPullParser parser) throws Exception {
    String sessionID = parser.getAttributeValue("", "sid");
    int blockSize = Integer.parseInt(parser.getAttributeValue("", "block-size"));

    String stanzaValue = parser.getAttributeValue("", "stanza");
    StanzaType stanza = null;
    if (stanzaValue == null) {
        stanza = StanzaType.IQ;
    }
    else {
        stanza = StanzaType.valueOf(stanzaValue.toUpperCase());
    }

    return new Open(sessionID, blockSize, stanza);
}
项目: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();
}
项目:androidPN-client.    文件:IBBTransferNegotiator.java   
public IBBOpenSidFilter(String sessionID) {
    super(Open.class);
    if (sessionID == null) {
        throw new IllegalArgumentException("StreamID cannot be null");
    }
    this.sessionID = sessionID;
}
项目:androidPN-client.    文件:IBBTransferNegotiator.java   
public boolean accept(Packet packet) {
    if (super.accept(packet)) {
        Open bytestream = (Open) packet;

        // packet must by of type SET and contains the given session ID
        return this.sessionID.equals(bytestream.getSessionID())
                        && IQ.Type.SET.equals(bytestream.getType());
    }
    return false;
}
项目:xmppsupport_v2    文件:OpenIQProvider.java   
public IQ parseIQ(XmlPullParser parser) throws Exception {
    String sessionID = parser.getAttributeValue("", "sid");
    int blockSize = Integer.parseInt(parser.getAttributeValue("",
            "block-size"));

    String stanzaValue = parser.getAttributeValue("", "stanza");
    StanzaType stanza = null;
    if (stanzaValue == null) {
        stanza = StanzaType.IQ;
    } else {
        stanza = StanzaType.valueOf(stanzaValue.toUpperCase());
    }

    return new Open(sessionID, blockSize, stanza);
}
项目: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();
}
项目:xmppsupport_v2    文件:IBBTransferNegotiator.java   
public IBBOpenSidFilter(String sessionID) {
    super(Open.class);
    if (sessionID == null) {
        throw new IllegalArgumentException("StreamID cannot be null");
    }
    this.sessionID = sessionID;
}
项目:xmppsupport_v2    文件:IBBTransferNegotiator.java   
public boolean accept(Packet packet) {
    if (super.accept(packet)) {
        Open bytestream = (Open) packet;

        // packet must by of type SET and contains the given session ID
        return this.sessionID.equals(bytestream.getSessionID())
                && IQ.Type.SET.equals(bytestream.getType());
    }
    return false;
}
项目:java-bells    文件:InitiationListener.java   
private void processRequest(Packet packet) {
    Open ibbRequest = (Open) packet;

    // validate that block size is within allowed range
    if (ibbRequest.getBlockSize() > this.manager.getMaximumBlockSize()) {
        this.manager.replyResourceConstraintPacket(ibbRequest);
        return;
    }

    // ignore request if in ignore list
    if (this.manager.getIgnoredBytestreamRequests().remove(ibbRequest.getSessionID()))
        return;

    // build bytestream request from packet
    InBandBytestreamRequest request = new InBandBytestreamRequest(this.manager, ibbRequest);

    // notify listeners for bytestream initiation from a specific user
    BytestreamListener userListener = this.manager.getUserListener(ibbRequest.getFrom());
    if (userListener != null) {
        userListener.incomingBytestreamRequest(request);

    }
    else if (!this.manager.getAllRequestListeners().isEmpty()) {
        /*
         * if there is no user specific listener inform listeners for all initiation requests
         */
        for (BytestreamListener listener : this.manager.getAllRequestListeners()) {
            listener.incomingBytestreamRequest(request);
        }

    }
    else {
        /*
         * if there is no listener for this initiation request, reply with reject message
         */
        this.manager.replyRejectPacket(ibbRequest);
    }
}
项目:java-bells    文件:InBandBytestreamManager.java   
/**
 * Establishes an In-Band Bytestream with the given user using the given session ID and returns
 * the session to send/receive data to/from the user.
 * 
 * @param targetJID the JID of the user an In-Band Bytestream should be established
 * @param sessionID the session ID for the In-Band Bytestream request
 * @return the session to send/receive data to/from the user
 * @throws XMPPException if the user doesn't support or accept in-band bytestreams, or if the
 *         user prefers smaller block sizes
 */
public InBandBytestreamSession establishSession(String targetJID, String sessionID)
                throws XMPPException {
    Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize, this.stanza);
    byteStreamRequest.setTo(targetJID);

    // sending packet will throw exception on timeout or error reply
    SyncPacketSend.getReply(this.connection, byteStreamRequest);

    InBandBytestreamSession inBandBytestreamSession = new InBandBytestreamSession(
                    this.connection, byteStreamRequest, targetJID);
    this.sessions.put(sessionID, inBandBytestreamSession);

    return inBandBytestreamSession;
}
项目:java-bells    文件:OpenIQProvider.java   
public IQ parseIQ(XmlPullParser parser) throws Exception {
    String sessionID = parser.getAttributeValue("", "sid");
    int blockSize = Integer.parseInt(parser.getAttributeValue("", "block-size"));

    String stanzaValue = parser.getAttributeValue("", "stanza");
    StanzaType stanza = null;
    if (stanzaValue == null) {
        stanza = StanzaType.IQ;
    }
    else {
        stanza = StanzaType.valueOf(stanzaValue.toUpperCase());
    }

    return new Open(sessionID, blockSize, stanza);
}