当前位置: 首页>>代码示例>>C#>>正文


C# ZmqSocket.Subscribe方法代码示例

本文整理汇总了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);
        }
开发者ID:h0x91b,项目名称:ESB-csharp-server,代码行数:33,代码来源:Subscriber.cs

示例2: ConnectSocket

 public void ConnectSocket()
 {
     if (_socket != null)
     {
         return;
     }
     _socket = _context.CreateSocket(SocketType.SUB);
     _socket.Subscribe(new byte[] {});
     _socket.Connect(_endpoint);
 }
开发者ID:modulexcite,项目名称:graveyard,代码行数:10,代码来源:ZmqSubscriber.cs

示例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;
        }
开发者ID:h0x91b,项目名称:ESB-csharp-driver,代码行数:16,代码来源:ESBClient.cs


注:本文中的ZmqSocket.Subscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。