public void SendNewMessage(ChatMessage newMessage) { ISendToClient callback = OperationContext.Current.GetCallbackChannel <ISendToClient>(); ThreadPool.QueueUserWorkItem(DeliverMessage, newMessage); Console.WriteLine($"{newMessage.ToString()}"); }
public void ClientConnect(ChatUser user) { var exists = from ChatUser e in connectedUsers where e.UserName == user.UserName select e; if (exists.Count() == 0) { connectedUsers.Add(user); Console.WriteLine("({0}) New user connected - {1}", DateTime.Now.ToString(), user.UserName); ISendToClient callback = OperationContext.Current.GetCallbackChannel <ISendToClient>(); callbackList.Add(user.UserName, callback); ThreadPool.QueueUserWorkItem(InitUsersList, callback); ThreadPool.QueueUserWorkItem(SendNewUserInfo, user); ChatMessage enterMessage = new ChatMessage() { User = user, Date = DateTime.Now, Message = "I connected" }; SendNewMessage(enterMessage); } }
public void sendNewMessage(ChatMessage newMessage) { callback = OperationContext.Current.GetCallbackChannel <ISendToClient>(); callback.deliverNewMessage(newMessage); }