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


C# ZmqSocket.SendMore方法代码示例

本文整理汇总了C#中ZmqSocket.SendMore方法的典型用法代码示例。如果您正苦于以下问题:C# ZmqSocket.SendMore方法的具体用法?C# ZmqSocket.SendMore怎么用?C# ZmqSocket.SendMore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZmqSocket的用法示例。


在下文中一共展示了ZmqSocket.SendMore方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Send

        public void Send(ZmqSocket socket)
        {
            for (int index = frames.Count - 1; index > 0; index--)
            {
                socket.SendMore(frames[index]);
            }

            socket.Send(frames[0]);
        }
开发者ID:Jay-Krish,项目名称:zguide,代码行数:9,代码来源:zmsg.cs

示例2: relay

        private void relay(ZmqSocket source, ZmqSocket destination)
        {
            bool hasMore = true;

            while (hasMore)
            {
                // no buffer overflow safety here, need to add that
                var number = source.Receive(_buffer);
                hasMore = source.ReceiveMore;

                if (hasMore)
                {
                    destination.SendMore(_buffer.Take(number).ToArray());
                }
                else
                {
                    destination.Send(_buffer.Take(number).ToArray());
                }
            }
        }
开发者ID:swfenton,项目名称:ZeroMqTutorials,代码行数:20,代码来源:Broker.cs

示例3: AcceptDataAdditionRequest

        /// <summary>
        /// Handles incoming data "push" requests: the client sends data for us to add to local storage.
        /// </summary>
        private void AcceptDataAdditionRequest(string requesterIdentity, ZmqSocket socket)
        {
            //final message part: receive the DataAdditionRequest object
            int size;
            var ms = new MemoryStream();
            byte[] buffer = socket.Receive(null, TimeSpan.FromMilliseconds(10), out size);
            if (size <= 0) return;

            var request = MyUtils.ProtoBufDeserialize<DataAdditionRequest>(buffer, ms);

            //log the request
            Log(LogLevel.Info, string.Format("Received data push request for {0}.",
                request.Instrument.Symbol));

            //start building the reply
            socket.SendMore(requesterIdentity, Encoding.UTF8);
            socket.SendMore("PUSHREP", Encoding.UTF8);
            try
            {
                _broker.AddData(request);
                socket.Send("OK", Encoding.UTF8);
            }
            catch (Exception ex)
            {
                socket.SendMore("ERROR", Encoding.UTF8);
                socket.Send(ex.Message, Encoding.UTF8);
            }
        }
开发者ID:KeithNel,项目名称:qdms,代码行数:31,代码来源:HistoricalDataServer.cs

示例4: AcceptAvailableDataRequest

        /// <summary>
        /// Handles requests for information on data that is available in local storage
        /// </summary>
        private void AcceptAvailableDataRequest(string requesterIdentity, ZmqSocket socket)
        {
            //get the instrument
            int size;
            var ms = new MemoryStream();
            byte[] buffer = socket.Receive(null, TimeSpan.FromMilliseconds(10), out size);
            if (size <= 0) return;

            var instrument = MyUtils.ProtoBufDeserialize<Instrument>(buffer, ms);

            //log the request
            Log(LogLevel.Info, string.Format("Received local data storage info request for {0}.",
                instrument.Symbol));

            //and send the reply

            var storageInfo = _broker.GetAvailableDataInfo(instrument);
            socket.SendMore(requesterIdentity, Encoding.UTF8);
            socket.SendMore("AVAILABLEDATAREP", Encoding.UTF8);

            socket.SendMore(MyUtils.ProtoBufSerialize(instrument, ms));

            socket.SendMore(BitConverter.GetBytes(storageInfo.Count));
            foreach (StoredDataInfo sdi in storageInfo)
            {
                socket.SendMore(MyUtils.ProtoBufSerialize(sdi, ms));
            }
            socket.Send("END", Encoding.UTF8);
        }
开发者ID:KeithNel,项目名称:qdms,代码行数:32,代码来源:HistoricalDataServer.cs

