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

项目:Smack    文件:InBandBytestreamSession.java   
/**
 * This method is invoked if a request to close the In-Band Bytestream has been received.
 * 
 * @param closeRequest the close request from the remote peer
 * @throws NotConnectedException 
 */
protected void closeByPeer(Close closeRequest) throws NotConnectedException {

    /*
     * close streams without flushing them, because stream is already considered closed on the
     * remote peers side
     */
    this.inputStream.closeInternal();
    this.inputStream.cleanup();
    this.outputStream.closeInternal(false);

    // acknowledge close request
    IQ confirmClose = IQ.createResultIQ(closeRequest);
    this.connection.sendStanza(confirmClose);

}
项目:EIM    文件:InBandBytestreamSession.java   
/**
 * This method is invoked if a request to close the In-Band Bytestream has been received.
 * 
 * @param closeRequest the close request from the remote peer
 */
protected void closeByPeer(Close closeRequest) {

    /*
     * close streams without flushing them, because stream is already considered closed on the
     * remote peers side
     */
    this.inputStream.closeInternal();
    this.inputStream.cleanup();
    this.outputStream.closeInternal(false);

    // acknowledge close request
    IQ confirmClose = IQ.createResultIQ(closeRequest);
    this.connection.sendPacket(confirmClose);

}
项目:androidPN-client.    文件:InBandBytestreamSession.java   
/**
 * This method is invoked if a request to close the In-Band Bytestream has been received.
 * 
 * @param closeRequest the close request from the remote peer
 */
protected void closeByPeer(Close closeRequest) {

    /*
     * close streams without flushing them, because stream is already considered closed on the
     * remote peers side
     */
    this.inputStream.closeInternal();
    this.inputStream.cleanup();
    this.outputStream.closeInternal(false);

    // acknowledge close request
    IQ confirmClose = IQ.createResultIQ(closeRequest);
    this.connection.sendPacket(confirmClose);

}
项目:xmppsupport_v2    文件:InBandBytestreamSession.java   
/**
 * This method is invoked if a request to close the In-Band Bytestream has
 * been received.
 * 
 * @param closeRequest
 *            the close request from the remote peer
 */
protected void closeByPeer(Close closeRequest) {

    /*
     * close streams without flushing them, because stream is already
     * considered closed on the remote peers side
     */
    this.inputStream.closeInternal();
    this.inputStream.cleanup();
    this.outputStream.closeInternal(false);

    // acknowledge close request
    IQ confirmClose = IQ.createResultIQ(closeRequest);
    this.connection.sendPacket(confirmClose);

}
项目:java-bells    文件:InBandBytestreamSession.java   
/**
 * This method is invoked if a request to close the In-Band Bytestream has been received.
 * 
 * @param closeRequest the close request from the remote peer
 */
protected void closeByPeer(Close closeRequest) {

    /*
     * close streams without flushing them, because stream is already considered closed on the
     * remote peers side
     */
    this.inputStream.closeInternal();
    this.inputStream.cleanup();
    this.outputStream.closeInternal(false);

    // acknowledge close request
    IQ confirmClose = IQ.createResultIQ(closeRequest);
    this.connection.sendPacket(confirmClose);

}
项目:telegraph    文件:InBandBytestreamSession.java   
/**
 * This method is invoked if a request to close the In-Band Bytestream has been received.
 * 
 * @param closeRequest the close request from the remote peer
 */
protected void closeByPeer(Close closeRequest) {

    /*
     * close streams without flushing them, because stream is already considered closed on the
     * remote peers side
     */
    this.inputStream.closeInternal();
    this.inputStream.cleanup();
    this.outputStream.closeInternal(false);

    // acknowledge close request
    IQ confirmClose = IQ.createResultIQ(closeRequest);
    this.connection.sendPacket(confirmClose);

}
项目:Smack    文件:CloseListenerTest.java   
/**
 * If a close request to an unknown session is received it should be replied
 * with an <item-not-found/> error.
 * 
 * @throws Exception should not happen
 */
