コード例 #1
0
        private async void ParseInput(bool exit, Socket ConnectionSocket)
        {
            Console.Write("Enter text : ");
            string Text = Console.ReadLine();

            if (Text.Contains("EXIT"))
            {
                ConnectionSocket.Send(NetPacket.Serialazie(new NetPacket()
                {
                    PacketType = NetPacket.NetPacketType.DISCONECT
                }));
                exit = true;
            }

            if (Text.Contains("POST:"))
            {
                ConnectionSocket.Send(await NetPacket.SerialazieAsync(new NetPacket()
                {
                    //Data = new Message() { Owner = Name , Time = DateTime.Now, Text = Text.Replace("POST:","")},
                    PacketType = NetPacket.NetPacketType.POST,
                }
                                                                      ));
            }

            if (Text.Contains("GET:"))
            {
                ConnectionSocket.Send(await NetPacket.SerialazieAsync(new NetPacket()
                {
                    //Data = new Message() { Owner = Text.Replace("GET:",""), Time = DateTime.Now },
                    PacketType = NetPacket.NetPacketType.GET,
                }
                                                                      ));
                var response = await NetPacket.DeserializeAsync(ConnectionSocket, 1024);

                //if (response.DataType==typeof(List<Message>))
                //{
                //    (response.Data as List<Message>).ForEach(Console.WriteLine);
                //}
            }
        }