Beispiel #1
0
  public void mapdata(Message msg) {
    long now = System.currentTimeMillis();
    int pktid = msg.int32();
    int off = msg.uint16();
    int len = msg.uint16();
    Defrag fragbuf;
    synchronized (fragbufs) {
      if ((fragbuf = fragbufs.get(pktid)) == null) {
        fragbuf = new Defrag(len);
        fragbufs.put(pktid, fragbuf);
      }
      fragbuf.add(msg.blob, 8, msg.blob.length - 8, off);
      fragbuf.last = now;
      if (fragbuf.done()) {
        mapdata2(fragbuf.msg());
        fragbufs.remove(pktid);
      }

      /* Clean up old buffers */
      for (Iterator<Map.Entry<Integer, Defrag>> i = fragbufs.entrySet().iterator(); i.hasNext(); ) {
        Map.Entry<Integer, Defrag> e = i.next();
        Defrag old = e.getValue();
        if (now - old.last > 10000) i.remove();
      }
    }
  }
  /**
   * Adds the channel-bundles of this <tt>Conference</tt> as
   * <tt>ColibriConferenceIQ.ChannelBundle</tt> instances in <tt>iq</tt>.
   *
   * @param iq the <tt>ColibriConferenceIQ</tt> in which to describe.
   */
  void describeChannelBundles(ColibriConferenceIQ iq) {
    synchronized (transportManagers) {
      for (Map.Entry<String, IceUdpTransportManager> entry : transportManagers.entrySet()) {
        ColibriConferenceIQ.ChannelBundle responseBundleIQ =
            new ColibriConferenceIQ.ChannelBundle(entry.getKey());

        entry.getValue().describe(responseBundleIQ);
        iq.addChannelBundle(responseBundleIQ);
      }
    }
  }
Beispiel #3
0
 public void trim(Coord ul, Coord lr) {
   synchronized (grids) {
     synchronized (req) {
       for (Iterator<Map.Entry<Coord, Grid>> i = grids.entrySet().iterator(); i.hasNext(); ) {
         Map.Entry<Coord, Grid> e = i.next();
         Coord gc = e.getKey();
         Grid g = e.getValue();
         if ((gc.x < ul.x) || (gc.y < ul.y) || (gc.x > lr.x) || (gc.y > lr.y)) i.remove();
       }
       for (Iterator<Coord> i = req.keySet().iterator(); i.hasNext(); ) {
         Coord gc = i.next();
         if ((gc.x < ul.x) || (gc.y < ul.y) || (gc.x > lr.x) || (gc.y > lr.y)) i.remove();
       }
     }
   }
 }
Beispiel #4
0
 public void sendreqs() {
   long now = System.currentTimeMillis();
   synchronized (req) {
     for (Iterator<Map.Entry<Coord, Request>> i = req.entrySet().iterator(); i.hasNext(); ) {
       Map.Entry<Coord, Request> e = i.next();
       Coord c = e.getKey();
       Request r = e.getValue();
       if (now - r.lastreq > 1000) {
         r.lastreq = now;
         if (++r.reqs >= 5) {
           i.remove();
         } else {
           Message msg = new Message(Session.MSG_MAPREQ);
           msg.addcoord(c);
           sess.sendmsg(msg);
         }
       }
     }
   }
 }