Package marauroa.common.net

Examples of marauroa.common.net.Decoder$MessageParts


    Perception p=zone.getPerception(obj, Perception.SYNC);
    MessageS2CPerception msg=new MessageS2CPerception(null, p);
    Encoder enc=Encoder.get();
    byte[] data=enc.encode(msg);
   
    Decoder dec=Decoder.get();
    List<Message> msgs=dec.decode(null, data);
   
    /*
     * There should only be one message.
     */
    assertEquals(1, msgs.size());
   
    MessageS2CPerception recv=(MessageS2CPerception)msgs.get(0);
    assertTrue(recv.getModifiedAddedRPObjects().isEmpty());
    assertTrue(recv.getModifiedDeletedRPObjects().isEmpty());
    assertTrue(recv.getDeletedRPObjects().isEmpty());
   
    List<RPObject> added=recv.getAddedRPObjects();
    assertEquals(1, added.size());
   
    RPObject recreated=added.get(0);
    assertNotNull(recreated);
    recreatedZone.add(recreated);
   
    assertEquals(obj, recreated);
   
    /*
     * Let's move Zone to the next turn.
     */
    zone.nextTurn();
    recreatedZone.nextTurn();

    /*
     * Remove object from lhand.
     */
    RPSlot lhand = obj.getSlot("lhand");
    RPObject pocket=lhand.getFirst();
    RPObject removed=lhand.remove(pocket.getID());
   
    assertNotNull(removed);
    assertEquals(removed,pocket);
   
    zone.modify(obj);
   
    /*
     * Create the perception and serialize it.
     */
    p=zone.getPerception(obj, Perception.DELTA);
    msg=new MessageS2CPerception(null, p);
    data=enc.encode(msg);
   
    msgs=dec.decode(null, data);
   
    assertEquals("there should only be one message",1, msgs.size());
   
    recv=(MessageS2CPerception)msgs.get(0);
    assertTrue(recv.getAddedRPObjects().isEmpty());
View Full Code Here

TOP

Related Classes of marauroa.common.net.Decoder$MessageParts

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.