Ejemplo n.º 1
0
        public void ReadSingleMessage()
        {
            var data = new ReadOnlySequence <byte>(_binaryInput);

            if (!_hubProtocol.TryParseMessage(ref data, _binder, out _))
            {
                throw new InvalidOperationException("Failed to read message");
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 接收到服务器消息的处理事件具体实现
 /// </summary>
 /// <param name="message">接收的服务器消息</param>
 private void ReceiveLoopAsync(string message)
 {
     try
     {
         if (_protocol.TryParseMessage(message, out HubMessage hubMessage))
         {
             ProcessMessages(hubMessage);
         }
     }
     catch (Exception e)
     {
         Log.Error("处理接收消息出错", e);
     }
 }
Ejemplo n.º 3
0
        private static bool TryParse(IHubProtocol protocol, IInvocationBinder[] binders, ref ReadOnlySequence <byte> buffer, out HubMessage message)
        {
            ReadOnlySequence <byte> seq = buffer;

            message = null;
            foreach (var binder in binders)
            {
                seq = buffer;
                if (protocol.TryParseMessage(ref seq, binder, out message) && !(message is InvocationBindingFailureMessage))
                {
                    buffer = seq;
                    return(true);
                }
            }
            buffer = seq;
            return(false);
        }
Ejemplo n.º 4
0
 public bool TryParseMessage(ref ReadOnlySequence <byte> input, IInvocationBinder binder, out HubMessage message)
 {
     return(_innerProtocol.TryParseMessage(ref input, binder, out message));
 }