Example #1
0
        protected static void DisconnectCallback(IAsyncResult ar)
        {
            RatClient context = (RatClient)ar.AsyncState;

            try
            {
                context.socket.EndDisconnect(ar);
            } catch (SocketException e)
            {
                // not sure
            }
            context.OnStateChanged(false, "Successfully disconnected from server");
        }
Example #2
0
        protected static void AcceptCallback(IAsyncResult ar)
        {
            RatServer context = (RatServer)ar.AsyncState;

            try
            {
                Socket    connection = context.socket.EndAccept(ar);
                RatClient client     = new RatClient(connection);

                context.OnClientConnected(client);
            }
            catch (SocketException e)
            {
            }
            context.socket.BeginAccept(new AsyncCallback(AcceptCallback), context);
        }
Example #3
0
        protected static void ConnectCallback(IAsyncResult ar)
        {
            RatClient context = (RatClient)ar.AsyncState;

            try
            {
                context.socket.EndConnect(ar);
                if (context.socket.Connected)
                {
                    context.OnStateChanged(true, "Successfully connected to server");
                }
            } catch (SocketException e)
            {
                context.OnStateChanged(false, "Failed to connect to server: " + e.Message);
            }
        }
Example #4
0
 protected void OnClientConnected(RatClient client)
 {
     ClientConnected?.Invoke(this, client);
 }