本文整理汇总了C#中ZmqSocket.Subscribe方法的典型用法代码示例。如果您正苦于以下问题:C# ZmqSocket.Subscribe方法的具体用法?C# ZmqSocket.Subscribe怎么用?C# ZmqSocket.Subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZmqSocket
的用法示例。
在下文中一共展示了ZmqSocket.Subscribe方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Subscriber
public Subscriber(string _guid, string _targetGuid, string _host, int _port, ZmqContext _ctx)
{
guid = _guid;
targetGuid = _targetGuid;
host = _host;
port = _port;
if (port > 0)
connectionString = String.Format("tcp://{0}:{1}", host, port);
else
connectionString = String.Format("inproc://{0}", targetGuid.ToLower());
buf = new byte[1024 * 1024];
subscribeChannels = new List<string>();
if (_ctx == null)
{
shardedCtx = false;
ctx = ZmqContext.Create();
}
else
{
shardedCtx = true;
ctx = _ctx;
}
socket = ctx.CreateSocket(SocketType.SUB);
if (log.IsDebugEnabled) log.DebugFormat("Subscriber connecting to: `{0}`", connectionString);
socket.Subscribe(Proxy.StringToByteArray(guid));
socket.Connect(connectionString);
socket.ReceiveHighWatermark = 1000000;
socket.ReceiveBufferSize = 128 * 1024;
lastActiveTime = Proxy.Unixtimestamp();
log.InfoFormat("Connected successfuly to: `{0}` `{1}`", connectionString, targetGuid);
}
示例2: ConnectSocket
public void ConnectSocket()
{
if (_socket != null)
{
return;
}
_socket = _context.CreateSocket(SocketType.SUB);
_socket.Subscribe(new byte[] {});
_socket.Connect(_endpoint);
}
示例3: Subscriber
public Subscriber(string _connectionString, string _proxyGuid, string ESBClientGuid)
{
connectionString = _connectionString;
buf = new byte[65536];
ctx = ZmqContext.Create();
socket = ctx.CreateSocket(SocketType.SUB);
var binGuid = ESBClient.stringToByteArray(ESBClientGuid);
channels = new List<string>();
//socket.SubscribeAll();
//socket.Subscribe(ASCIIEncoding.ASCII.GetBytes(""));
socket.Subscribe(binGuid);
socket.Connect(connectionString);
socket.ReceiveHighWatermark = 100000;
socket.ReceiveBufferSize = 256 * 1024;
}