@Test
public void shouldReplyErrorIfSessionIsUnknown() throws Exception {

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

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

    // get the CloseListener from InBandByteStreamManager
    CloseListener closeListener = Whitebox.getInternalState(byteStreamManager,
                    CloseListener.class);

    Close close = new Close("unknownSessionId");
    close.setFrom(initiatorJID);
    close.setTo(targetJID);

    closeListener.handleIQRequest(close);

    // wait because packet is processed in an extra thread
    Thread.sleep(200);

    // capture reply to the In-Band Bytestream close request
    ArgumentCaptor<IQ> argument = ArgumentCaptor.forClass(IQ.class);
    verify(connection).sendStanza(argument.capture());

    // assert that reply is the correct error packet
    assertEquals(initiatorJID, argument.getValue().getTo());
    assertEquals(IQ.Type.error, argument.getValue().getType());
    assertEquals(XMPPError.Condition.item_not_found,
                    argument.getValue().getError().getCondition());

}
项目:EIM    文件:CloseListener.java   
public void processPacket(Packet packet) {
    Close closeRequest = (Close) packet;
    InBandBytestreamSession ibbSession = this.manager.getSessions().get(
                    closeRequest.getSessionID());
    if (ibbSession == null) {
        this.manager.replyItemNotFoundPacket(closeRequest);
    }
    else {
        ibbSession.closeByPeer(closeRequest);
        this.manager.getSessions().remove(closeRequest.getSessionID());
    }

}
项目:EIM    文件:InBandBytestreamSession.java   
/**
 * This method is invoked if one of the streams has been closed locally, if an error occurred
 * locally or if the whole session should be closed.
 * 
 * @throws IOException if an error occurs while sending the close request
 */
protected synchronized void closeByLocal(boolean in) throws IOException {
    if (this.isClosed) {
        return;
    }

    if (this.closeBothStreamsEnabled) {
        this.inputStream.closeInternal();
        this.outputStream.closeInternal(true);
    }
    else {
        if (in) {
            this.inputStream.closeInternal();
        }
        else {
            // close stream but try to send any data left
            this.outputStream.closeInternal(true);
        }
    }

    if (this.inputStream.isClosed && this.outputStream.isClosed) {
        this.isClosed = true;

        // send close request
        Close close = new Close(this.byteStreamRequest.getSessionID());
        close.setTo(this.remoteJID);
        try {
            SyncPacketSend.getReply(this.connection, close);
        }
        catch (XMPPException e) {
            throw new IOException("Error while closing stream: " + e.getMessage());
        }

        this.inputStream.cleanup();

        // remove session from manager
        InBandBytestreamManager.getByteStreamManager(this.connection).getSessions().remove(this);
    }

}
项目:androidPN-client.    文件:CloseListener.java   
public void processPacket(Packet packet) {
    Close closeRequest = (Close) packet;
    InBandBytestreamSession ibbSession = this.manager.getSessions().get(
                    closeRequest.getSessionID());
    if (ibbSession == null) {
        this.manager.replyItemNotFoundPacket(closeRequest);
    }
    else {
        ibbSession.closeByPeer(closeRequest);
        this.manager.getSessions().remove(closeRequest.getSessionID());
    }

}
项目:androidPN-client.    文件:InBandBytestreamSession.java   
/**
 * This method is invoked if one of the streams has been closed locally, if an error occurred
 * locally or if the whole session should be closed.
 * 
 * @throws IOException if an error occurs while sending the close request
 */
protected synchronized void closeByLocal(boolean in) throws IOException {
    if (this.isClosed) {
        return;
    }

    if (this.closeBothStreamsEnabled) {
        this.inputStream.closeInternal();
        this.outputStream.closeInternal(true);
    }
    else {
        if (in) {
            this.inputStream.closeInternal();
        }
        else {
            // close stream but try to send any data left
            this.outputStream.closeInternal(true);
        }
    }

    if (this.inputStream.isClosed && this.outputStream.isClosed) {
        this.isClosed = true;

        // send close request
        Close close = new Close(this.byteStreamRequest.getSessionID());
        close.setTo(this.remoteJID);
        try {
            SyncPacketSend.getReply(this.connection, close);
        }
        catch (XMPPException e) {
            throw new IOException("Error while closing stream: " + e.getMessage());
        }

        this.inputStream.cleanup();

        // remove session from manager
        InBandBytestreamManager.getByteStreamManager(this.connection).getSessions().remove(this);
    }

}
项目:xmppsupport_v2    文件:CloseListener.java   
public void processPacket(Packet packet) {
    Close closeRequest = (Close) packet;
    InBandBytestreamSession ibbSession = this.manager.getSessions().get(
            closeRequest.getSessionID());
    if (ibbSession == null) {
        this.manager.replyItemNotFoundPacket(closeRequest);
    } else {
        ibbSession.closeByPeer(closeRequest);
        this.manager.getSessions().remove(closeRequest.getSessionID());
    }

}
项目:xmppsupport_v2    文件:InBandBytestreamSession.java   
/**
 * This method is invoked if one of the streams has been closed locally, if
 * an error occurred locally or if the whole session should be closed.
 * 
 * @throws IOException
 *             if an error occurs while sending the close request
 */
