public WebSocketSessionBase(INetApplication application, INetProtocol protocol, INetServer server, Socket clientSocket, ILogger logger)
     : base(application, protocol, server, clientSocket)
 {
     IsHandShake    = false;
     ReceiveTimeout = TimeSpan.FromMinutes(2);
     this.logger    = logger;
 }
        public virtual bool Setup(INetServerConfig config, INetApplication application, INetProtocol protocol, ISocketSessionFactory sessionFactory)
        {
            if (protocol == null)
            {
                throw new ArgumentNullException("protocol");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }

            this.protocol       = protocol;
            this.application    = application;
            this.config         = config;
            this.endPoint       = new IPEndPoint(config.Address, config.Port);
            this.sessionFactory = sessionFactory;

            this.status    = NetServerStatus.Inited;
            this.IsRunning = false;

            return(true);
        }
Beispiel #3
0
 public AsyncTcpSession(INetApplication application, INetProtocol protocol, INetServer server, Socket clientSocket)
     : base(application, protocol, server, clientSocket)
 {
     asyncEventArgs = new SocketAsyncEventArgs();
     Byte[] buffer = new byte[255];
     asyncEventArgs.SetBuffer(buffer, 0, 255);
     asyncEventArgs.Completed += new EventHandler <SocketAsyncEventArgs>(AsyncEventArgs_Completed);
 }
Beispiel #4
0
        public override bool Setup(INetServerConfig config, INetApplication application, INetProtocol protocol, ISocketSessionFactory sessionFactory)
        {
            if (base.Setup(config, application, protocol, sessionFactory))
            {
                Logger = LoggerManager.GetLogger(String.Concat(Application.Name, ".AsyncTcp.", config.Port));
                this.sessionFactory = sessionFactory;
                return(true);
            }

            return(false);
        }
        public INetSession CreateSession(INetApplication application, INetProtocol protocol, INetServer server, System.Net.Sockets.Socket client)
        {
            SocketSession      s      = new WebSocketSession(application, protocol, server, client);
            SocketServerConfig config = null;

            if (server is SocketServerBase)
            {
                config = (server as SocketServerBase).Config;
            }
            if (config != null)
            {
                s.Timeout     = TimeSpan.FromMinutes(config.SessionTimeout);
                s.TimeoutType = config.TimeoutType;
            }

            return(s);
        }
        protected virtual void Init(INetApplication application, INetProtocol protocol, INetServer server, Socket clientSocket)
        {
            this.application      = application;
            this.protocol         = protocol;
            this.server           = server;
            this.clientSocket     = clientSocket;
            this.sessionID        = Guid.NewGuid().ToString("N").ToLower();
            this.startTime        = DateTime.Now;
            this.ActiveTime       = DateTime.Now;
            this.Timeout          = TimeSpan.FromMinutes(10);
            this.LastRequestTime  = DateTime.Now;
            this.LastResponseTime = DateTime.Now;
            this.TimeoutType      = SessionTimeoutType.Active;

            if (clientSocket != null)
            {
                InnerStream = new NetworkStream(this.clientSocket);
            }
        }
Beispiel #7
0
        // private static ILogger logger = null;


        public WebSocketSession(INetApplication application, INetProtocol protocol, INetServer server, Socket clientSocket)
            : base(application, protocol, server, clientSocket, LoggerManager.GetLogger("WebSocketSession"))
        {
        }
Beispiel #8
0
 public UdpSession(INetApplication application, INetProtocol protocol, INetServer server, Socket clientSocket)
     : base(application, protocol, server, clientSocket)
 {
 }
 public SocketSession(INetApplication application, INetProtocol protocol, INetServer server, Socket clientSocket)
 {
     Init(application, protocol, server, clientSocket);
 }
 public virtual bool Setup(INetServerConfig config, INetApplication application, INetProtocol protocol)
 {
     return(false);
 }