Esempio n. 1
0
        // Regarding the async modifier - see https://github.com/Code-Sharp/WampSharp/issues/122
        protected override async void OnMessageReceived(MessageWebSocket sender, MessageWebSocketMessageReceivedEventArgs args)
        {
            try
            {
                Stream stream = args.GetDataStream().AsStreamForRead();

                MemoryStream memoryStream = new MemoryStream();

                await stream.CopyToAsync(memoryStream);

                stream.Position = 0;

                WampMessage <TMessage> message = mBinaryBinding.Parse(stream);

                RaiseMessageArrived(message);
            }
            catch (Exception ex)
            {
                RaiseConnectionError(ex);

                if (mWebSocket != null)
                {
                    mWebSocket.Dispose();
                }
            }
        }
Esempio n. 2
0
        private void OnReceiveMessage(object sender, NetMQSocketEventArgs e)
        {
            var message      = e.Socket.ReceiveMultipartMessage();
            var connectionId = e.Socket is RouterSocket && message.FrameCount > 1 ? message.First.ToByteArray() : null;

            using (var ms = new MemoryStream(message.Last.Buffer, 0, message.Last.MessageSize, false))
                RaiseMessageArrived(_binding.Parse(ms));
        }
        protected override async Task <WampMessage <TMessage> > ParseMessage(WebSocketMessageReadStream readStream)
        {
            using (MemoryStream memoryStream = new MemoryStream())
            {
                await readStream.CopyToAsync(memoryStream).ConfigureAwait(false);

                byte[] bytes = memoryStream.ToArray();
                WampMessage <TMessage> result = mBinding.Parse(bytes);
                return(result);
            }
        }
Esempio n. 4
0
 public WampMessage <TMessage> Parse(byte[] raw)
 {
     return(mBinding.Parse(raw));
 }
        private void OnDataReceived(object sender, DataReceivedEventArgs e)
        {
            WampMessage <TMessage> message = mBinding.Parse(e.Data);

            RaiseMessageArrived(message);
        }
Esempio n. 6
0
        private void OnConnectionMessage(byte[] bytes)
        {
            WampMessage <TMessage> parsed = mBinding.Parse(bytes);

            RaiseMessageArrived(parsed);
        }