Example #1
0
        protected override IDuplexProtocolMessage TryParseDuplexMessage(StreamMessage message)
        {
            DuplexStreamMessage duplexMessage;

            return(DuplexStreamMessage.TryParse(message, protocol, out duplexMessage)
           ? duplexMessage
           : null);
        }
Example #2
0
        public static bool TryParse(StreamMessage message, StreamQbservableProtocol protocol, out DuplexStreamMessage duplexMessage)
        {
            Contract.Requires(message != null);
            Contract.Requires(protocol != null);
            Contract.Ensures(Contract.Result <bool>() == (Contract.ValueAtReturn(out duplexMessage) != null));

            switch (message.Kind)
            {
            case QbservableProtocolMessageKind.DuplexInvoke:
            case QbservableProtocolMessageKind.DuplexResponse:
            case QbservableProtocolMessageKind.DuplexSubscribeResponse:
            case QbservableProtocolMessageKind.DuplexGetEnumeratorResponse:
            case QbservableProtocolMessageKind.DuplexEnumeratorResponse:
            case QbservableProtocolMessageKind.DuplexOnNext:
            // The following cases are handled the same as the above cases to ensure that extra data is read, though it's unexpected.
            case QbservableProtocolMessageKind.DuplexOnCompleted:
            case QbservableProtocolMessageKind.DuplexSubscribe:
            case QbservableProtocolMessageKind.DuplexDisposeSubscription:
            case QbservableProtocolMessageKind.DuplexGetEnumerator:
            case QbservableProtocolMessageKind.DuplexMoveNext:
            case QbservableProtocolMessageKind.DuplexResetEnumerator:
            case QbservableProtocolMessageKind.DuplexDisposeEnumerator:
                duplexMessage = new DuplexStreamMessage(
                    message.Kind,
                    BitConverter.ToInt64(message.Data, 0),
                    protocol.Deserialize <object>(message.Data, offset: DuplexCallbackId.Size),
                    message.Data,
                    message.Length);
                return(true);

            case QbservableProtocolMessageKind.DuplexErrorResponse:
            case QbservableProtocolMessageKind.DuplexGetEnumeratorErrorResponse:
            case QbservableProtocolMessageKind.DuplexEnumeratorErrorResponse:
            case QbservableProtocolMessageKind.DuplexOnError:
                duplexMessage = new DuplexStreamMessage(
                    message.Kind,
                    BitConverter.ToInt64(message.Data, 0),
                    ExceptionDispatchInfo.Capture(protocol.Deserialize <Exception>(message.Data, offset: DuplexCallbackId.Size)),
                    message.Data,
                    message.Length);
                return(true);

            default:
                duplexMessage = null;
                return(false);
            }
        }
Example #3
0
 protected override StreamMessage CreateResetEnumerator(DuplexCallbackId enumeratorId)
 => DuplexStreamMessage.CreateResetEnumerator(enumeratorId, protocol);
Example #4
0
 protected override StreamMessage CreateMoveNext(DuplexCallbackId enumeratorId)
 => DuplexStreamMessage.CreateMoveNext(enumeratorId, protocol);
Example #5
0
 protected override StreamMessage CreateInvoke(DuplexCallbackId clientId, object[] arguments)
 => DuplexStreamMessage.CreateInvoke(clientId, arguments, protocol);
Example #6
0
 protected override StreamMessage CreateDisposeSubscription(int subscriptionId)
 => DuplexStreamMessage.CreateDisposeSubscription(subscriptionId, protocol);
Example #7
0
 protected override StreamMessage CreateSubscribe(DuplexCallbackId clientId)
 => DuplexStreamMessage.CreateSubscribe(clientId, protocol);
Example #8
0
 protected override StreamMessage CreateDisposeEnumerator(int enumeratorId)
 => DuplexStreamMessage.CreateDisposeEnumerator(enumeratorId, protocol);
Example #9
0
 protected override StreamMessage CreateEnumeratorError(DuplexCallbackId id, ExceptionDispatchInfo error)
 => DuplexStreamMessage.CreateEnumeratorError(id, error, protocol);
Example #10
0
 protected override StreamMessage CreateGetEnumeratorResponse(DuplexCallbackId id, int clientEnumeratorId)
 => DuplexStreamMessage.CreateGetEnumeratorResponse(id, clientEnumeratorId, protocol);
Example #11
0
 protected override StreamMessage CreateEnumeratorResponse(DuplexCallbackId id, bool result, object current)
 => DuplexStreamMessage.CreateEnumeratorResponse(id, result, current, protocol);
Example #12
0
 protected override StreamMessage CreateOnCompleted(DuplexCallbackId id)
 => DuplexStreamMessage.CreateOnCompleted(id, protocol);
Example #13
0
 protected override StreamMessage CreateOnNext(DuplexCallbackId id, object value)
 => DuplexStreamMessage.CreateOnNext(id, value, protocol);
Example #14
0
 protected override StreamMessage CreateSubscribeResponse(DuplexCallbackId id, int clientSubscriptionId)
 => DuplexStreamMessage.CreateSubscribeResponse(id, clientSubscriptionId, protocol);
Example #15
0
 protected override StreamMessage CreateErrorResponse(DuplexCallbackId id, ExceptionDispatchInfo error)
 => DuplexStreamMessage.CreateErrorResponse(id, error, protocol);
Example #16
0
 protected override StreamMessage CreateResponse(DuplexCallbackId id, object result)
 => DuplexStreamMessage.CreateResponse(id, result, protocol);