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

            SendRequest(requestMessage);
        }
Example #2
0
 public static void Send(Socket socket, Message requestMessage)
 {
     socket.Send(requestMessage.ToString());
 }
Example #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);
        }
Example #4
0
        private Gap.Network.Message SendRequest(string requestName)
        {
            var requestMessage = new Gap.Network.Message { Name = requestName };

            return SendRequest(requestMessage);
        }
Example #5
0
File: User.cs Project: hakan648/Gap
        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);
        }