public String[] getUserList() throws RemoteException { Vector<String> res = new Vector<String>(); for (ChatUser CU : userstable.values()) { res.add(CU.getName()); } return res.toArray(new String[] {}); }
private void writeDataToLog(int xId, String key, RMItem value) { System.out.println("entering writedatatolog"); synchronized (logArray) { Log temp; int indx; if ((indx = logContains(xId)) != -1) { temp = (Log) logArray.elementAt(indx); temp.put(key, value); } else { temp = new Log(xId, new RMHashtable()); temp.put(key, value); logArray.add(temp); } } }
public void sendMessage(ChatMessage m) throws RemoteException { Vector<String> fallidos = new Vector<String>(); for (String uname : userstable.keySet()) { try { userstable.get(uname).sendMessage(m); } catch (Exception E) { fallidos.add(uname); System.out.println("no se lo he podido enviar a " + uname); } } for (String uname : fallidos) { try { leaveUser(userstable.get(uname)); } catch (Exception E) { System.out.println("realmente " + uname + " se ha ido , lo borro"); userstable.remove(uname); broadcastLeaving(uname); } } }