Package com.github.ghetolay.jwamp.message.output

Examples of com.github.ghetolay.jwamp.message.output.OutputWampPublishMessage


  private void publish(String topicId, Object event, boolean excludeMe, List<String> exclude, List<String> eligible) throws IOException, SerializationException{

    if(!topics.contains(topicId))
      subscribe(topicId);

    OutputWampPublishMessage msg = new OutputWampPublishMessage();
    msg.setTopicId(topicId);
    msg.setEvent(event);

    if(excludeMe)
      msg.setExcludeMe(true);
    else if(exclude != null || eligible != null){
      msg.setExclude(exclude != null ? exclude : new ArrayList<String>());
      msg.setEligible(eligible != null ? exclude : new ArrayList<String>());
    }

    conn.sendMessage(msg);
  }
View Full Code Here


  WampSerializer serializer = new WampSerializer();
 
  //Tests are from wamp specification
  @Test
  public void serialize1() throws SerializationException{
    OutputWampPublishMessage msg = new OutputWampPublishMessage();
    msg.setTopicId("http://example.com/simple");
    msg.setEvent("Hello, world!");
   
    assertEquals("[7,\"http://example.com/simple\",\"Hello, world!\"]",
        WampMessageSerializer.serialize(msg, serializer.getObjectMapper()));
  }
View Full Code Here

 
  //in the example event is null
  //does empty event is permit instead ?
  @Test
  public void serialize2() throws SerializationException{
    OutputWampPublishMessage msg = new OutputWampPublishMessage();
    msg.setTopicId("http://example.com/simple");
   
    assertEquals("[7,\"http://example.com/simple\"]",
        WampMessageSerializer.serialize(msg, serializer.getObjectMapper()));
  }
View Full Code Here

  public void serialize3() throws SerializationException{
   
    //it's set to NON_DEFAULT in WampSerialize to reducing data size. Maybe it shouldn"t
    serializer.getObjectMapper().getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.ALWAYS);
   
    OutputWampPublishMessage msg = new OutputWampPublishMessage();
    msg.setTopicId("http://example.com/event#myevent2");
   
    SomeObject obj = new SomeObject();
    obj.setRand(0.09187032734575862);
    obj.setFlag(false);
    obj.setNum(23);
    obj.setName("Kross");
   
    Calendar cal = Calendar.getInstance();
    //Seriously month 0-based !!! ?
    cal.set(2012, 2, 29, 10, 41, 9);
    cal.set(Calendar.MILLISECOND, 864);

    obj.setCreated(cal.getTime());
   
    msg.setEvent(obj);
   
    assertEquals("[7,\"http://example.com/event#myevent2\","
            "{"
                    +    "\"rand\":0.09187032734575862,"
                    +    "\"flag\":false,"
View Full Code Here

    assertEquals(JsonDateSerializer.format.parse((String)evtObject.get("created")), cal.getTime());
  }
 
  @Test
  public void serialize4() throws SerializationException{
    OutputWampPublishMessage msg = new OutputWampPublishMessage();
    msg.setTopicId("event:myevent1");
    msg.setEvent("hello");
    msg.setExclude( Arrays.asList("NwtXQ8rdfPsy-ewS","dYqgDl0FthI6_hjb") );
   
    assertEquals("[7,\"event:myevent1\","
            + "\"hello\","
            + "[\"NwtXQ8rdfPsy-ewS\",\"dYqgDl0FthI6_hjb\"]]",
        WampMessageSerializer.serialize(msg, serializer.getObjectMapper()));
View Full Code Here

    assertEquals("dYqgDl0FthI6_hjb", excludeList.get(1));
  }
 
  @Test
  public void serialize5() throws SerializationException{
    OutputWampPublishMessage msg = new OutputWampPublishMessage();
    msg.setTopicId("event:myevent1");
    msg.setEvent("hello");
   
    msg.setEligible(Arrays.asList("NwtXQ8rdfPsy-ewS"));
   
    assertEquals("[7,\"event:myevent1\","
            + "\"hello\","
            + "[],"
            + "[\"NwtXQ8rdfPsy-ewS\"]]",
View Full Code Here

TOP

Related Classes of com.github.ghetolay.jwamp.message.output.OutputWampPublishMessage

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.