Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected Map<String, Object> clientMap = new HashMap<String, Object>();
- if (!clientMap.contains(ClientID)){
- clientMap.put(clientID, Queue<Integer> queue = new ArrayDeque<Integer>());
- }
- Time startTime = now
- while(true) {
- nextPacket = queue.peek()
- for (Map.Entry<String, Object> entry : clientMap.entrySet()) {
- String key = entry.getKey();
- Object queue = entry.getValue();
- if (now - startTime) * bytesPerSecond > nextPacket.size {
- nextPacket = queue.dequeue()
- sendRequestToServer(nextPacket)
- startTime = now
- }
- sleep for a bit
- }
- }
- if (newPacket){ //new packet could be like new Network Event or something
- if queue.size < maxQueueSize{
- queue.enqueue(newRequest);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement