Example #1
0
        public void Stop()
        {
            isRunning = false;
            responseSocket.Close();
            responseSocket.Dispose();

            listenThread.Join(100);
            logger.Info("Message puller has stopped");
        }
Example #2
0
 protected override void OnStopped()
 {
     base.OnStopped();
     _pullSocket.Close();
     _pullSocket.Dispose();
     _pushSocket.Close();
     _pushSocket.Dispose();
     _netMqContext.Dispose();
 }
    public override void OnUnregistered()
    {
        base.OnUnregistered();

        Debug.Assert(_zmqPredictedMotion != null);
        _zmqPredictedMotion.Close();
        _msgRecv.Close();

        _zmqPredictedMotion.Dispose();
        _zmqPredictedMotion = null;

        _lastCenterEyePosition = Vector3.zero;
    }
    public void Close()
    {
        if (_zmqPredictedMotion == null)
        {
            return;
        }

        _zmqPredictedMotion.Close();
        _msgRecv.Close();

        _zmqPredictedMotion.Dispose();
        _zmqPredictedMotion = null;
    }
Example #5
0
        private void FanInEntry(object n)
        {
            FansInRun f;
            string    name = (string)n;

            if (FunInRM.ContainsKey(name))
            {
                f = FunInRM[name];
            }
            else
            {
                Logging.logger.Error("FunInEntry get name failed " + name);
                return;
            }

            PullSocket p = new PullSocket();
            string     e = "tcp://" + f.point.ip + ":" + f.point.port;

            try
            {
                p.Bind(e);
                f.pullsock = p;
            }
            catch (Exception err)
            {
                Logging.logger.Error(ModName + " bind funin socket failed " + e + " " + err.Message);
                throw (err);
            }

            string str;
            string outdata;
            bool   result;

            f.Working = true;
            while (f.Running)
            {
                str    = string.Empty;
                result = f.pullsock.TryReceiveFrameString(out str);

                outdata = string.Empty;
                if (result == true)
                {
                    outdata = Entry4FanInData(name, str);
                }

                DelayTime();
            }
            f.Working = false;
            p.Close();
            return;
        }
Example #6
0
        public void TearDown()
        {
            _actorService?.Stop();
            Poller?.Stop();
            PushSocket?.Close();
            PullSocket?.Close();
            Poller?.Dispose();

            PullSocket    = null;
            PushSocket    = null;
            Poller        = null;
            _actorService = null;

            Thread.Sleep(1000);
        }
Example #7
0
        private void SocketListener(object sender, DoWorkEventArgs e)
        {
            using (var pullSocket = new PullSocket(_host + _port))
            {
                while (!_eternalQueueListener.CancellationPending)
                {
                    NetMQMessage message = new NetMQMessage();
                    if (!pullSocket.TryReceiveMultipartMessage(TimeSpan.FromMilliseconds(500), ref message))
                    {
                        continue;
                    }

                    // There should only be 1 part messages
                    if (message.FrameCount != 1)
                    {
                        continue;
                    }

                    var payload = message[0].ConvertToString();

                    var packet = JsonConvert.DeserializeObject <Packet>(payload);

                    switch (packet.Type)
                    {
                    case PacketType.LiveResult:
                        var liveResultEventModel = JsonConvert.DeserializeObject <LiveResultPacket>(payload);
                        _packetQueue.Enqueue(liveResultEventModel);
                        break;

                    case PacketType.BacktestResult:
                        var backtestResultEventModel = JsonConvert.DeserializeObject <BacktestResultPacket>(payload);
                        _packetQueue.Enqueue(backtestResultEventModel);
                        break;

                    case PacketType.Log:
                        var logEventModel = JsonConvert.DeserializeObject <LogPacket>(payload);
                        _packetQueue.Enqueue(logEventModel);
                        break;
                    }
                }

                pullSocket.Close();
                _resetEvent.Set();
            }
        }
Example #8
0
        public void ContinousReceiveMessages()
        {
            var pullSocket = new PullSocket();

            pullSocket.Bind("tcp://*:" + RemoteServGr.NodePort);
            while (RemoteServGr.Running)
            {
                var msgJson = pullSocket.ReceiveFrameString();
                ReceiveMessage(msgJson);
            }
            var msg = new Message
            {
                MsgType       = MessageType.EndingProgram,
                SendingServer = RemoteServGr.NodeAddress
            };
            var messageWrapper = new RemoteDispatch(msg, null);

            RemoteServGr.SendQueue.Add(messageWrapper);
            pullSocket.Close();
        }
Example #9
0
 /// <summary>
 /// close socket
 /// </summary>
 public void Close()
 {
     _cancellationTokenSource?.Cancel();
     _receiveTask?.Wait();
     _puller.Close();
 }
Example #10
0
        private void FanInPubEntry(object n)
        {
            FansInPubRun f;
            string       name = (string)n;

            if (FunInPubRM.ContainsKey(name))
            {
                f = FunInPubRM[name];
            }
            else
            {
                Logging.logger.Error("FunInPubEntry get name failed " + name);
                return;
            }

            PullSocket      pull = new PullSocket();
            PublisherSocket pub  = new PublisherSocket();
            string          le   = "tcp://" + f.PullPoint.ip + ":" + f.PullPoint.port;
            string          pe   = "tcp://*:" + f.PubPoint.port;

            try
            {
                pull.Bind(le);
                pub.Bind(pe);
                f.pull = pull;
                f.pub  = pub;
            }
            catch (Exception err)
            {
                Logging.logger.Error(ModName + " bind funin socket failed " + le + " " + pe + " " + err.Message);
                throw (err);
            }
            string str;
            string outdata;
            bool   result;

            f.Working = true;
            while (f.Running)
            {
                str    = string.Empty;
                result = pull.TryReceiveFrameString(out str);

                outdata = string.Empty;
                if (result == true)
                {
                    try
                    {
                        outdata = Entry4FanInPubData(name, str);

                        if (outdata != null)
                        {
                            pub.SendFrame(outdata);
                        }
                    }
                    catch (Exception err)
                    {
                        Logging.logger.Error("exception occur " + name + err.Message);
                        continue;
                    }
                }

                DelayTime();
            }
            f.Working = false;
            pull.Close();
            pub.Close();
            return;
        }
Example #11
0
 public virtual void Stop()
 {
     Poller?.Stop();
     PullSocket?.Close();
 }