コード例 #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();
            }
        }
コード例 #3
0
 public override void OnDisconnected(ConnectionEventArgs e)
 {
     FSocketClient.DisconnectEvent.Set();
 }
コード例 #4
0
 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();
        }