本文整理汇总了C#中NetMQSocket.Subscribe方法的典型用法代码示例。如果您正苦于以下问题:C# NetMQSocket.Subscribe方法的具体用法?C# NetMQSocket.Subscribe怎么用?C# NetMQSocket.Subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetMQSocket
的用法示例。
在下文中一共展示了NetMQSocket.Subscribe方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MessageHelper
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);
}
示例2: Start
// 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]);*/
}
示例3: Execute
public void Execute(NetMQSocket socket)
{
#pragma warning disable 618
socket.Subscribe(_topic);
#pragma warning restore 618
}