示例#1
0
        public void HandleReceivedMessage(Message message)
        {
            if (message is SearchRequest)
            {
                SearchResponse searchResponse = GetSearchResponse((SearchRequest)message);
                foreach (ConnectedClient connectedClient in clientsList)
                {
                    if (connectedClient.ClientID == searchResponse.ClientID)
                    {
                        connectedClient.TcpSocket.Send(MessageSerializer.Serialize(searchResponse));
                    }
                }
            }

            if (message is UpdateBookListRequest)
            {
                UpdateBookListRequest updateBookListRequest = (UpdateBookListRequest)message;
                foreach (ConnectedClient connectedClient in clientsList)
                {
                    if (connectedClient.ClientID == updateBookListRequest.ClientID)
                    {
                        connectedClient.ClientBookList = updateBookListRequest.NewBookList;
                    }
                }
            }
        }
示例#2
0
 public void SendMessage(BookShopLibrary.Message message)
 {
     TcpSocket.Send(ClientMessageSerializer.Serialize(message));
 }