Пример #1
0
 /// <summary>
 ///     Create a new NetMQSocket with the given <see cref="SocketBase" />.
 /// </summary>
 /// <param name="socketHandle">a SocketBase object to assign to the new socket</param>
 internal NetMQSocket([NotNull] SocketBase socketHandle)
 {
     this.m_netMqSelector   = new NetMQSelector();
     this.SocketHandle      = socketHandle;
     this.Options           = new SocketOptions(this);
     this.m_socketEventArgs = new NetMQSocketEventArgs(this);
 }
Пример #2
0
        private void OnShimReady(object sender, NetMQSocketEventArgs e)
        {
            string command = e.Socket.ReceiveFrameString();

            if (command == NetMQActor.EndShimMessage)
            {
                this.m_poller.Stop();
            }
        }
Пример #3
0
            private void OnPipeReady(object sender, NetMQSocketEventArgs e)
            {
                NetMQMessage message = this.m_pipe.ReceiveMultipartMessage();

                string command = message.Pop().ConvertToString();

                switch (command)
                {
                case NetMQBeacon.ConfigureCommand:
                    string interfaceName = message.Pop().ConvertToString();
                    int    port          = message.Pop().ConvertToInt32();
                    this.Configure(interfaceName, port);
                    break;

                case NetMQBeacon.PublishCommand:
                    this.m_transmit           = message.Pop();
                    this.m_pingTimer.Interval = message.Pop().ConvertToInt32();
                    this.m_pingTimer.Enable   = true;
                    this.SendUdpFrame(this.m_transmit);
                    break;

                case NetMQBeacon.SilenceCommand:
                    this.m_transmit         = null;
                    this.m_pingTimer.Enable = false;
                    break;

                case NetMQBeacon.SubscribeCommand:
                    this.m_filter = message.Pop();
                    break;

                case NetMQBeacon.UnsubscribeCommand:
                    this.m_filter = null;
                    break;

                case NetMQActor.EndShimMessage:
                    this.m_poller.Stop();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
Пример #4
0
        /// <summary>
        ///     Create a new NetMQSocket with the given <see cref="ZmqSocketType" />.
        /// </summary>
        /// <param name="socketType">Type of socket to create</param>
        /// <param name="connectionString"></param>
        /// <param name="defaultAction"></param>
        internal NetMQSocket(ZmqSocketType socketType, string connectionString, DefaultAction defaultAction)
        {
            this.SocketHandle      = NetMQConfig.Context.CreateSocket(socketType);
            this.m_netMqSelector   = new NetMQSelector();
            this.Options           = new SocketOptions(this);
            this.m_socketEventArgs = new NetMQSocketEventArgs(this);

            this.Options.Linger = NetMQConfig.Linger;

            if (!string.IsNullOrEmpty(connectionString))
            {
                IEnumerable <string> endpoints =
                    connectionString.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(a => a.Trim()).Where(a => !string.IsNullOrEmpty(a));

                foreach (string endpoint in endpoints)
                {
                    if (endpoint[0] == '@')
                    {
                        this.Bind(endpoint.Substring(1));
                    }
                    else if (endpoint[0] == '>')
                    {
                        this.Connect(endpoint.Substring(1));
                    }
                    else if (defaultAction == DefaultAction.Connect)
                    {
                        this.Connect(endpoint);
                    }
                    else
                    {
                        this.Bind(endpoint);
                    }
                }
            }
        }
Пример #5
0
 private void OnBackendReady(object sender, NetMQSocketEventArgs e)
 {
     Proxy.ProxyBetween(this.m_backend, this.m_frontend, this.m_controlOut);
 }
Пример #6
0
 private void OnSocketEventsChanged(object sender, NetMQSocketEventArgs e)
 {
     // when the sockets SendReady or ReceiveReady changed we marked the poller as dirty in order to reset the poll events
     this.m_isPollSetDirty = true;
 }
Пример #7
0
        private void OnSocketReady(object sender, NetMQSocketEventArgs e)
        {
            NetMQMessage message = this.m_receiveSocket.ReceiveMultipartMessage();

            this.m_handler(this.m_receiveSocket, message);
        }
Пример #8
0
 private void OnReceiveReady(object sender, NetMQSocketEventArgs e)
 {
     this.m_eventDelegator.Fire(this, new NetMQQueueEventArgs <T>(this));
 }