public static SessionProvider CreateTcpSessionProvider(SessionProviderOptions options, OnSessionNotify <SessionCompletedNotify, SessionHandler> onSessionNotifyProc) { SessionProvider provider = new TcpSocketSessionProviderHandle(options, onSessionNotifyProc); return(provider); }
public static SessionProvider CreateProxySessionProvider(SessionProviderOptions options, OnSessionNotify <SessionCompletedNotify, SessionProviderContext> onSessionNotifyProc, OnProxyNotify <ProxyNotify> onProxyNotifyProc) { SessionProvider provider = new TcpProxySessionProviderHandle(options, onSessionNotifyProc, onProxyNotifyProc); return(provider); }
internal TcpSocketSessionProviderHandle( SessionProviderOptions options, OnSessionNotify <SessionCompletedNotify, SessionProviderContext> onSessionNotifyProc) : base(onSessionNotifyProc) { _options = options; var serverConfig = new TcpSocketSaeaServerConfiguration(); serverConfig.AppKeepAlive = true; serverConfig.CompressTransferFromPacket = false; serverConfig.PendingConnectionBacklog = options.PendingConnectionBacklog; _server = TcpSocketsFactory.CreateServerAgent(TcpSocketSaeaSessionType.Packet, serverConfig, (notify, session) => { switch (notify) { case TcpSocketCompletionNotify.OnConnected: var sessionBased = new TcpSocketSessionBased(session); session.AppTokens = new object[] { sessionBased }; _onSessionNotifyProc(SessionCompletedNotify.OnConnected, sessionBased); break; case TcpSocketCompletionNotify.OnSend: _onSessionNotifyProc(SessionCompletedNotify.OnSend, session.AppTokens[0] as SessionProviderContext); break; case TcpSocketCompletionNotify.OnDataReceiveing: _onSessionNotifyProc(SessionCompletedNotify.OnRecv, session.AppTokens[0] as SessionProviderContext); break; case TcpSocketCompletionNotify.OnDataReceived: _onSessionNotifyProc(SessionCompletedNotify.OnReceived, session.AppTokens[0] as SessionProviderContext); break; case TcpSocketCompletionNotify.OnClosed: _onSessionNotifyProc(SessionCompletedNotify.OnClosed, session.AppTokens[0] as SessionProviderContext); break; default: break; } }); }
internal TcpProxySessionProviderHandle( SessionProviderOptions options, OnSessionNotify <SessionCompletedNotify, SessionHandler> onSessionNotifyProc, OnProxyNotify <ProxyNotify> onProxyNotify) : base(onSessionNotifyProc) { _options = options; _onProxyNotify = onProxyNotify; var clientConfig = new TcpSocketSaeaClientConfiguration(); clientConfig.ReuseAddress = true; clientConfig.KeepAlive = true; clientConfig.KeepAliveInterval = 5000; clientConfig.KeepAliveSpanTime = 1000; _clientAgent = TcpSocketsFactory.CreateClientAgent(TcpSocketSaeaSessionType.Full, clientConfig, (notify, session) => { switch (notify) { case TcpSocketCompletionNotify.OnConnected: this.ConnectionProcess(session); break; case TcpSocketCompletionNotify.OnSend: this.OnSend(session); break; case TcpSocketCompletionNotify.OnDataReceiveing: this.PacketProcess(session); break; case TcpSocketCompletionNotify.OnClosed: this.OnClosed(session); break; default: break; } }); }
internal SessionProvider(OnSessionNotify <SessionCompletedNotify, SessionHandler> onSessionNotifyProc) { _onSessionNotifyProc = onSessionNotifyProc; }
protected SessionProvider(OnSessionNotify <SessionCompletedNotify, SessionProviderContext> onSessionNotifyProc) { _onSessionNotifyProc = onSessionNotifyProc; }