Package org.xmpp.packet

Examples of org.xmpp.packet.Message


    final Element entryElement = (Element) domDocument.appendChild(domDocument.createElementNS(Onesocialweb.NAMESPACE, Onesocialweb.RELATION_ELEMENT));
    final RelationDomWriter writer = new DefaultRelationDomWriter();
    writer.write(relation, entryElement);
    domDocument.removeChild(entryElement);

    final Message message = new Message();
    message.setFrom(localJID);
    message.setType(Message.Type.headline);
    org.dom4j.Element eventElement = message.addChildElement("event", "http://jabber.org/protocol/pubsub#event");
    org.dom4j.Element itemsElement = eventElement.addElement("items");
    itemsElement.addAttribute("node", NODE);
    org.dom4j.Element itemElement = itemsElement.addElement("item");
    itemElement.addAttribute("id", relation.getId());
    itemElement.add((org.dom4j.Element) entryElement);

    // Send to this user
    message.setTo(getOtherEnd(relation, localJID));
    server.getMessageRouter().route(message);
  }
View Full Code Here


    final AtomicInteger callbackCount = new AtomicInteger(1);
    final Runnable countDown = new Runnable() {
      @Override
      public void run() {
        if (callbackCount.decrementAndGet() == 0 && receiptRequested != null) {
          Message response = XmppUtil.createResponseMessage(updateMessage);
          response.addChildElement("received", XmppNamespace.NAMESPACE_XMPP_RECEIPTS);
          responseCallback.run(response);
        }
      }
    };
View Full Code Here

            challengeExt.setPacketId(packet.getID());
        }
        challengeExt.setQAChallenge(question);
       
       
        Message challengeMessage = new Message();
        challengeMessage.setTo(packet.getFrom());
        challengeMessage.setFrom(packet.getTo());
        challengeMessage.addExtension(challengeExt);
       
        challengeExt.addLegacyChallenge(challengeMessage);
       
        // add the challenge to the challenge map
        ChallengeData challengeData = new ChallengeData(challengeId, packet.getTo().toBareJID(), packet.getFrom().toBareJID() );
View Full Code Here

                        route(packetToSend);
                    }
                   
                    challengeManager.clearPackets(challengeId);
                   
                    Message successMessage = new Message();
                    successMessage.setTo( packet.getFrom() );
                    successMessage.setFrom( packet.getTo() );
                    successMessage.setBody( "Anti-Spim Device: Thank you. Your messages have been forwarded.");
                    route(successMessage);
                   
                    throw new PacketRejectedException("Robot Olympics: Passed challenge; discarding.");
                } else {
                    Message failureMessage = new Message();
                    failureMessage.setTo( packet.getFrom() );
                    failureMessage.setFrom( packet.getTo() );

                    PacketError error = new PacketError(PacketError.Condition.not_acceptable,
                            PacketError.Type.cancel,
                            "Anti-Spim Device: Failed, but you can keep trying.");
                   
                    failureMessage.setError(error);
                   
                    route(failureMessage);
                }
            } else {
                Message failureMessage = new Message();
                failureMessage.setTo( packet.getFrom() );
                failureMessage.setFrom( packet.getTo() );
                failureMessage.setBody( "Anti-Spim Device: Please complete the robot challenge.");
                route(failureMessage);
               
                challengeManager.appendPacket(packet);
                throw new PacketRejectedException("Robot Olympics: Must meet challenge.");
            }
View Full Code Here

    protected void tearDown() throws Exception {
        super.tearDown();
    }

    public void testInnocentMessage() {
        Message message = new Message();
        message.setTo("a@soashable.com");
        message.setFrom("b@soashable.com");
        message.setBody("testing");
       
        //interceptor.interceptPacket(message, session, incoming, processed);
               
    }
View Full Code Here

        super.setUp();
       
        session = new MockSession();
        session.setServerName("test.com");
       
        message = new Message();
        message.setTo("harlan@soashable.com");
        message.setFrom("harlan@soashable.com");
        message.setBody("Hello, Friend");
        message.setID("message1");
       
View Full Code Here

    public void testRespondToChallengeCorrect() {
        Packet challenge = challengeManager.createChallenge(message, session);
       
        String correctResponse = challengeManager.getChallenge( message ).getCorrectResponses().get(0);
       
        Message challengeResponse = new Message();
        challengeResponse.setTo(message.getFrom());
        challengeResponse.setFrom(message.getTo());
        challengeResponse.setBody( StaticChallengeGenerator.CORRECT_RESPONSE + " " + challengeManager.makeChallengeId(message));
       
        boolean challengePassed = challengeManager.checkResponse(challengeResponse, session);
       
        assertTrue( "Challenge should have passed but didn't", challengePassed );
        assertTrue( "isChallgeMet did not return the correct answer",challengeManager.isChallengeMet(message) );
View Full Code Here

    public void testRespondToChallengeIncorrect() {
        Packet challenge = challengeManager.createChallenge(message, session);
       
        String incorrectResponse = "fdsfsdfdsf2354";
       
        Message challengeResponse = new Message();
        challengeResponse.setTo(message.getFrom());
        challengeResponse.setFrom(message.getTo());
        challengeResponse.setBody(incorrectResponse + " " + challengeManager.makeChallengeId(message));
       
        boolean challengePassed = challengeManager.checkResponse(challengeResponse, session);
       
        assertFalse( "Challenge should have passed but didn't", challengePassed );
        assertFalse( "isChallgeMet did not return the correct answer", challengeManager.isChallengeMet(message) );
View Full Code Here

        assertFalse( "Challenge should have passed but didn't", challengePassed );
        assertFalse( "isChallgeMet did not return the correct answer", challengeManager.isChallengeMet(message) );
    }
   
    public void testIsChallengeResponseTrue() {
        Message challengeResponse = new Message();
        challengeResponse.setTo(message.getFrom());
        challengeResponse.setFrom(message.getTo());
        challengeResponse.setBody(challengeManager.makeChallengeId(message));
       
        assertTrue( "Legit response was not identified as a response", challengeManager.isChallengeResponse(challengeResponse) );
    }
View Full Code Here

       
        assertTrue( "Legit response was not identified as a response", challengeManager.isChallengeResponse(challengeResponse) );
    }
   
    public void testIsChallengeResponseFalse() {
        Message challengeResponse = new Message();
        challengeResponse.setTo(message.getFrom());
        challengeResponse.setFrom(message.getTo());
        challengeResponse.setBody("fdsfs");
       
        assertFalse( "Non-response was identified as a response", challengeManager.isChallengeResponse(challengeResponse) );
    }
View Full Code Here

TOP

Related Classes of org.xmpp.packet.Message

Copyright © 2018 www.massapicom. 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.