Beispiel #1
0
        public int ConnectIfNo()
        {
            if (this.remoteEP == null)
            {
                return(-1);
            }


            if (this.connectionStatus == WacohForceEnumConnectionStatus.Connecting)
            {
                return(1);
            }

            this.netNonStopTcpClient.ConnectIfNo();
            if (this.netNonStopTcpClient.IsLocalReadyConnect)
            {
                this.connectionStatus = WacohForceEnumConnectionStatus.Connecting;
            }

            return(0);
        }
Beispiel #2
0
        public WacohForceLdd()
        {
            this.netNonStopTcpClient.EhDataReceive += (sender, e) =>
            {
                var ee  = e as CtkNonStopTcpStateEventArgs;
                var msg = ee.TrxMessageBuffer;
                this.messageReceiver.Receive(msg.Buffer, msg.Offset, msg.Length);
                this.messageReceiver.AnalysisMessage();

                if (this.messageReceiver.Count == 0)
                {
                    return;
                }

                var vec = this.messageReceiver.Dequeue();
                if (this.correctionFlag)
                {
                    this.centerForceVector = vec;
                    lock (this)
                        correctionFlag = false;
                }

                var ea = new WacohForceMessageEventArgs();
                ea.centerForceVector = this.centerForceVector;
                ea.rawForceVector    = vec;
                this.OnDataReceive(ea);
            };


            this.netNonStopTcpClient.EhDisconnect += (sender, e) =>
            {
                this.connectionStatus = WacohForceEnumConnectionStatus.Disconnection;
            };
            this.netNonStopTcpClient.EhFirstConnect += (sender, e) =>
            {
                this.connectionStatus = WacohForceEnumConnectionStatus.Connected;
            };
        }