Examples of SynchronizationManager


Examples of com.captiveimagination.jgn.synchronization.SynchronizationManager

      return;
    }
   
    JMEGraphicalController controller = new JMEGraphicalController(); //in charge of generating and applying sync messages
   
    SynchronizationManager syncManager = new SynchronizationManager(server, controller); //create the server that will send and receive sync messages
    syncManager.addSyncObjectManager(this);
   
    JGN.createThread(server).start(); //create a new thread for the server and start it
    JGN.createThread(syncManager).start(); //create and start a thread for the synchronization manager
   
    //register our sphere and make sure ot include its color
    try {
      syncManager.register(localSphere, new ColoredSynchronizeCreateMessage(localSphere.getColor()), 50);
    } catch (IOException e) {
      System.err.println("Could not register the local PlayerSphere:");
      e.printStackTrace();
      return;
    }
View Full Code Here

Examples of com.captiveimagination.jgn.synchronization.SynchronizationManager

    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) {
                  System.out.println("Message Failed: " + message);
              }
  
              public void messageReceived(Message message) {
                  System.out.println("Message Received: " + message);
              }

              public void messageSent(Message message) {
                  System.out.println("Message Sent: " + message);
              }
          });
   
    //register our sphere and make sure ot include its color
    try {
      syncManager.register(localSphere, new ColoredSynchronizeCreateMessage(localSphere.getColor()), 50);
    } catch (IOException e) {
      System.err.println("Could not register local PlayerSphere:");
      e.printStackTrace();
      return;
    }
View Full Code Here

Examples of com.captiveimagination.jgn.synchronization.SynchronizationManager

    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) {
                  System.out.println("Message Failed: " + message);
              }
  
              public void messageReceived(Message message) {
                  System.out.println("Message Received: " + message);
              }

              public void messageSent(Message message) {
                  System.out.println("Message Sent: " + message);
              }
          });
   
    //register our sphere
    syncManager.register(player, new SynchronizeCreateMessage(), 50);
  }
View Full Code Here

Examples of com.captiveimagination.jgn.synchronization.SynchronizationManager

        InetSocketAddress serverFast = new InetSocketAddress(InetAddress.getLocalHost(), 1501);
    JGNServer server = new JGNServer(serverReliable, serverFast); //this is our primary server and the addresses it should use
   
    JMEGraphicalController controller = new JMEGraphicalController(); //in charge of generating and applying sync messages
   
    SynchronizationManager syncManager = new SynchronizationManager(server, controller); //create the server that will send and receive sync messages
    syncManager.addSyncObjectManager(this);
   
    JGN.createThread(server).start(); //create a new thread for the server and start it
    JGN.createThread(syncManager).start(); //create and start a thread for the synchronization manager
   
    //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);
   
    syncManager.register(player, new SynchronizeCreateMessage(), 50); //register the server's sphere
  }
View Full Code Here

Examples of com.captiveimagination.jgn.synchronization.SynchronizationManager

      return;
    }
   
    controller = new JMEGraphicalController(); //in charge of generating and applying sync messages

    syncManager = new SynchronizationManager(server, controller); //create the server that will send and receive sync messages
    syncManager.addSyncObjectManager(this);
   
    Thread tmp = JGN.createThread(server); //create a new thread for the server and start it
    childThreads.add(tmp);
    tmp.start();
View Full Code Here

Examples of com.captiveimagination.jgn.synchronization.SynchronizationManager

    tmp.start();
   
    controller = new JMEGraphicalController(); //in charge of generating and applying sync messages

    //create the sync manager, register ourselves with it, and start its thread
    syncManager = new SynchronizationManager(client, controller);
    syncManager.addSyncObjectManager(this);
    tmp = JGN.createThread(syncManager);
    childThreads.add(tmp);
    tmp.start();
  }
View Full Code Here

Examples of com.captiveimagination.jgn.synchronization.SynchronizationManager

      return;
    }
   
    JMEGraphicalController controller = new JMEGraphicalController(); //in charge of generating and applying sync messages
   
    SynchronizationManager syncManager = new SynchronizationManager(server, controller); //create the server that will send and receive sync messages
    syncManager.addSyncObjectManager(this);
   
    JGN.createThread(server).start(); //create a new thread for the server and start it
    JGN.createThread(syncManager).start(); //create and start a thread for the synchronization manager
   
    //register our tank and make sure ot include its color
    try {
      syncManager.register(localTank, new ColoredSynchronizeCreateMessage(localTank.getColor()), 50);
    } catch (IOException e) {
      System.err.println("Could not register the local Tank:");
      e.printStackTrace();
      return;
    }
View Full Code Here

Examples of com.captiveimagination.jgn.synchronization.SynchronizationManager

    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) {
                  System.out.println("Message Failed: " + message);
              }
  
              public void messageReceived(Message message) {
                  System.out.println("Message Received: " + message);
              }

              public void messageSent(Message message) {
                  System.out.println("Message Sent: " + message);
              }
          });
   
    //register our tank and make sure ot include its color
    try {
      syncManager.register(localTank, new ColoredSynchronizeCreateMessage(localTank.getColor()), 50);
    } catch (IOException e) {
      System.err.println("Could not register local Tank:");
      e.printStackTrace();
      return;
    }
View Full Code Here

Examples of com.ikanow.infinit.e.processing.generic.synchronization.SynchronizationManager

    int fixes_db = 0;
    int fixes_search = 0;
        while (!sources.isEmpty()) {
          List<SourcePojo> sourceBatch = SourceUtils.getDistributedSourceList(sources, null, true);
          try {           
            SynchronizationManager syncManager = new SynchronizationManager();
            syncManager.setSources(sourceBatch);
           
            //TODO (INF-2114): For now remove this ... can add it back once syncDB is fixed:
            // (means that syncSearch will now do a lookup by hand against MongoDB)
            //HashSet<String> dbCache = new HashSet<String>();
            HashSet<String> dbCache = null;
           
            logger.debug("Syncing: " + sourceBatch.size());
           
            // Find things in the DB that don't have an index
            //TODO (INF-2114): For now remove this ... actually should call it but then
            // synch to the index instead of deleting from the DB
        //fixes_db += syncManager.syncDB(time_of_this_cleanse, dbCache);
       
            logger.debug("Syncing DB: " + fixes_db);
       
            // Find things in the index that don't have a DB entry
        fixes_search += syncManager.syncSearch(time_of_this_cleanse, dbCache);
       
            logger.debug("Syncing Index: " + fixes_search);           
          }
          catch (Exception e) {
            // Do nothing, the purpose of this try/catch is to ensure that the updateSyncStatus below always gets called
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.