public Boolean notifyUser(String userName, String message) { String hash = HashArchive.getInstance().getHashByUserName(userName); if (hash != null) { WebSocketController.sendMessageToClient(hash, message); return(true); } LinkedList <String> CurrentPendingMessages; WebSocketController.PendingMessages.TryGetValue(userName, out CurrentPendingMessages); if (CurrentPendingMessages != null) { PMDB.Add(new Tuple <string, string>(userName, message)); CurrentPendingMessages.AddLast(message); } else { PMDB.Add(new Tuple <string, string>(userName, message)); CurrentPendingMessages = new LinkedList <String>(); CurrentPendingMessages.AddLast(message); WebSocketController.PendingMessages.Add(userName, CurrentPendingMessages); } return(false); }
public void AddMessage() { try { var toAdd = Tuple.Create("aviad", "9000"); pendingMessagesDB.Add(toAdd); li = pendingMessagesDB.Get(); Assert.AreEqual(li.Count, 2); } catch (Exception e) { Assert.AreEqual(true, false, "there was a connection error to the testing db"); } }
public void init() { WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB(); cDB.emptyDB(); configuration.DB_MODE = testing; pendingMessagesDB = new PendingMessagesDB(testing); li = new LinkedList <Tuple <String, String> >(); pendingMessagesDB.Add(Tuple.Create("itamar", "hey")); }