Search code examples
c#zeromqnetmq

ZeroMq/NetMQ Cannot find extension ReceiveFrameBytes from ReceivingSocketExtensions


When publishing/subscribing in NetMQ how can i receive bytes.

I am trying to use the extension byte[] ReceiveFrameBytes() from ReceivingSocketExtensions, but I just cannot see it intellisense.

I am using NetMQ which is the container namespace for the extension. I am using the Nuget NetMq package (not sure if its relevant - I am assuming its same as github version)

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 ?
            }             
        }
    }   
}

To solve it using NUGET package use

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

Solution

  • ReceiveFrameBytes is new API only available in latest pre-release from nuget or building from master. Try to use Receive or ReceiveBytes.