Пример #1
0
        public void SendMessage(string toUsername, string message)
        {
            var requestMessage = new Gap.Network.Message
                                 {
                                     Name = "message",
                                     Parameters = new string[] { toUsername, message }
                                 };

            SendRequest(requestMessage);
        }
Пример #2
0
 public static void Send(Socket socket, Message requestMessage)
 {
     socket.Send(requestMessage.ToString());
 }
Пример #3
0
        private Gap.Network.Message SendRequest(string requestName, string parameter)
        {
            var requestMessage = new Gap.Network.Message { Name = requestName, Parameters = new string[] { parameter } };

            return SendRequest(requestMessage);
        }
Пример #4
0
        private Gap.Network.Message SendRequest(string requestName)
        {
            var requestMessage = new Gap.Network.Message { Name = requestName };

            return SendRequest(requestMessage);
        }
Пример #5
0
        public void ProcessRequest()
        {
            var requestMessage = Message.Receive(this.ClientTransmitterSocket);

            var responseMessage = new Message();

            switch (requestMessage.Name)
            {
                case "login":
                    this.Login(requestMessage.Parameters[0]);
                    break;
                case "getOnlineUsers":
                    responseMessage.Parameters = OnlineUsersButMe().Select(x => x.Name).ToArray();
                    break;
                case "logout":
                    this.Logout();
                    break;
                case "IntroReceiverPort":
                    int clientReceiverPort = int.Parse(requestMessage.Parameters[0]);
                    ConnectToClient(clientReceiverPort);
                    break;
                case "message":
                    SendMessage(requestMessage.Parameters[0], requestMessage.Parameters[1]);
                    break;
            }

            Message.Send(ClientTransmitterSocket, responseMessage);
        }