Send() приватный статический Метод

private static Send ( ClientWebSocket webSocket ) : Client.Task
webSocket ClientWebSocket
Результат Client.Task
Пример #1
0
 private void Client_button_send_Click(object sender, EventArgs e)
 {
     try
     {
         clientEnd.Send(Encoding.UTF8.GetBytes(client_message.Text));
     }
     catch (Exception ex) { MessageBox.Show(ex.ToString()); }
 }
Пример #2
0
        private void connectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (clientState == ClientState.Disconnected)
            {
                try
                {
                    using (ConnectForm connectForm = new ConnectForm())
                    {
                        // THIS IS CONFIRMED TO WORK!
                        //float playerBase = codeInjector.ReadFloat(codeInjector.ReadUInt(codeInjector.ReadUInt(codeInjector.ReadUInt(codeInjector.ReadUInt(codeInjector.ReadUInt(0x004C67BC) + 0x60) + 0xA8) + 0x114) + 0x40) + 0x130);
                        //Console.WriteLine(playerBase);
                        connectForm.ShowDialog();
                        participant.Nickname = connectForm.Nickname;

                        client = new Client();
                        client.PacketReceived += client_PacketReceived;
                        client.Connect(IPAddress.Parse(connectForm.Server), 3031, 3030);
                        client.Send(ProtocolType.Tcp, new Packet()
                            {
                                PacketType = PacketType.Connect,
                                Content = connectForm.Nickname
                            });
                        clientState = ClientState.Connecting;

                        /*if (connectForm.Server != null && connectForm.Nickname != null)
                        {
                            ipEndPoint = new IPEndPoint(IPAddress.Parse(connectForm.Server), 3030);

                            tcpClient.Connect(new IPEndPoint(IPAddress.Parse(connectForm.Server), 3031));

                            stream = tcpClient.GetStream();

                            Packet packet = new Packet()
                            {
                                PacketType = PacketType.Connect,
                                Content = connectForm.Nickname
                            };

                            stream.Write(packet.ToBytes(), 0, packet.Length);

                            listenerThread.Start();

                            /*

                            client = new UdpClient();
                            client.Connect(ipEndPoint);

                            Packet packet = SendPacket(new Packet()
                                {
                                    PacketType = PacketType.Nickname,
                                    Content = connectForm.Nickname
                                });

                            if (packet.PacketType != PacketType.Nickname || packet.Content != "OK")
                            {
                                MessageBox.Show("An error occured during the handshake with the Server. A response was received, but the Server rejected your request. Please try again.", "Error while handshaking");
                            }
                            else
                            {
                                participants = new List<Participant>();
                                playerCount = 0;
                                participant.Nickname = connectForm.Nickname;
                                clientState = ClientState.Connected;

                                SetStatus("Connected (" + connectForm.Server + ")");
                            }
                        }*/
                    }
                }
                catch (Exception exc)
                {
                    ErrorHandler.ShowDialog("Connect dialog failed to load", "The connect dialog failed to load.", exc);
                }
            }
            else
            {
                MessageBox.Show("Disconnect from the current game to connect to a new game.","Already connected");
            }
        }