Search in sources :

Example 1 with BytestreamListener

use of org.jivesoftware.smackx.bytestreams.BytestreamListener in project Smack by igniterealtime.

the class InitiationListener method processRequest.

private void processRequest(Stanza packet) throws NotConnectedException, InterruptedException {
    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().toString() + '\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);
    }
}
Also used : BytestreamListener(org.jivesoftware.smackx.bytestreams.BytestreamListener) Open(org.jivesoftware.smackx.bytestreams.ibb.packet.Open)

Example 2 with BytestreamListener

use of org.jivesoftware.smackx.bytestreams.BytestreamListener in project Smack by igniterealtime.

the class InitiationListener method processRequest.

private void processRequest(Stanza packet) throws NotConnectedException, InterruptedException {
    Bytestream byteStreamRequest = (Bytestream) packet;
    StreamNegotiator.signal(byteStreamRequest.getFrom().toString() + '\t' + byteStreamRequest.getSessionID(), byteStreamRequest);
    // ignore request if in ignore list
    if (this.manager.getIgnoredBytestreamRequests().remove(byteStreamRequest.getSessionID())) {
        return;
    }
    // build bytestream request from packet
    Socks5BytestreamRequest request = new Socks5BytestreamRequest(this.manager, byteStreamRequest);
    // notify listeners for bytestream initiation from a specific user
    BytestreamListener userListener = this.manager.getUserListener(byteStreamRequest.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(byteStreamRequest);
    }
}
Also used : Bytestream(org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream) BytestreamListener(org.jivesoftware.smackx.bytestreams.BytestreamListener)

Aggregations

BytestreamListener (org.jivesoftware.smackx.bytestreams.BytestreamListener)2 Open (org.jivesoftware.smackx.bytestreams.ibb.packet.Open)1 Bytestream (org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream)1