private void WriteInvocationMessage(InvocationMessage message, JsonTextWriter writer) { WriteInvocationId(message, writer); writer.WritePropertyName(TargetPropertyName); writer.WriteValue(message.Target); WriteArguments(message.Arguments, writer); }
private void WriteInvocationMessage(InvocationMessage message, Utf8JsonWriter writer) { WriteInvocationId(message, writer); writer.WriteString(TargetPropertyNameBytes, message.Target); WriteArguments(message.Arguments, writer); WriteStreamIds(message.StreamIds, writer); }
public async Task SignalRInvocationMethodExecutorTest(string protocolName) { var resolver = new SignalRRequestResolver(false); var methodExecutor = new SignalRInvocationMethodExecutor(resolver, new ExecutionContext { Executor = _triggeredFunctionExecutor }); var hub = Guid.NewGuid().ToString(); var category = Guid.NewGuid().ToString(); var @event = Guid.NewGuid().ToString(); var connectionId = Guid.NewGuid().ToString(); var arguments = new object[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; var message = new Microsoft.AspNetCore.SignalR.Protocol.InvocationMessage(Guid.NewGuid().ToString(), @event, arguments); var protocol = protocolName == "json" ? (IHubProtocol) new JsonHubProtocol() : new MessagePackHubProtocol(); var contentType = protocolName == "json" ? Constants.JsonContentType : Constants.MessagePackContentType; var bytes = new ReadOnlySequence <byte>(protocol.GetMessageBytes(message)); ReadOnlySequence <byte> payload; if (protocolName == "json") { TextMessageParser.TryParseMessage(ref bytes, out payload); } else { BinaryMessageParser.TryParseMessage(ref bytes, out payload); } var request = TestHelpers.CreateHttpRequestMessage(hub, category, @event, connectionId, contentType: contentType, content: payload.ToArray()); await methodExecutor.ExecuteAsync(request); var result = await _triggeredFunctionDataTcs.Task; var triggerData = (SignalRTriggerEvent)result.TriggerValue; Assert.NotNull(triggerData.TaskCompletionSource); Assert.Equal(hub, triggerData.Context.Hub); Assert.Equal(category, triggerData.Context.Category); Assert.Equal(@event, triggerData.Context.Event); Assert.Equal(connectionId, triggerData.Context.ConnectionId); Assert.Equal(hub, triggerData.Context.Hub); Assert.Equal(arguments, triggerData.Context.Arguments); }
private void WriteInvocationMessage(InvocationMessage message, ref MessagePackWriter writer) { writer.WriteArrayHeader(6); writer.Write(HubProtocolConstants.InvocationMessageType); PackHeaders(message.Headers, ref writer); if (string.IsNullOrEmpty(message.InvocationId)) { writer.WriteNil(); } else { writer.Write(message.InvocationId); } writer.Write(message.Target); writer.WriteArrayHeader(message.Arguments.Length); foreach (var arg in message.Arguments) { WriteArgument(arg, ref writer); } WriteStreamIds(message.StreamIds, ref writer); }