Server.Connector.Send C# (CSharp) Méthode

Send() private méthode

private Send ( Socket client, String data ) : void
client Socket
data String
Résultat void
        private void Send(Socket client, String data)
        {
            byte[] byteData = Encoding.ASCII.GetBytes(data);

            client.BeginSend(byteData, 0, byteData.Length, 0,
                new AsyncCallback(SendCallback), client);
        }

Same methods

Connector::Send ( Socket client, byte data ) : void

Usage Example

 private void CreateLobby()
 {
     connector.Start();
     while (!this.isStarted)
     {
         if (connector.Clients.Count < CountOfPlayers)
         {
             connector.Send("hi", connector.SenderDefaultEndPoint);
             for (int i = 0; i < connector.AllMessages.Count;)
             {
                 string[] message = Encoding.UTF8.GetString(connector.AllMessages[0].Message).Split(' ');
                 if (message[0] == "new")
                 {
                     connector.Send("+new", connector.AllMessages[0].Address);
                     connector.Clients.Add(connector.AllMessages[0].Address);
                     Console.WriteLine("К серверу добавлен новый клиент:" + connector.AllMessages[0].Address);
                 }
                 connector.AllMessages.RemoveAt(0);
             }
         }
         else
         {
             Game.isReadyToStart = true;
             connector.AllMessages.Clear();
             break;
         }
         Thread.Sleep(500);
     }
     Console.WriteLine("Лобби собрано");
 }
All Usage Examples Of Server.Connector::Send