public List<Message> RequestMessages(Guid token, int lastMessageId)
 {
     lock (threadLock)
     {
         AuthenticationProcessor auth = new AuthenticationProcessor();
         if (auth.ValidateNameByToken(token) != null)
         {
             var newMesseges = ServerContext.ChatSession.Where(m => m.Id > lastMessageId).ToList<Message>();
             return newMesseges;
         }
         else return null;
     }
 }
 public List <Message> RequestMessages(Guid token, int lastMessageId)
 {
     lock (threadLock)
     {
         AuthenticationProcessor auth = new AuthenticationProcessor();
         if (auth.ValidateNameByToken(token) != null)
         {
             var newMesseges = ServerContext.ChatSession.Where(m => m.Id > lastMessageId).ToList <Message>();
             return(newMesseges);
         }
         else
         {
             return(null);
         }
     }
 }
Beispiel #3
0
 public bool PutMessage(Guid token, string message)
 {
     lock (threadLock)
     {
         AuthenticationProcessor auth = new AuthenticationProcessor();
         var name = auth.ValidateNameByToken(token);
         if (name != null)
         {
             Message newMessage = new Message();
             newMessage.Id      = ServerContext.ChatSession.Count + 1;
             newMessage.Name    = name;
             newMessage.Time    = DateTime.Now;
             newMessage.Content = message;
             ServerContext.ChatSession.Add(newMessage);
             return(true);
         }
         return(false);
     }
 }
Beispiel #4
0
 public bool PutMessage(Guid token, string message)
 {
     lock (threadLock)
     {
         AuthenticationProcessor auth = new AuthenticationProcessor();
         var name = auth.ValidateNameByToken(token);
         if (name != null)
         {
             Message newMessage = new Message();
             newMessage.Id = ServerContext.ChatSession.Count + 1;
             newMessage.Name = name;
             newMessage.Time = DateTime.Now;
             newMessage.Content = message;
             ServerContext.ChatSession.Add(newMessage);
             return true;
         }
         return false;
     }
 }