2015-08-28 22 views
0

在NetMQ中發佈/訂閱時,如何接收字節。ZeroMq/NetMQ無法從ReceivingSocketExtensions中找到擴展名ReceiveFrameBytes

我想從ReceivingSocketExtensions使用擴展字節[] ReceiveFrameBytes(),但我無法看到它的intellisense。

我正在使用NetMQ,它是擴展的容器名稱空間。我使用的NuGet NetMq包(不知道其相關的 - 我假設它作爲GitHub的版本相同)

http://netmq.readthedocs.org/en/latest/receiving-sending/

namespace WhoCares 
{ 
    using NetMQ; // the extension are in this namespace? 
    using System; 
    using System.Collections.Generic; 
    using System.IO; 
    using System.Linq; 
    using System.Text; 
    using System.Threading; 

    public class Subscriber 
    { 
     private Thread  _coreThread; 
     private NetMQContext _context; 
     private NetMQSocket _socket; 

     public bool IsRunning { get; private set; } 

     public void Run() 
     {    
      if (IsRunning) 
       throw new InvalidOperationException("Already running"); 

      _context = NetMQContext.Create(); 
      _socket = _context.CreateSubscriberSocket(); 
      _socket.Options.ReceiveHighWatermark = 1000; 
      _socket.Connect("tcp://localhost:12345"); 
      _socket.Subscribe("TopicA"); 

      IsRunning = true; 

      Core(); 
     } 


     private void Core() 
     { 
      _coreThread = Thread.CurrentThread; 

      while (true) 
      {    
       string messageReceived = _socket.ReceiveString(); 
       string bytesReceived = _socket.ReceiveString(); // I dont want a string..im sending bytesReceived 

       // i want to use 
       byte[] _socket.ReceiveFrameBytes();// COMPILER ERROR.. ITS IN THE EXTENSION ? 
      }    
     } 
    } 
} 

要使用NuGet包使用

_socket.ReceiveMessage().Pop().ToByteArray() 

回答

1

ReceiveFrameBytes解決問題是最新的API,僅在nuget最新的預發佈版本或主版本中提供。嘗試使用Receive或ReceiveBytes。