Examples of JGNClient


Examples of com.captiveimagination.jgn.clientserver.JGNClient

  public ChatClient() throws Exception {
    JGN.register(NamedChatMessage.class);

    InetSocketAddress reliableAddress = new InetSocketAddress(InetAddress.getLocalHost(), 0);
    InetSocketAddress fastAddress = new InetSocketAddress(InetAddress.getLocalHost(), 0);
    client = new JGNClient(reliableAddress, fastAddress);
    client.addMessageListener(this);
    client.addMessageListener(new DebugListener("ChatClient>"));
    JGN.createThread(client).start();

    InetSocketAddress reliableServerAddress = new InetSocketAddress(InetAddress.getByName("10.100.1.49"), 1100);
View Full Code Here

Examples of com.captiveimagination.jgn.clientserver.JGNClient

          e.printStackTrace();
          return;
        }
       
        //create the client and start it in its own thread
    JGNClient client;
    try {
      client = new JGNClient(clientReliable, clientFast); //create the networking client
    } catch (IOException e) {
      System.err.println("Could not create JGN client:");
      e.printStackTrace();
      return;
    }
    JGN.createThread(client).start(); //create a new thread for the client and start it
   
    JMEGraphicalController controller = new JMEGraphicalController(); //in charge of generating and applying sync messages
   
    //create the sync manager, register ourselves with it, and start its thread
    SynchronizationManager syncManager = new SynchronizationManager(client, controller);
    syncManager.addSyncObjectManager(this);
    JGN.createThread(syncManager).start();
   
    //connect to the server
    System.out.println("Connecting...");
    try {
      client.connectAndWait(serverReliable, serverFast, 5000);
    } catch (IOException e) {
      //Show an error message that we couldn't connect and print detailed info to standard error
      JOptionPane.showMessageDialog(null, "Could not connect to server.", "Connection Error", JOptionPane.ERROR_MESSAGE);
      System.err.println("Error while connecting to server:");
      e.printStackTrace();
      return;
    } catch (InterruptedException e) {
      //Show an error message that we couldn't connect and print detailed info to standard error
      JOptionPane.showMessageDialog(null, "Could not connect to server.", "Connection Error", JOptionPane.ERROR_MESSAGE);
      System.err.println("Error while connecting to server:");
      e.printStackTrace();
      return;
    }
    System.out.println("Connected!");
   
    //attach a MessageListener so that we can get more detailed information about what the server is doing
    client.getServerConnection().getReliableClient().addMessageListener(new MessageListener() {
              public void messageCertified(Message message) {
                  System.out.println("Message Certified: " + message);
              }
  
              public void messageFailed(Message message) {
View Full Code Here

Examples of com.captiveimagination.jgn.clientserver.JGNClient

        InetSocketAddress serverFast = new InetSocketAddress(InetAddress.getLocalHost(), 1501);
        //client addresses
        InetSocketAddress clientReliable = new InetSocketAddress(InetAddress.getLocalHost(), 0); //let Java choose a port for us
        InetSocketAddress clientFast = new InetSocketAddress(InetAddress.getLocalHost(), 0); //let Java choose a port for us
        //create the client and start it in its own thread
    JGNClient client = new JGNClient(clientReliable, clientFast); //create the networking client
    JGN.createThread(client).start(); //create a new thread for the client and start it
   
    JMEGraphicalController controller = new JMEGraphicalController(); //in charge of generating and applying sync messages
   
    //create the sync manager, register ourselves with it, and start its thread
    SynchronizationManager syncManager = new SynchronizationManager(client, controller);
    syncManager.addSyncObjectManager(this);
    JGN.createThread(syncManager).start();
   
    //get localSphere from the game
    Field field = ExampleGame.class.getDeclaredField("localSphere");
    field.setAccessible(true);
    PlayerSphere player = null;
    while((player = (PlayerSphere)field.get(app)) == null) {
      try {
        Thread.sleep(100);
      }catch(Exception e) {
        System.err.println("Error while thread sleeping to get field:");
        e.printStackTrace();
      }
    }
   
    //get rootNode from the game
    field = ExampleGame.class.getDeclaredField("scene");
    field.setAccessible(true);
    Node scene = (Node)field.get(app);
    setScene(scene);
   
    //connect to the server
    System.out.println("Connecting...");
    client.connectAndWait(serverReliable, serverFast, 5000);
    System.out.println("Connected!");
   
     client.getServerConnection().getReliableClient().addMessageListener(new MessageListener() {
              public void messageCertified(Message message) {
                  System.out.println("Message Certified: " + message);
              }
  
              public void messageFailed(Message message) {
View Full Code Here

Examples of com.captiveimagination.jgn.clientserver.JGNClient

      return;
    }

    //create the client and start it in its own thread
    try {
      client = new JGNClient(clientReliable, clientFast); //create the networking client
    } catch (IOException e) {
      System.err.println("Could not create JGN client:");
      e.printStackTrace();
      return;
    }
View Full Code Here

Examples of com.captiveimagination.jgn.clientserver.JGNClient

          e.printStackTrace();
          return;
        }
       
        //create the client and start it in its own thread
    JGNClient client;
    try {
      client = new JGNClient(clientReliable, clientFast); //create the networking client
    } catch (IOException e) {
      System.err.println("Could not create JGN client:");
      e.printStackTrace();
      return;
    }
    JGN.createThread(client).start(); //create a new thread for the client and start it
   
    JMEGraphicalController controller = new JMEGraphicalController(); //in charge of generating and applying sync messages
   
    //create the sync manager, register ourselves with it, and start its thread
    SynchronizationManager syncManager = new SynchronizationManager(client, controller);
    syncManager.addSyncObjectManager(this);
    JGN.createThread(syncManager).start();
   
    //connect to the server
    System.out.println("Connecting...");
    try {
      client.connectAndWait(serverReliable, serverFast, 5000);
    } catch (IOException e) {
      //Show an error message that we couldn't connect and print detailed info to standard error
      JOptionPane.showMessageDialog(null, "Could not connect to server.", "Connection Error", JOptionPane.ERROR_MESSAGE);
      System.err.println("Error while connecting to server:");
      e.printStackTrace();
      return;
    } catch (InterruptedException e) {
      //Show an error message that we couldn't connect and print detailed info to standard error
      JOptionPane.showMessageDialog(null, "Could not connect to server.", "Connection Error", JOptionPane.ERROR_MESSAGE);
      System.err.println("Error while connecting to server:");
      e.printStackTrace();
      return;
    }
    System.out.println("Connected!");
   
    //attach a MessageListener so that we can get more detailed information about what the server is doing
    client.getServerConnection().getReliableClient().addMessageListener(new MessageListener() {
              public void messageCertified(Message message) {
                  System.out.println("Message Certified: " + message);
              }
  
              public void messageFailed(Message message) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.