예제 #1
0
 /**
  * Takes the input transmitted by a client and creates or updates the local instances that
  * represent the objects on the client.
  *
  * @param ec the container with the client's objects
  */
 public void setOrUpdate(ExtendedDataContainer ec) {
   ClientInfo ci = ec.getClientInfo();
   LocalObjectList lol = getLocalObjectList(ci);
   LocalObject lo = new LocalObject(ci.getID(), true);
   ec.fillLocalObject(lo);
   boolean found = false;
   for (Iterator<LocalObject> itty = lol.iterator(); itty.hasNext(); ) {
     LocalObject lot = itty.next();
     if (lot.equals(lo)) {
       lot.copyFrom(lo);
       found = true;
       break;
     }
   }
   if (!found) {
     lol.add(lo);
     NetLogger.log(
         "Server: Added an object of client "
             + ci.getID()
             + "! Client's object count is now: "
             + lol.size());
   }
 }
예제 #2
0
 /**
  * Fills a data container with data from the all local objects on the server.
  *
  * @param dc the container to fill
  */
 public void fill(ExtendedDataContainer dc, ClientInfo ci) {
   Map<ClientInfo, LocalObjectList> copy =
       new HashMap<ClientInfo, LocalObjectList>(client2LocalObj);
   if (ci != null) {
     copy.remove(ci);
   }
   for (Iterator<LocalObjectList> itty = copy.values().iterator(); itty.hasNext(); ) {
     LocalObjectList lol = itty.next();
     for (Iterator<LocalObject> itty2 = lol.iterator(); itty2.hasNext(); ) {
       LocalObject lo = itty2.next();
       dc.add(lo);
     }
   }
 }