protected synchronized void closeByLocal(boolean in) throws IOException {
    if (this.isClosed) {
        return;
    }

    if (this.closeBothStreamsEnabled) {
        this.inputStream.closeInternal();
        this.outputStream.closeInternal(true);
    } else {
        if (in) {
            this.inputStream.closeInternal();
        } else {
            // close stream but try to send any data left
            this.outputStream.closeInternal(true);
        }
    }

    if (this.inputStream.isClosed && this.outputStream.isClosed) {
        this.isClosed = true;

        // send close request
        Close close = new Close(this.byteStreamRequest.getSessionID());
        close.setTo(this.remoteJID);
        try {
            SyncPacketSend.getReply(this.connection, close);
        } catch (XMPPException e) {
            throw new IOException("Error while closing stream: "
                    + e.getMessage());
        }

        this.inputStream.cleanup();

        // remove session from manager
        InBandBytestreamManager.getByteStreamManager(this.connection)
                .getSessions().remove(this);
    }

}
项目:java-bells    文件:CloseListener.java   
public void processPacket(Packet packet) {
    Close closeRequest = (Close) packet;
    InBandBytestreamSession ibbSession = this.manager.getSessions().get(
                    closeRequest.getSessionID());
    if (ibbSession == null) {
        this.manager.replyItemNotFoundPacket(closeRequest);
    }
    else {
        ibbSession.closeByPeer(closeRequest);
        this.manager.getSessions().remove(closeRequest.getSessionID());
    }

}
项目:java-bells    文件:InBandBytestreamSession.java   
/**
 * This method is invoked if one of the streams has been closed locally, if an error occurred
 * locally or if the whole session should be closed.
 * 
 * @throws IOException if an error occurs while sending the close request
 */
protected synchronized void closeByLocal(boolean in) throws IOException {
    if (this.isClosed) {
        return;
    }

    if (this.closeBothStreamsEnabled) {
        this.inputStream.closeInternal();
        this.outputStream.closeInternal(true);
    }
    else {
        if (in) {
            this.inputStream.closeInternal();
        }
        else {
            // close stream but try to send any data left
            this.outputStream.closeInternal(true);
        }
    }

    if (this.inputStream.isClosed && this.outputStream.isClosed) {
        this.isClosed = true;

        // send close request
        Close close = new Close(this.byteStreamRequest.getSessionID());
        close.setTo(this.remoteJID);
        try {
            SyncPacketSend.getReply(this.connection, close);
        }
        catch (XMPPException e) {
            throw new IOException("Error while closing stream: " + e.getMessage());
        }

        this.inputStream.cleanup();

        // remove session from manager
        InBandBytestreamManager.getByteStreamManager(this.connection).getSessions().remove(this);
    }

}
项目:telegraph    文件:CloseListener.java   
public void processPacket(Packet packet) {
    Close closeRequest = (Close) packet;
    InBandBytestreamSession ibbSession = this.manager.getSessions().get(
                    closeRequest.getSessionID());
    if (ibbSession == null) {
        this.manager.replyItemNotFoundPacket(closeRequest);
    }
    else {
        ibbSession.closeByPeer(closeRequest);
        this.manager.getSessions().remove(closeRequest.getSessionID());
    }

}
项目:telegraph    文件:InBandBytestreamSession.java   
/**
 * This method is invoked if one of the streams has been closed locally, if an error occurred
 * locally or if the whole session should be closed.
 * 
 * @throws IOException if an error occurs while sending the close request
 */
