Package marauroa.client.net

Examples of marauroa.client.net.TCPNetworkClientManager


   *            server port number
   * @throws IOException
   *             if connection is not possible
   */
  public void connect(String host, int port) throws IOException {
    netMan = new TCPNetworkClientManager(host, port);
  }
View Full Code Here


   * @param proxy proxy server to use for the connection
   * @param serverAddress marauroa server (final destination)
   * @throws IOException if connection is not possible
   */
  public void connect(Proxy proxy, InetSocketAddress serverAddress) throws IOException {
    netMan = new TCPNetworkClientManager(proxy, serverAddress);
  }
View Full Code Here

   * Test that message sent from client to server are received correctly.
   * This test the structure from end to end. Client -> serialize -> net -> deserialize -> Server
   */
  @Test
  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

   * This test the structure from end to end. Client -> serialize -> net -> deserialize -> Server
   * @throws InvalidVersionException
   */
  @Test
  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

TOP

Related Classes of marauroa.client.net.TCPNetworkClientManager

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.