Esempio n. 1
0
 /// <summary>
 /// Sends messages to server.
 /// </summary>
 /// <param name="message"></param>
 /// <param name="ss"></param>
 public static void Send(string message, Networking.SocketState ss)
 {
     // Append a newline, since that is our protocol's terminating character for a message.
     byte[] messageBytes = Encoding.UTF8.GetBytes(message);
     try
     {
         ss.theSocket.BeginSend(messageBytes, 0, messageBytes.Length, SocketFlags.None, SendCallback, ss.theSocket);
     }
     catch (SocketException E)
     {
         System.Diagnostics.Debug.WriteLine(E.Message);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Calls BeginReceive to get data from the server.
 /// </summary>
 /// <param name="ss"></param>
 public static void GetData(Networking.SocketState ss)
 {
     // not wrapping this in a try catch because for some reason the exceptions always throw in the receive callback.
     ss.theSocket.BeginReceive(ss.messageBuffer, 0, ss.messageBuffer.Length, SocketFlags.None, ReceiveCallback, ss);
 }