Advertisement
courtneythurston

Untitled

Feb 26th, 2021
943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. protected Map<String, Object> clientMap = new HashMap<String, Object>();
  2.  
  3. if (!clientMap.contains(ClientID)){
  4.     clientMap.put(clientID, Queue<Integer> queue = new ArrayDeque<Integer>());
  5. }
  6.  
  7. Time startTime = now
  8.    
  9. while(true) {
  10. nextPacket = queue.peek()
  11. for (Map.Entry<String, Object> entry : clientMap.entrySet()) {
  12.     String key = entry.getKey();
  13.     Object queue = entry.getValue();
  14.     if (now - startTime) * bytesPerSecond > nextPacket.size {
  15.         nextPacket = queue.dequeue()
  16.         sendRequestToServer(nextPacket)
  17.         startTime = now
  18.     }
  19. sleep for a bit
  20.     }
  21. }
  22. if (newPacket){ //new packet could be like new Network Event or something
  23.     if queue.size < maxQueueSize{
  24.         queue.enqueue(newRequest);
  25.     }
  26. }
  27.  
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement