Package marauroa.common.net.message

Examples of marauroa.common.net.message.MessageC2SAction


     * Each time we send an action we are confirming server our presence, so we
     * reset the counter to avoid sending keep alive messages.
     */
    perceptionsCount = 0;

    MessageC2SAction msgAction = new MessageC2SAction(null, action);
    netMan.addMessage(msgAction);
  }
View Full Code Here


  public void sendMessageC2S() throws IOException {
    TCPNetworkClientManager clientNet = new TCPNetworkClientManager("localhost", PORT);

    RPAction action = new RPAction();
    action.put("test", "hello world");
    MessageC2SAction msg = new MessageC2SAction(null, action);

    clientNet.addMessage(msg);

    MessageC2SAction recv = (MessageC2SAction)netMan.getMessage();

    assertEquals(msg.getRPAction(), recv.getRPAction());
  }
View Full Code Here

  public void sendMessageS2C() throws IOException, InvalidVersionException {
    TCPNetworkClientManager clientNet=new TCPNetworkClientManager("localhost", PORT);

    RPAction action=new RPAction();
    action.put("test","hello world");
    MessageC2SAction msg=new MessageC2SAction(null, action);

    clientNet.addMessage(msg);

    MessageC2SAction recv=(MessageC2SAction)netMan.getMessage();

    assertEquals(msg.getRPAction(), recv.getRPAction());

    RPAction reply=new RPAction();
    reply.put("test","world ok");

    netMan.sendMessage(new MessageC2SAction(recv.getSocketChannel(), reply));

    MessageC2SAction msgReply=null;
    while(msgReply==null) {
      msgReply=(MessageC2SAction) clientNet.getMessage(100);
    }

    assertNotNull(msgReply);
    assertEquals(reply, msgReply.getRPAction());
  }
View Full Code Here

   *            the action message
   */
  @Override
  public void process(Message message) {
    try {
      MessageC2SAction msg = (MessageC2SAction) message;
      int clientid = msg.getClientID();

      PlayerEntry entry = playerContainer.get(clientid);

      /*
       * verify event
       */
      if (!isValidEvent(msg, entry, ClientState.GAME_BEGIN)) {
        return;
      }
     
      /*
       * Update timeout timestamp on player.
       */
      entry.update();

      /* Send the action to RP Manager */
      RPAction action = msg.getRPAction();

      /*
       * NOTE: These are action attributes that are important for RP
       * functionality. Tag them in such way that it is not possible to
       * change them on a buggy RP implementation or it will cause
View Full Code Here

    RPAction action = new RPAction();
    action.put("one", 1);
    action.put("two", "2");

    MessageC2SAction message = new MessageC2SAction(null, action);

    byte[] result = enc.encode(message);

    Decoder dec = Decoder.get();
View Full Code Here

    RPAction action = new RPAction();
    action.put("one", 1);
    action.put("two", "2");

    MessageC2SAction message = new MessageC2SAction(null, action);

    byte[] result = enc.encode(message);

    Decoder dec = Decoder.get();
View Full Code Here

    RPAction action = new RPAction();
    action.put("one", 1);
    action.put("two", "2");

    MessageC2SAction message = new MessageC2SAction(null, action);

    byte[] result1 = enc.encode(message);

    action = new RPAction();
    action.put("three", 31);
    action.put("four", "4");

    message = new MessageC2SAction(null, action);

    byte[] result2 = enc.encode(message);
   
    byte[] result=new byte[result1.length+result2.length];
    System.arraycopy(result1, 0, result, 0, result1.length);
View Full Code Here

TOP

Related Classes of marauroa.common.net.message.MessageC2SAction

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.