示例#1
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);
            }
        }
示例#2
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");
        }