public WampMessage <JToken> Parse(byte[] raw)
        {
            using (MemoryStream memoryStream = new MemoryStream(raw, false))
            {
                using (MessagePackReader reader = new MessagePackReader(memoryStream))
                {
                    try
                    {
                        mLogger.Debug(() => string.Format("Trying to parse msgpack message: {0}",
                                                          Convert.ToBase64String(raw)));

                        JToken token = JToken.Load(reader);

                        mLogger.Debug(() => string.Format("Parsed msgpack message: {0}",
                                                          token.ToString(Formatting.None)));

                        WampMessage <JToken> message = mMessageFormatter.Parse(token);

                        return(message);
                    }
                    catch (Exception ex)
                    {
                        mLogger.ErrorFormat(ex, "Failed parsing msgpack message: {0}",
                                            Convert.ToBase64String(raw));

                        throw;
                    }
                }
            }
        }
Esempio n. 2
0
        private Mock <IWampServer <JToken> > CallHandleOnMock(IWampClient client, string message)
        {
            Mock <IWampServer <JToken> > mock =
                new Mock <IWampServer <JToken> >();

            JToken raw = JToken.Parse(message);

            IWampIncomingMessageHandler <JToken, IWampClient> handler =
                GetHandler(mock.Object);

            handler.HandleMessage(client, mMessageFormatter.Parse(raw));

            return(mock);
        }