Пример #1
0
 public override void OnConnected(ConnectionEventArgs e)
 {
     connection = e.Connection;
     connection.BeginReceive();
     if (Connected != null)
     {
         Connected(e.Connection);
     }
     ConnectEvent.Set();
 }
Пример #2
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.ConnectionId + "\r\n");
            s.Append(" Ip Address " + e.Connection.RemoteEndPoint.Address + "\r\n");
            s.Append(" Tcp Port " + e.Connection.RemoteEndPoint.Port + "\r\n");
            
            Console.WriteLine(s.ToString());
            s.Length = 0;
            
            e.Connection.CustomData = new ConnectionData(ConnectionState.csConnected);
            e.Connection.BeginReceive();
            
        }
Пример #3
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.ConnectionId + "\r\n");
            
            e.Connection.CustomData = null;
            
            Console.WriteLine(s.ToString());
            
            s.Length = 0;


        }
 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();
 }
        private void FireOnDisconnected(ConnectionEventArgs e)
        {
            
          FSocketService.OnDisconnected(e);

        }
        /// <summary>
        /// Begin disconnect the connection
        /// </summary>
        internal void BeginDisconnect(BaseSocketConnection connection)
        {

            if (!Disposed)
            {

              ConnectionEventArgs e = new ConnectionEventArgs(connection);

              if (connection.Active)
              {

                try
                {

                  if ((Environment.OSVersion.Version.Major == 5)
                      && (Environment.OSVersion.Version.Minor >= 1))
                  {

                    //----- NT5 / WinXP and later!
                    connection.Socket.BeginDisconnect(false, new AsyncCallback(BeginDisconnectCallback), e);

                  }
                  else
                  {

                    //----- NT5 / Win2000!
                    ThreadPool.QueueUserWorkItem(new WaitCallback(BeginDisconnectCallbackProcessing), e);
                    
                  }

                }
                catch (Exception ex)
                {
                  FireOnException(connection, ex);
                }

              }
              else
              {

                RemoveSocketConnection(connection);
                DisposeAndNullConnection(ref connection);

              }

            }

        }
Пример #8
0
 public override void OnDisconnected(ConnectionEventArgs e)
 {
     if (Disconnected != null)
     {
         Disconnected(e.Connection);
     }
     DisconnectEvent.Set();
 }
Пример #9
0
        public override void OnDisconnected(ConnectionEventArgs e)
        {

            StringBuilder s = new StringBuilder();

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

            Event(s.ToString());

            if (e.Connection.Host.HostType == HostType.htServer)
            {
                //------
            }
            else
            {
                e.Connection.AsClientConnection().BeginReconnect();
            }

        }
Пример #10
0
        public override void OnConnected(ConnectionEventArgs e)
        {

            StringBuilder s = new StringBuilder();

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

            Event(s.ToString());

            s.Length = 0;

            if (e.Connection.Host.HostType == HostType.htServer)
            {
                e.Connection.BeginReceive();
            }
            else
            {
                byte[] b = GetMessage(e.Connection.SocketHandle.ToInt32());
                e.Connection.BeginSend(b);
            }
            
        }
Пример #11
0
 public virtual void OnDisconnected(ConnectionEventArgs e) { }