Exemplo n.º 1
0
        public async Task <Package> Receive()
        {
            var result = await Client.ReceiveAsync();

            Package package = null;

            if (result.RemoteEndPoint.Address.ToString() == "127.0.0.1")
            {
                MainEntry._Logger.Debug("Receive JsonPackage");
                package = JsonPackage.Unpack(result.Buffer);
            }
            else
            {
                MainEntry._Logger.Debug("Receive TerminalPackage");

                package = Package.Unpack(result.RemoteEndPoint, result.Buffer);
            }

            if (package != null)
            {
                Console.WriteLine(string.Format("Socket ReceiveData Package Type {0}", package._PackageType));
            }
            else
            {
                Console.WriteLine(string.Format("Socket ReceiveData Package but Null"));
            }
            return(package);
        }
Exemplo n.º 2
0
        public async Task <Package> Receive()
        {
            var result = await Client.ReceiveAsync();

            Package package = null;

            if (result.RemoteEndPoint.Address.ToString() == "127.0.0.1")
            {
                package = JsonPackage.Unpack(result.Buffer);
            }
            else
            {
                package = Package.Unpack(result.RemoteEndPoint, result.Buffer);
            }

            Console.WriteLine(string.Format("Socket ReceiveData Package Type {0}", package._PackageType));
            return(package);
        }