예제 #1
0
        private void WriteInvocationMessage(InvocationMessage message, JsonTextWriter writer)
        {
            WriteInvocationId(message, writer);
            writer.WritePropertyName(TargetPropertyName);
            writer.WriteValue(message.Target);

            WriteArguments(message.Arguments, writer);
        }
예제 #2
0
 private void WriteInvocationMessage(InvocationMessage invocationMessage, Packer packer)
 {
     packer.PackArrayHeader(5);
     packer.Pack(InvocationMessageType);
     packer.PackString(invocationMessage.InvocationId);
     packer.Pack(invocationMessage.NonBlocking);
     packer.PackString(invocationMessage.Target);
     packer.PackObject(invocationMessage.Arguments, _serializationContext);
 }
예제 #3
0
        private void WriteInvocationMessage(InvocationMessage message, JsonTextWriter writer)
        {
            writer.WriteStartObject();
            WriteHubInvocationMessageCommon(message, writer, HubProtocolConstants.InvocationMessageType);
            writer.WritePropertyName(TargetPropertyName);
            writer.WriteValue(message.Target);

            WriteArguments(message.Arguments, writer);

            writer.WriteEndObject();
        }
예제 #4
0
 private void WriteInvocationMessage(InvocationMessage invocationMessage, Packer packer)
 {
     packer.PackArrayHeader(4);
     packer.Pack(HubProtocolConstants.InvocationMessageType);
     if (string.IsNullOrEmpty(invocationMessage.InvocationId))
     {
         packer.PackNull();
     }
     else
     {
         packer.PackString(invocationMessage.InvocationId);
     }
     packer.PackString(invocationMessage.Target);
     packer.PackObject(invocationMessage.Arguments, _serializationContext);
 }
예제 #5
0
 private void WriteInvocationMessage(InvocationMessage message, Packer packer)
 {
     packer.PackArrayHeader(5);
     packer.Pack(HubProtocolConstants.InvocationMessageType);
     PackHeaders(packer, message.Headers);
     if (string.IsNullOrEmpty(message.InvocationId))
     {
         packer.PackNull();
     }
     else
     {
         packer.PackString(message.InvocationId);
     }
     packer.PackString(message.Target);
     packer.PackArrayHeader(message.Arguments.Length);
     foreach (var arg in message.Arguments)
     {
         packer.PackObject(arg, SerializationContext);
     }
 }
예제 #6
0
        private void WriteInvocationMessage(InvocationMessage message, JsonTextWriter writer)
        {
            writer.WriteStartObject();
            WriteHubMessageCommon(message, writer, InvocationMessageType);
            writer.WritePropertyName(TargetPropertyName);
            writer.WriteValue(message.Target);

            if (message.NonBlocking)
            {
                writer.WritePropertyName(NonBlockingPropertyName);
                writer.WriteValue(message.NonBlocking);
            }

            writer.WritePropertyName(ArgumentsPropertyName);
            writer.WriteStartArray();
            foreach (var argument in message.Arguments)
            {
                _payloadSerializer.Serialize(writer, argument);
            }
            writer.WriteEndArray();

            writer.WriteEndObject();
        }
예제 #7
0
        private InvocationMessage BindInvocationMessage(JObject json, IInvocationBinder binder)
        {
            var invocationId = JsonUtils.GetOptionalProperty <string>(json, InvocationIdPropertyName, JTokenType.String);
            var target       = JsonUtils.GetRequiredProperty <string>(json, TargetPropertyName, JTokenType.String);

            var args = JsonUtils.GetRequiredProperty <JArray>(json, ArgumentsPropertyName, JTokenType.Array);

            var paramTypes = binder.GetParameterTypes(target);

            InvocationMessage message;

            try
            {
                var arguments = BindArguments(args, paramTypes);
                message = new InvocationMessage(invocationId, target, argumentBindingException: null, arguments: arguments);
            }
            catch (Exception ex)
            {
                message = new InvocationMessage(invocationId, target, ExceptionDispatchInfo.Capture(ex));
            }
            ReadHeaders(json, message.Headers);
            return(message);
        }