Receive() private static method

private static Receive ( ClientWebSocket webSocket ) : Client.Task
webSocket ClientWebSocket
return Client.Task
Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Client client = new Client("127.0.0.1", 9999);

            client.Send();
            client.Receive();
            Console.ReadLine();
        }
Exemplo n.º 2
0
 static void StartClient()
 {
     for (int i = 0; i < 1; i++)
     {
         Client newClient = new Client(Constants.ServerIp, Constants.DEFAULT_SERVER_PORT);
         newClient.Receive();
         newClient.Close();
     }
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Client client = new Client("10.184.195.154", 9999);//this was changed from zip Kristin's IP 8888 specific port

            Parallel.Invoke(() =>
            {
                while (true)
                {
                    client.Send();
                }
            },
                            () =>
            {
                while (true)
                {
                    client.Receive();
                }
            });
            Console.ReadLine();
        }
Exemplo n.º 4
0
        private string _lastCard = ""; //上一張被丟出的牌

        static void Main(string[] args)
        {
            Client program = new Client();

            program.CreateDictionary(); //建立字典

            program.Connect();          //連線到server

            while (true)
            {
                while (!program._gameOver)
                {
                    program.Assignment(program.Receive());
                }

                Console.WriteLine("本局結束,莊家換人,開始下一場\n");

                program._position  = -1;
                program._playerNow = 1;
                program._lastCard  = "";
                program._gameOver  = false;
                program._handCard  = null;
            }
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            WriteLine("Client started", Color.GREEN);
            WriteLine("");

            Write("Input serial device (eg. COM3): ");
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            string port = Console.ReadLine();

            Console.ResetColor();

            Client client;

            try
            {
                client = new Client(port, MAX_SIZE);
            }
            catch (PortException)
            {
                WriteLine("ERROR. COULD NOT OPEN PORT. EXITING", Color.RED);
                return;
            }

            WriteLine($"Client created on port \"{port.ToUpper()}\"\n");

            Write("Request file: ");
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            string fileName = Console.ReadLine();

            Console.ResetColor();


            Write($"Requesting file \"{fileName}\".. ");
            client.Send(Encoding.ASCII.GetBytes(fileName));
            WriteLine("Done");


            Write("Getting file size.. ");
            var buffer = new ArrayList();

            client.Receive(ref buffer);

            var arr        = (byte[])buffer.ToArray(typeof(byte));
            var sizeString = Encoding.ASCII.GetString(arr, 0, arr.Length);

            WriteLine("Done");
            WriteLine("Size: " + sizeString);

            var size  = Convert.ToInt64(sizeString);
            var count = (int)Math.Ceiling((double)size / MAX_SIZE);

            // Get file
            Write("\nReceiving file.. ");

            buffer = new ArrayList();
            for (int i = 0; i < count; i++)
            {
                client.Receive(ref buffer);
            }
            WriteLine("Done");

            // Save file
            Write("Saving file.. ");

            fileName = "RECEIVED_" + fileName;
            var file = Path.Combine(Environment.CurrentDirectory, fileName);

            arr = (byte[])buffer.ToArray(typeof(byte));
            File.WriteAllBytes(file, arr);

            WriteLine("Done");

            WriteLine("\nRequest handled. Exiting..", Color.GREEN);
        }