Exemple #1
0
    NetMQMessage sendRequest(RequestSocket socket, Dictionary <string, object> data)
    {
        NetMQMessage m = new NetMQMessage();

        m.Append("notify." + data["subject"]);

        using (var byteStream = new MemoryStream())
        {
            var ctx = new SerializationContext();
            ctx.CompatibilityOptions.PackerCompatibilityOptions = MsgPack.PackerCompatibilityOptions.None;
            var ser = MessagePackSerializer.Get <object>(ctx);
            ser.Pack(byteStream, data);
            m.Append(byteStream.ToArray());
        }

        socket.SendMultipartMessage(m);
        timeout = new System.TimeSpan(0, 0, 0, 1);

        NetMQMessage recievedMsg;

        recievedMsg = socket.ReceiveMultipartMessage();

        string msgType = recievedMsg[0].ConvertToString();

        if (recievedMsg.FrameCount > 1)
        {
            MsgPack.UnpackingResult <MsgPack.MessagePackObject> message = MsgPack.Unpacking.UnpackObject(recievedMsg[1].ToByteArray());
            MsgPack.MessagePackObject mmap = message.Value;
        }

        return(recievedMsg);
    }
Exemple #2
0
        public static UnpackingResult <string> UnpackString(byte[] source, int offset, Encoding encoding)
        {
            UnpackingResult <string> result2;

            if (encoding == null)
            {
                throw new ArgumentNullException("encoding");
            }
            try
            {
                UnpackingResult <byte[]> result = UnpackBinary(source, offset);
                string introduced4 = encoding.GetString(result.Value, 0, result.Value.Length);
                result2 = new UnpackingResult <string>(introduced4, result.ReadCount);
            }
            catch (DecoderFallbackException exception)
            {
                throw NewInvalidEncodingException(encoding, exception);
            }
            return(result2);
        }
 /// <summary>
 ///		Compare two instances are equal.
 /// </summary>
 /// <param name="other"><see cref="UnpackingResult&lt;T&gt;"/> instance.</param>
 /// <returns>
 ///		Whether value of <paramref name="other"/> is equal to this instance or not.
 /// </returns>
 public bool Equals(UnpackingResult <T> other)
 {
     return(this._readCount == other._readCount && EqualityComparer <T> .Default.Equals(this._value, other._value));
 }