示例#1
0
        public override void OnConnected(ConnectionEventArgs e)
        {
            StringBuilder s = new StringBuilder();

            s.Append("------------------------------------------------" + "\r\n");
            s.Append("Connected - " + e.Connection.Context.ConnectionId + "\r\n");
            s.Append(e.Connection.Context.Host.Context.HostType.ToString() + "\r\n");
            s.Append(e.Connection.Context.Creator.Context.Name + "\r\n");
            s.Append(e.Connection.Context.Creator.Context.EncryptType.ToString() + "\r\n");
            s.Append(e.Connection.Context.Creator.Context.CompressionType.ToString() + "\r\n");
            s.Append("------------------------------------------------" + "\r\n");

            Event(s.ToString());

            s.Length = 0;

            Thread.Sleep(123);

            if (e.Connection.Context.Host.Context.HostType == HostType.htServer)
            {
                e.Connection.BeginReceive();
            }
            else
            {
                byte[] b = GetMessage(e.Connection.Context.SocketHandle.Handle.ToInt32());
                e.Connection.BeginSend(b);
            }
        }
示例#2
0
        public override void OnDisconnected(ConnectionEventArgs e)
        {
            StringBuilder s = new StringBuilder();

            s.Append("------------------------------------------------" + "\r\n");
            s.Append("Disconnected - " + e.Connection.Context.ConnectionId + "\r\n");
            s.Append("------------------------------------------------" + "\r\n");

            Event(s.ToString());
            s.Length = 0;

            if (e.Connection.Context.Host.Context.HostType == HostType.htServer)
            {
                //------
            }
            else
            {
                //e.Connection.AsClientConnection().BeginReconnect();
            }
        }
 public override void OnDisconnected(ConnectionEventArgs e)
 {
     FSocketClient.DisconnectEvent.Set();
 }
 public override void OnConnected(ConnectionEventArgs e)
 {
     FSocketClient.SocketConnection = e.Connection;
     FSocketClient.SocketConnection.BeginReceive();
     FSocketClient.ConnectEvent.Set();
 }
示例#5
0
        public override void OnDisconnected(ConnectionEventArgs e)
        {
            StringBuilder s = new StringBuilder();

            s.Append("------------------------------------------------" + "\r\n");
            s.Append("Client Disconnected\r\n");
            s.Append(" Connection Id " + e.Connection.Context.ConnectionId + "\r\n");

            e.Connection.Context.UserData = null;

            Console.WriteLine(s.ToString());

            s.Length = 0;
        }
示例#6
0
        public override void OnConnected(ConnectionEventArgs e)
        {
            StringBuilder s = new StringBuilder();

            s.Append("\r\n------------------------------------------------\r\n");
            s.Append("New Client\r\n");
            s.Append(" Connection Id " + e.Connection.Context.ConnectionId + "\r\n");
            s.Append(" Ip Address " + e.Connection.Context.RemoteEndPoint.Address + "\r\n");
            s.Append(" Tcp Port " + e.Connection.Context.RemoteEndPoint.Port + "\r\n");

            Console.WriteLine(s.ToString());
            s.Length = 0;

            e.Connection.Context.UserData = new ConnectionData(ConnectionState.csConnected);
            e.Connection.BeginReceive();
        }