From 900bfb3d508983ab8ee6fb08c4f6091a1cd0f102 Mon Sep 17 00:00:00 2001 From: Nikhildec Date: Sun, 10 Jan 2016 01:37:11 +0530 Subject: [PATCH] Update MessageDispatcher.java --- .../vartalap/server/MessageDispatcher.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/RPIAN Vartalap Server/src/rpian/vartalap/server/MessageDispatcher.java b/RPIAN Vartalap Server/src/rpian/vartalap/server/MessageDispatcher.java index 6979038..0b114f9 100644 --- a/RPIAN Vartalap Server/src/rpian/vartalap/server/MessageDispatcher.java +++ b/RPIAN Vartalap Server/src/rpian/vartalap/server/MessageDispatcher.java @@ -1,18 +1,31 @@ package rpian.vartalap.server; import java.io.PrintWriter; +import java.util.Collection; +import java.util.Iterator; -public class MessageDispatcher extends Thread { +public class MessageDispatcher extends Thread +{ @Override - public void run() { - while (true) { - try { + public void run() + { + while (true) + { + try + { String str = RPIANVartalapServer.q.dequeue(); - for (PrintWriter o : RPIANVartalapServer.nosArrayList) { - o.println(str); + System.out.println("Str = "+str); + Collection c = RPIANVartalapServer.nosArrayList.values();//currently you can get all nos later u can get based on username + Iterator i = c.iterator(); + while (i.hasNext()) + { + PrintWriter p = i.next(); + p.println(str); } - } catch (Exception e) { + } + catch (Exception e) + { System.out.println("MessageDispatcher Caught Exception: " + e); } }