public byte[] Format(WampMessage <object> message)
        {
            object[] array = mMessageFormatter.Format(message);

            if (mLogger.IsDebugEnabled())
            {
                mLogger.DebugFormat("Formatting message: {Message}",
                                    JToken.FromObject(array).ToString(Formatting.None));
            }

            using (MemoryStream memoryStream = new MemoryStream())
            {
                using (MessagePackWriter writer = new MessagePackWriter(memoryStream)
                {
                    WriteDateTimeAsString = true
                })
                {
                    mSerializer.Serialize(writer, array);
                    memoryStream.Position = 0;
                    byte[] result = memoryStream.ToArray();

                    if (mLogger.IsDebugEnabled())
                    {
                        mLogger.DebugFormat("Formatted message: {MsgPackMessage}",
                                            Convert.ToBase64String(result));
                    }

                    return(result);
                }
            }
        }
Example #2
0
        public byte[] Format(WampMessage <object> message)
        {
            object[] array = mMessageFormatter.Format(message);

            mLogger.Debug(() => string.Format("Formatting message: {0}",
                                              JToken.FromObject(array).ToString(Formatting.None)));

            using (MemoryStream memoryStream = new MemoryStream())
            {
                using (MessagePackWriter writer = new MessagePackWriter(memoryStream))
                {
                    mSerializer.Serialize(writer, array);
                    memoryStream.Position = 0;
                    byte[] result = memoryStream.ToArray();

                    mLogger.Debug(() => string.Format("Formatted message: {0}",
                                                      Convert.ToBase64String(result)));

                    return(result);
                }
            }
        }