示例5: RelayMessage

        private void RelayMessage(ZmqSocket source, ZmqSocket destination)
        {
            try
            {
                var buffer = new byte[4096];
                bool isProcessing = true;
                while (_routing && isProcessing)
                {

                    //int size = 0;
                    source.Receive(buffer);
                    if (IsStopCommand(Encoding.UTF8.GetString(buffer)))
                    {
                        _routing = false;
                        break;
                    }
                    else
                    {
                        if (source.ReceiveMore)
                            destination.SendMore(buffer);
                            //destination.SendMore(message, Encoding.UTF8);
                        else
                            destination.Send(buffer);
                            //destination.Send(message, Encoding.UTF8);

                        isProcessing = source.ReceiveMore;
                    }
                }
            }
            catch (ZeroMQ.ZmqException ex)
            {
                Logger.Instance.Debug(ex);
            }
        }
开发者ID:kadekcipta,项目名称:ZmqJsonRpc,代码行数:34,代码来源:Router.cs

示例6: Send

 public void Send(ZmqSocket publisher) 
 {
     publisher.SendMore(Key, Encoding.Unicode);
     publisher.SendMore(BitConverter.GetBytes(Sequence));
     publisher.Send(Body, Encoding.Unicode);
 }
开发者ID:Jay-Krish,项目名称:zguide,代码行数:6,代码来源:kvsimple.cs

示例7: ContractServer

        /// <summary>
        /// The main loop. Runs on its own thread. Accepts requests on the REP socket, gets results from the InstrumentManager,
        /// and sends them back right away.
        /// </summary>
        private void ContractServer()
        {
            var timeout = new TimeSpan(100000);
            _socket = _context.CreateSocket(SocketType.REP);
            _socket.Bind("tcp://*:" + _socketPort);
            var ms = new MemoryStream();
            List<Instrument> instruments;

            while (_runServer)
            {
                string request = _socket.Receive(Encoding.UTF8, timeout);
                if (request == null) continue;

                //if the request is for a search, receive the instrument w/ the search parameters and pass it to the searcher
                if (request == "SEARCH" && _socket.ReceiveMore)
                {
                    int size;
                    byte[] buffer = _socket.Receive(null, timeout, out size);
                    var searchInstrument = MyUtils.ProtoBufDeserialize<Instrument>(buffer, ms);

                    Log(LogLevel.Info, string.Format("Instruments Server: Received search request: {0}",
                        searchInstrument));

                    try
                    {
                        instruments = _instrumentManager.FindInstruments(null, searchInstrument);
                    }
                    catch (Exception ex)
                    {
                        Log(LogLevel.Error, string.Format("Instruments Server: Instrument search error: {0}",
                            ex.Message));
                        instruments = new List<Instrument>();
                    }
                }
                else if (request == "ALL") //if the request is for all the instruments, we don't need to receive anything else
                {
                    Log(LogLevel.Info, "Instruments Server: received request for list of all instruments.");
                    instruments = _instrumentManager.FindInstruments();
                }
                else if (request == "ADD") //request to add instrument
                {
                    int size;
                    byte[] buffer = _socket.Receive(null, timeout, out size);
                    var instrument = MyUtils.ProtoBufDeserialize<Instrument>(buffer, ms);

                    bool addResult;
                    try
                    {
                        addResult = InstrumentManager.AddInstrument(instrument);
                    }
                    catch (Exception ex)
                    {
                        addResult = false;
                        Log(LogLevel.Error, string.Format("Instruments Server: Instrument addition error: {0}",
                            ex.Message));
                    }
                    _socket.Send(addResult ? "SUCCESS" : "FAILURE", Encoding.UTF8);

                    continue;
                }
                else //no request = loop again
                {
                    continue;
                }

                byte[] uncompressed = MyUtils.ProtoBufSerialize(instruments, ms);//serialize the list of instruments
                ms.Read(uncompressed, 0, (int)ms.Length); //get the uncompressed data
                byte[] result = LZ4Codec.Encode(uncompressed, 0, (int)ms.Length); //compress it

                //before we send the result we must send the length of the uncompressed array, because it's needed for decompression
                _socket.SendMore(BitConverter.GetBytes(uncompressed.Length));

                //then finally send the results
                _socket.Send(result);
            }

            _socket.Dispose();
        }
开发者ID:KeithNel,项目名称:qdms,代码行数:82,代码来源:InstrumentsServer.cs


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