Пример #1
0
        /// <summary>
        /// Callback for when a new client connects to the server
        /// </summary>
        /// <param name="asyncResult"></param>
        protected virtual void AcceptClient(IAsyncResult asyncResult)
        {
            ClientComms = new Comms(Listener.EndAcceptTcpClient(asyncResult));
            ClientComms.OnDataReceived += ProcessMessage;

            ListenForNewClient();
        }
Пример #2
0
 public BaseClient(string ipAddress, int portNumber = 1490)
 {
     // Attempt to connect
     try
     {
         ServerComms = new Comms(new TcpClient(ipAddress, portNumber));
         ServerComms.OnDataReceived += OnMessageReceived;
         ServerComms.OnDisconnect   += OnServerDisconnect;
     }
     catch (Exception e)
     {
         Console.WriteLine("Connection failed");
         Console.WriteLine(e.Message);
     }
 }