Examples of Jingle


Examples of rocks.xmpp.extensions.jingle.model.Jingle

                "    </content>\n" +
                "  </jingle>\n" +
                "</iq>\n";

        IQ iq = unmarshal(xml, IQ.class);
        Jingle jingle = iq.getExtension(Jingle.class);
        Assert.assertNotNull(jingle);
        Assert.assertEquals(jingle.getAction(), Jingle.Action.SESSION_ACCEPT);
        Assert.assertEquals(jingle.getResponder(), Jid.valueOf("juliet@capulet.lit/balcony"));
        Assert.assertEquals(jingle.getSessionId(), "a73sjjvkla37jfea");
    }
View Full Code Here

Examples of rocks.xmpp.extensions.jingle.model.Jingle

                "    </reason>\n" +
                "  </jingle>\n" +
                "</iq>\n";

        IQ iq = unmarshal(xml, IQ.class);
        Jingle jingle = iq.getExtension(Jingle.class);
        Assert.assertNotNull(jingle);
        Assert.assertEquals(jingle.getAction(), Jingle.Action.SESSION_TERMINATE);
        Assert.assertNotNull(jingle.getReason());
        Assert.assertNotNull(jingle.getReason().getType() instanceof Jingle.Reason.Success);
        Assert.assertEquals(jingle.getReason().getText(), "Sorry, gotta go!");
        Assert.assertEquals(jingle.getSessionId(), "a73sjjvkla37jfea");
    }
View Full Code Here

Examples of rocks.xmpp.extensions.jingle.model.Jingle

                "    </content>\n" +
                "  </jingle>\n" +
                "</iq>\n";

        IQ iq = unmarshal(xml, IQ.class);
        Jingle jingle = iq.getExtension(Jingle.class);
        Assert.assertNotNull(jingle);
        Assert.assertEquals(jingle.getAction(), Jingle.Action.SESSION_INITIATE);
        Assert.assertEquals(jingle.getSessionId(), "a73sjjvkla37jfea");
        Assert.assertEquals(jingle.getContents().size(), 1);
        Assert.assertEquals(jingle.getContents().get(0).getCreator(), Jingle.Content.Creator.INITIATOR);
        Assert.assertEquals(jingle.getContents().get(0).getName(), "voice");
        Assert.assertTrue(jingle.getContents().get(0).getApplicationFormat() instanceof Rtp);
        Assert.assertTrue(jingle.getContents().get(0).getTransportMethod() instanceof IceUdpTransportMethod);
    }
View Full Code Here

Examples of rocks.xmpp.extensions.jingle.model.Jingle

        Assert.assertTrue(jingle.getContents().get(0).getTransportMethod() instanceof IceUdpTransportMethod);
    }

    @Test
    public void marshalJingleSessionTerminate() throws XMLStreamException, JAXBException {
        Jingle jingle = new Jingle("a73sjjvkla37jfea", Jingle.Action.SESSION_TERMINATE, new Jingle.Reason(new Jingle.Reason.Decline()));
        String xml = marshal(jingle);
        Assert.assertEquals(xml, "<jingle xmlns=\"urn:xmpp:jingle:1\" action=\"session-terminate\" sid=\"a73sjjvkla37jfea\"><reason><decline></decline></reason></jingle>");
    }
View Full Code Here

Examples of rocks.xmpp.extensions.jingle.model.Jingle

                "    <ringing xmlns='urn:xmpp:jingle:apps:rtp:info:1'/>\n" +
                "  </jingle>\n" +
                "</iq>\n";

        IQ iq = unmarshal(xml, IQ.class);
        Jingle jingle = iq.getExtension(Jingle.class);
        Assert.assertNotNull(jingle);
        Assert.assertNotNull(jingle.getPayload());
        Assert.assertTrue(jingle.getPayload() instanceof Ringing);
    }
View Full Code Here

Examples of rocks.xmpp.extensions.jingle.model.Jingle

                "        <hash xmlns='urn:xmpp:hashes:1' algo='sha-1'>552da749930852c69ae5d2141d3766b1</hash>\n" +
                "      </file>\n" +
                "    </checksum>\n" +
                "  </jingle>\n";

        Jingle jingle = unmarshal(xml, Jingle.class);
        Assert.assertTrue(jingle.getPayload() instanceof JingleFileTransfer.Checksum);
        Assert.assertEquals(((JingleFileTransfer.Checksum) jingle.getPayload()).getFile().getHashes().size(), 1);
    }
View Full Code Here

