Example #1
0
 private void Send(IEnumerable <byte[]> message)
 {
     using (var en = message.GetEnumerator())
     {
         var hasMore = en.MoveNext();
         while (hasMore)
         {
             var data = en.Current;
             hasMore = en.MoveNext();
             _socket.Send(data, hasMore);
         }
     }
 }
Example #2
0
        protected override void SendRequest(IZmqSocket socket)
        {
            var buffer = _serializationStrategy.SerializeRequest(_requestMessage);

            socket.Send(buffer);
            // PerfCounters.IncrementSent()
        }
Example #3
0
        /// <summary>
        /// Sends the byte[] message and uses the specified flags to configure the sending behavior.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="message">The byte array to send</param>
        /// <param name="flags">Send flags configuring the sending operation</param>
        public static void Send(this IZmqSocket source, byte[] message, SendFlags flags)
        {
            bool hasMore   = (flags & SendFlags.SendMore) != 0;
            bool doNotWait = (flags & SendFlags.DoNotWait) != 0;

            source.Send(message, hasMore, doNotWait);
        }
		private void OnRequestReceived(byte[] message, IZmqSocket socket)
		{
			var reqMessage = _serializationStrategy.DeserializeRequest(message);

			ResponseMessage response = InternalDispatch(reqMessage);

			var buffer = _serializationStrategy.SerializeResponse(response);
			socket.Send(buffer);
		}
Example #5
0
        private void OnRequestReceived(byte[] message, IZmqSocket socket)
        {
            var reqMessage = _serializationStrategy.DeserializeRequest(message);

            ResponseMessage response = InternalDispatch(reqMessage);

            var buffer = _serializationStrategy.SerializeResponse(response);

            socket.Send(buffer);
        }
Example #6
0
        /// <summary>
        /// Sends a string message, converting to bytes using the
        /// encoding specified. If none, uses UTF8.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="message">The string message</param>
        /// <param name="encoding">If not specified, defaults to UTF8</param>
        /// <param name="hasMoreToSend">Flag indicating whether it's a multipart message</param>
        /// <param name="noWait">Indicates that the sock must send the message immediately</param>
        public static void Send(this IZmqSocket source, string message, Encoding encoding = null,
                                bool hasMoreToSend = false, bool noWait = false)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            encoding = encoding ?? Encoding.UTF8;
            var buffer = encoding.GetBytes(message);

            source.Send(buffer, hasMoreToSend, noWait);
        }
Example #7
0
        public static void Send(this IZmqSocket source, ArraySegment <byte> buffer, bool hasMoreToSend = false, bool noWait = false)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            var segment = new byte[buffer.Count];

            Buffer.BlockCopy(buffer.Array, buffer.Offset, segment, 0, segment.Length);

            source.Send(segment, hasMoreToSend, noWait);
        }