public static SessionProvider CreateProxySessionProvider(SessionProviderOptions options,
                                                                 OnSessionNotify <SessionCompletedNotify, SessionHandler> onSessionNotifyProc,
                                                                 OnProxyNotify <ProxyNotify> onProxyNotifyProc)
        {
            SessionProvider provider = new TcpProxySessionProviderHandle(options, onSessionNotifyProc, onProxyNotifyProc);

            return(provider);
        }
Example #2
0
        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;
                }
            });
        }