Examples of rocks.xmpp.extensions.jingle.model.Jingle

        xmppSession.addIQListener(new IQListener() {
            @Override
            public void handle(IQEvent e) {
                IQ iq = e.getIQ();
                if (e.isIncoming() && isEnabled() && !e.isConsumed() && iq.getType() == IQ.Type.SET) {
                    Jingle jingle = iq.getExtension(Jingle.class);
                    if (jingle != null) {

                        // The value of the 'action' attribute MUST be one of the following.
                        // If an entity receives a value not defined here, it MUST ignore the attribute and MUST return a <bad-request/> error to the sender.
                        // There is no default value for the 'action' attribute.
                        if (jingle.getAction() == null) {
                            xmppSession.send(iq.createError(new StanzaError(new BadRequest(), "No valid action attribute set.")));
                        } else if (jingle.getSessionId() == null) {
                            xmppSession.send(iq.createError(new StanzaError(new BadRequest(), "No session id set.")));
                        } else if (jingle.getAction() == Jingle.Action.SESSION_INITIATE) {

                            // Check if the Jingle request is not mal-formed, otherwise return a bad-request error.
                            // See 6.3.2 Errors
                            if (jingle.getContents().isEmpty()) {
                                xmppSession.send(iq.createError(new StanzaError(new BadRequest(), "No contents found.")));
                            } else {
                                boolean hasContentWithDispositionSession = false;
                                boolean hasSupportedApplications = false;
                                boolean hasSupportedTransports = false;
                                // Check if we support the application format and transport method and at least one content element has a disposition of "session".
                                for (Jingle.Content content : jingle.getContents()) {
                                    // Check if the content disposition is "session" (default value is "session").
                                    if (!hasContentWithDispositionSession && ("session".equals(content.getDisposition()) || content.getDisposition() == null)) {
                                        hasContentWithDispositionSession = true;
                                    }

                                    if (!hasSupportedApplications && content.getApplicationFormat() != null) {
                                        hasSupportedApplications = true;
                                    }

                                    if (!hasSupportedTransports && content.getTransportMethod() != null) {
                                        hasSupportedTransports = true;
                                    }
                                }

                                if (!hasContentWithDispositionSession) {
                                    // When sending a session-initiate with one <content/> element,
                                    // the value of the <content/> element's 'disposition' attribute MUST be "session"
                                    // (if there are multiple <content/> elements then at least one MUST have a disposition of "session");
                                    // if this rule is violated, the responder MUST return a <bad-request/> error to the initiator.
                                    xmppSession.send(iq.createError(new StanzaError(new BadRequest(), "No content with disposition 'session' found.")));
                                } else {
                                    // If the request was ok, immediately acknowledge the initiation request.
                                    // See 6.3.1 Acknowledgement
                                    xmppSession.send(iq.createResult());

                                    // However, after acknowledging the session initiation request,
                                    // the responder might subsequently determine that it cannot proceed with negotiation of the session
                                    // (e.g., because it does not support any of the offered application formats or transport methods,
                                    // because a human user is busy or unable to accept the session, because a human user wishes to formally decline
                                    // the session, etc.). In these cases, the responder SHOULD immediately acknowledge the session initiation request
                                    // but then terminate the session with an appropriate reason as described in the Termination section of this document.

                                    if (!hasSupportedApplications) {
                                        // Terminate the session with <unsupported-applications/>.
                                        xmppSession.send(new IQ(iq.getFrom(), IQ.Type.SET, new Jingle(jingle.getSessionId(), Jingle.Action.SESSION_TERMINATE, new Jingle.Reason(new Jingle.Reason.UnsupportedApplications()))));
                                    } else if (!hasSupportedTransports) {
                                        // Terminate the session with <unsupported-transports/>.
                                        xmppSession.send(new IQ(iq.getFrom(), IQ.Type.SET, new Jingle(jingle.getSessionId(), Jingle.Action.SESSION_TERMINATE, new Jingle.Reason(new Jingle.Reason.UnsupportedTransports()))));
                                    } else {
                                        // Everything is fine, create the session and notify the listeners.
                                        JingleSession jingleSession = new JingleSession(jingle.getSessionId(), iq.getFrom(), false, xmppSession, JingleManager.this, jingle.getContents());
                                        jingleSessionMap.put(jingle.getSessionId(), jingleSession);
                                        notifyJingleListeners(new JingleEvent(JingleManager.this, xmppSession, iq, jingle));
                                    }
                                }
                            }
                        } else {

                            // Another action (!= session-initiate) has been sent.
                            // Check if we know the session.
                            JingleSession jingleSession = jingleSessionMap.get(jingle.getSessionId());

                            if (jingleSession == null) {
                                // If we receive a non-session-initiate Jingle action with an unknown session id,
                                // return <item-not-found/> and <unknown-session/>
                                StanzaError stanzaError = new StanzaError(new ItemNotFound());
View Full Code Here

Examples of rocks.xmpp.extensions.jingle.model.Jingle

        }
        // As soon as an entity sends a session-terminate action, it MUST consider the session to be in the ENDED state
        // (even before receiving acknowledgement from the other party).
        state = State.ENDED;
        try {
            xmppSession.query(new IQ(peer, IQ.Type.SET, new Jingle(sessionId, Jingle.Action.SESSION_TERMINATE, reason)));
        } finally {
            jingleManager.removeSession(sessionId);
        }
    }
View Full Code Here

Examples of rocks.xmpp.extensions.jingle.model.Jingle

     */
    public void sendSessionInfo(Object object) throws XmppException {
        if (state == State.INITIAL) {
            throw new IllegalStateException("The session has not yet been initialized.");
        }
        xmppSession.query(new IQ(peer, IQ.Type.SET, new Jingle(sessionId, Jingle.Action.SESSION_INFO, object)));
    }
View Full Code Here

Examples of rocks.xmpp.extensions.jingle.model.Jingle

    /**
     * Rejects the Jingle session.
     */
    public void reject() {
        // Another reason for terminating the session is that the terminating party wishes to formally decline the session; in this case, the recommended condition is <decline/>.
        xmppSession.send(new IQ(iq.getFrom(), IQ.Type.SET, new Jingle(sessionId, Jingle.Action.SESSION_TERMINATE, new Jingle.Reason(new Jingle.Reason.Decline()))));
    }
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.