public ZmqClient() { context = NetMQContext.Create(); subSocket = context.CreateSubscriberSocket(); subSocket.Options.ReceiveHighWatermark = 1000; subSocket.Connect(MarketDataSettings.RealTimeUpdateServerAddress); }
public MessageHelper(string address, string topic) { _context = NetMQContext.Create(); _subscribeSocket = _context.CreateSubscriberSocket(); _subscribeSocket.Connect(address); _subscribeSocket.ReceiveReady += SubscribeSocketOnReceiveReady; _subscribeSocket.Subscribe(topic); _poller = new Poller(); _poller.AddSocket(_subscribeSocket); Task.Factory.StartNew(_poller.Start); }
public Subscriber(params string[] messageKeys) { if (messageKeys != null && messageKeys.Length > 0) subscribeTo.AddRange(messageKeys.ToList()); context = NetMQContext.Create(); server = context.CreateSubscriberSocket(); server.Connect("tcp://127.0.0.1:5003"); subscribeTo.ForEach(server.Subscribe); Thread.Sleep(500); }
public void Start(string serverAddress, int serverPublishPort, int clientId, Action<ServerToClientMessage> messageHandler) { this.messageHandler = messageHandler; ctx = NetMQContext.Create(); subscribeSocket = ctx.CreateSubscriberSocket(); subscribeSocket.Connect(string.Format("tcp://{0}:{1}", serverAddress, serverPublishPort)); subscribeSocket.Subscribe(clientId.ToString()); subscribeSocket.Subscribe("a"); isRunning = true; receiveThread = new Thread(Run); receiveThread.Name = "ClientMessageListenThread"; receiveThread.Start(); logger.Info("Server message subscriber started"); }
// initialized sprites void Start() { AsyncIO.ForceDotNet.Force(); calImages = new Sprite[10]; calImages[0] = Resources.Load<Sprite>("notargets"); calImages[1] = Resources.Load<Sprite>("targetTL"); calImages[2] = Resources.Load<Sprite>("targetTM"); calImages[3] = Resources.Load<Sprite>("targetTR"); calImages[4] = Resources.Load<Sprite>("targetML"); calImages[5] = Resources.Load<Sprite>("targetMM"); calImages[6] = Resources.Load<Sprite>("targetMR"); calImages[7] = Resources.Load<Sprite>("targetBL"); calImages[8] = Resources.Load<Sprite>("targetBM"); calImages[9] = Resources.Load<Sprite>("targetBR"); calCount = 0; curCount = 0; gameObject.GetComponent<Image> ().sprite = calImages [calCount]; //max coords 1180*564 transX = 0; transY = 0; targetPrefab = GameObject.FindGameObjectWithTag ("RaycastTarget"); targetPrefab.SetActive (false); targetPrefab.layer = 2;//ignore raycast layer isVisible = false; AsyncIO.ForceDotNet.Force(); //setup sockets //hangs???? //http://forum.unity3d.com/threads/netmq-basic.298104/ //must compile myself //https://github.com/zeromq/netmq/issues/98 context = NetMQContext.Create (); server = context.CreatePublisherSocket (); server.Bind("tcp://127.0.0.1:5556"); client = context.CreateSubscriberSocket (); client.Connect("tcp://127.0.0.1:5556"); client.Subscribe ("coord"); Debug.Log (System.Environment.Version); /*server.SendMore("coord").Send ("200 200"); string top = client.ReceiveString (); string message = client.ReceiveString (); Debug.Log (message); string[] coord = message.Split (); transX = int.Parse (coord [0]); transY = int.Parse (coord [1]);*/ }
private void SetUpAddSubscriberCountChannel(NetMQContext zmqContext) { this.AddSubscriberCountChannel = zmqContext.CreateSubscriberSocket(); this.AddSubscriberCountChannel.Connect(Pipe.SubscribeAddressClient); this.AddSubscriberCountChannel.Subscribe(Pipe.ControlChannelEncoding.GetBytes(Pipe.SubscriberCountAddress)); }