NetMQ.Sockets.SubscriberSocket.Subscribe C# (CSharp) Method

Subscribe() public method

Subscribe this socket to the given 'topic' - which means enable this socket to receive messages that begin with this array of bytes.
public Subscribe ( byte topic ) : void
topic byte this specifies what byte-array prefix to subscribe to
return void
        public new virtual void Subscribe(byte[] topic)
        {
            SetSocketOption(ZmqSocketOption.Subscribe, topic);
        }

Same methods

SubscriberSocket::Subscribe ( string topic ) : void
SubscriberSocket::Subscribe ( string topic, Encoding encoding ) : void

Usage Example

コード例 #1
0
    /* =====================
     * UNITY PLAYER EVENT HOOKS
     * =====================
     */

    // Function called when Unity Player is loaded.
    public IEnumerator Start()
    {
        // Check if the program should use CLI arguments (with defaults)
        if (!Application.isEditor)
        {
            pose_host  = GetArg("-pose-host", pose_host_default);
            video_host = GetArg("-video-host", video_host_default);
        }

        // Init simple splash screen
        Text text_obj = splashScreen.GetComponentInChildren <Text>(true);

        text_obj.text = "FlightGoggles Simulation Environment" + Environment.NewLine +
                        flight_goggles_version + Environment.NewLine + Environment.NewLine +
                        "Waiting for client connection..." + Environment.NewLine + Environment.NewLine +
                        "Pose input socket:" + Environment.NewLine + pose_host + Environment.NewLine + Environment.NewLine +
                        "Video output socket:" + Environment.NewLine + video_host;

        splashScreen.SetActive(true);

        // Fixes for Unity/NetMQ conflict stupidity.
        AsyncIO.ForceDotNet.Force();
        socket_lock = new object();

        // Connect sockets
        Debug.Log("Creating sockets.");
        pull_socket = new NetMQ.Sockets.SubscriberSocket();
        pull_socket.Options.ReceiveHighWatermark = 90;
        pull_socket.Connect(pose_host);

        // Setup subscriptions.
        pull_socket.Subscribe("Pose");
        push_socket = new NetMQ.Sockets.PublisherSocket();
        push_socket.Connect(video_host);
        Debug.Log("Sockets bound.");

        // Initialize Internal State
        internal_state = new UnityState_t();

        // Do not try to do any processing this frame so that we can render our splash screen.
        internal_state.screenSkipFrames = 1;

        // Wait until end of frame to transmit images
        while (true)
        {
            // Wait until all rendering + UI is done.
            // Blocks until the frame is rendered.
            yield return(new WaitForEndOfFrame());

            // Check if this frame should be rendered.
            if (internal_state.readyToRender)
            {
                // Read the frame from the GPU backbuffer and send it via ZMQ.
                sendFrameOnWire();
            }
        }
    }
All Usage Examples Of NetMQ.Sockets.SubscriberSocket::Subscribe