Examples of UnexpectedRequest


Examples of rocks.xmpp.core.stanza.model.errors.UnexpectedRequest

                        if (ibbSession != null) {
                            if (ibbSession.dataReceived(data)) {
                                xmppSession.send(iq.createResult());
                            } else {
                                // 2. Because the sequence number has already been used, the recipient returns an <unexpected-request/> error with a type of 'cancel'.
                                xmppSession.send(iq.createError(new StanzaError(StanzaError.Type.CANCEL, new UnexpectedRequest())));
                            }
                        }
                        e.consume();
                    } else {
                        InBandByteStream.Open open = iq.getExtension(InBandByteStream.Open.class);
                        if (open != null) {
                            if (open.getBlockSize() > 65535) {
                                xmppSession.send(iq.createError(new StanzaError(StanzaError.Type.MODIFY, new ResourceConstraint())));
                            } else {
                                // Somebody wants to create a IBB session with me.
                                // Notify the listeners.
                                notifyByteStreamEvent(new IbbEvent(InBandByteStreamManager.this, open.getSessionId(), xmppSession, iq, open.getBlockSize()));
                            }
                            e.consume();
                        } else {
                            InBandByteStream.Close close = iq.getExtension(InBandByteStream.Close.class);
                            // The session got closed.
                            if (close != null) {
                                IbbSession ibbSession = getIbbSession(iq, close.getSessionId());
                                if (ibbSession != null) {
                                    try {
                                        ibbSessionMap.remove(close.getSessionId());
                                        ibbSession.closedByPeer();
                                    } catch (IOException e1) {
                                        logger.log(Level.WARNING, e1.getMessage(), e1);
                                    } finally {
                                        xmppSession.send(iq.createResult());
                                    }
                                }
                                e.consume();
                            }
                        }
                    }
                }
            }
        });

        // 4. Use of Message Stanzas
        // an application MAY use message stanzas instead.
        xmppSession.addMessageListener(new MessageListener() {
            @Override
            public void handle(MessageEvent e) {
                if (e.isIncoming() && isEnabled()) {
                    InBandByteStream.Data data = e.getMessage().getExtension(InBandByteStream.Data.class);
                    if (data != null) {
                        IbbSession ibbSession = ibbSessionMap.get(data.getSessionId());
                        if (ibbSession != null) {
                            if (!ibbSession.dataReceived(data)) {
                                // 2. Because the sequence number has already been used, the recipient returns an <unexpected-request/> error with a type of 'cancel'.
                                xmppSession.send(e.getMessage().createError(new StanzaError(StanzaError.Type.CANCEL, new UnexpectedRequest())));
                            }
                        } else {
                            xmppSession.send(e.getMessage().createError(new StanzaError(new ItemNotFound())));
                        }
                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.