예제 #1
0
        protected void Init(string host, int port, int connectionTimeout)
        {
            this._pkg      = new FPPackage();
            this._cry      = new FPEncryptor(_pkg);
            this._psr      = new FPProcessor();
            this._callback = new FPCallback();

            if (connectionTimeout <= 0)
            {
                connectionTimeout = 30 * 1000;
            }

            FPManager.Instance.AddSecond(OnSecondDelegate);
            this._sock = new FPSocket(OnData, host, port, connectionTimeout);
            this._sock.Socket_Connect = this.OnConnect;
            this._sock.Socket_Close   = this.OnClose;
            this._sock.Socket_Error   = this.OnError;
        }
예제 #2
0
        protected void Init(string host, int port, bool autoReconnect, int connectionTimeout)
        {
            this._pkg      = new FPPackage();
            this._cyr      = new FPEncryptor(_pkg);
            this._event    = new FPEvent();
            this._psr      = new FPProcessor();
            this._callback = new FPCallback();

            if (connectionTimeout > 0)
            {
                this._timeout = connectionTimeout;
            }

            this._autoReconnect = autoReconnect;

            FPClient self = this;

            this._eventDelegate = (evd) => {
                self.OnSecond(evd.GetTimestamp());
            };

            ThreadPool.Instance.Event.AddListener("second", this._eventDelegate);

            this._sock = new FPSocket((stream) => {
                self.OnData(stream);
            }, host, port, this._timeout);

            this._sock.GetEvent().AddListener("connect", (evd) => {
                self.OnConnect();
            });

            this._sock.GetEvent().AddListener("close", (evd) => {
                self.OnClose();
            });

            this._sock.GetEvent().AddListener("error", (evd) => {
                self.OnError(evd.GetException());
            });
        }