Example #1
0
        /// <summary>
        /// socket accepted handler
        /// </summary>
        /// <param name="listener"></param>
        /// <param name="connection"></param>
        private void OnAccepted(ISocketListener<TMessageInfo, TMessage> listener, SocketBase.IConnection<TMessageInfo, TMessage> connection)
        {
            if (base.CountConnection() < this._maxConnections)
            {
                connection.SetProtoHandler(_protocolHandlerFactory.CreateProtocolHandler());
                base.RegisterConnection(connection);
                return;
            }

            SocketBase.Log.Trace.Info("too many connections.");
            connection.BeginDisconnect();
        }
Example #2
0
 /// <summary>
 /// endPoint connected
 /// </summary>
 /// <param name="name"></param>
 /// <param name="connection"></param>
 protected virtual void OnEndPointConnected(string name, SocketBase.IConnection <TMessageInfo, TMessage> connection)
 {
     connection.SetProtoHandler(this._protocolHandlerFactory.CreateProtocolHandler(connection));
     base.RegisterConnection(connection);
 }