protected synchronized void closeByLocal(boolean in) throws IOException {
    if (this.isClosed) {
        return;
    }

    if (this.closeBothStreamsEnabled) {
        this.inputStream.closeInternal();
        this.outputStream.closeInternal(true);
    }
    else {
        if (in) {
            this.inputStream.closeInternal();
        }
        else {
            // close stream but try to send any data left
            this.outputStream.closeInternal(true);
        }
    }

    if (this.inputStream.isClosed && this.outputStream.isClosed) {
        this.isClosed = true;

        // send close request
        Close close = new Close(this.byteStreamRequest.getSessionID());
        close.setTo(this.remoteJID);
        try {
            SyncPacketSend.getReply(this.connection, close);
        }
        catch (XMPPException e) {
            throw new IOException("Error while closing stream: " + e.getMessage());
        }

        this.inputStream.cleanup();

        // remove session from manager
        InBandBytestreamManager.getByteStreamManager(this.connection).getSessions().remove(this);
    }

}
项目:Smack    文件:CloseIQProvider.java   
@Override
public Close parse(XmlPullParser parser, int initialDepth) {
    String sid = parser.getAttributeValue("", "sid");
    return new Close(sid);
}
项目:Smack    文件:InBandBytestreamSession.java   
/**
 * This method is invoked if one of the streams has been closed locally, if an error occurred
 * locally or if the whole session should be closed.
 * 
 * @throws IOException if an error occurs while sending the close request
 */
protected synchronized void closeByLocal(boolean in) throws IOException {
    if (this.isClosed) {
        return;
    }

    if (this.closeBothStreamsEnabled) {
        this.inputStream.closeInternal();
        this.outputStream.closeInternal(true);
    }
    else {
        if (in) {
            this.inputStream.closeInternal();
        }
        else {
            // close stream but try to send any data left
            this.outputStream.closeInternal(true);
        }
    }

    if (this.inputStream.isClosed && this.outputStream.isClosed) {
        this.isClosed = true;

        // send close request
        Close close = new Close(this.byteStreamRequest.getSessionID());
        close.setTo(this.remoteJID);
        try {
            connection.createPacketCollectorAndSend(close).nextResultOrThrow();
        }
        catch (Exception e) {
            // Sadly we are unable to use the IOException(Throwable) constructor because this
            // constructor is only supported from Android API 9 on.
            IOException ioException = new IOException();
            ioException.initCause(e);
            throw ioException;
        }

        this.inputStream.cleanup();

        // remove session from manager
        InBandBytestreamManager.getByteStreamManager(this.connection).getSessions().remove(this);
    }

}
项目:EIM    文件:CloseIQProvider.java   
public IQ parseIQ(XmlPullParser parser) throws Exception {
    String sid = parser.getAttributeValue("", "sid");
    return new Close(sid);
}
项目:androidPN-client.    文件:CloseIQProvider.java   
public IQ parseIQ(XmlPullParser parser) throws Exception {
    String sid = parser.getAttributeValue("", "sid");
    return new Close(sid);
}
项目:xmppsupport_v2    文件:CloseIQProvider.java   
public IQ parseIQ(XmlPullParser parser) throws Exception {
    String sid = parser.getAttributeValue("", "sid");
    return new Close(sid);
}
项目:java-bells    文件:CloseIQProvider.java   
public IQ parseIQ(XmlPullParser parser) throws Exception {
    String sid = parser.getAttributeValue("", "sid");
    return new Close(sid);
}
项目:telegraph    文件:CloseIQProvider.java   
public IQ parseIQ(XmlPullParser parser) throws Exception {
    String sid = parser.getAttributeValue("", "sid");
    return new Close(sid);
}
项目:Smack    文件:CloseListener.java   
/**
 * Constructor.
 * 
 * @param manager the In-Band Bytestream manager
 */
protected CloseListener(InBandBytestreamManager manager) {
    super(Close.ELEMENT, Close.NAMESPACE, IQ.Type.set, Mode.async);
    this.manager = manager;
}