public void GlobalSetup() { var resolver = new DefaultHubProtocolResolver(new List <IHubProtocol> { new DummyProtocol("protocol1"), new DummyProtocol("protocol2") }, NullLogger <DefaultHubProtocolResolver> .Instance); _protocol = new RedisProtocol(new DefaultHubMessageSerializer(resolver, new List <string>() { "protocol1", "protocol2" }, hubSupportedProtocols: null)); _groupCommand = new RedisGroupCommand(id: 42, serverName: "Server", GroupAction.Add, groupName: "group", connectionId: "connection"); // Because of the DummyProtocol, the args don't really matter _args = Array.Empty <object>(); _methodName = "Method"; _excludedConnectionIdsSmall = GenerateIds(2); _excludedConnectionIdsLarge = GenerateIds(20); _writtenAck = _protocol.WriteAck(42); _writtenGroupCommand = _protocol.WriteGroupCommand(_groupCommand); _writtenInvocationNoExclusions = _protocol.WriteInvocation(_methodName, _args, null); _writtenInvocationSmallExclusions = _protocol.WriteInvocation(_methodName, _args, _excludedConnectionIdsSmall); _writtenInvocationLargeExclusions = _protocol.WriteInvocation(_methodName, _args, _excludedConnectionIdsLarge); }
public byte[] WriteGroupCommand(RedisGroupCommand command) { // Written as a MessagePack 'arr' containing at least these items: // * An 'int': the Id of the command // * A 'str': The server name // * An 'int': The action (likely less than 0x7F and thus a single-byte fixnum) // * A 'str': The group name // * A 'str': The connection Id // Any additional items are discarded. var memoryBufferWriter = MemoryBufferWriter.Get(); try { var writer = new MessagePackWriter(memoryBufferWriter); writer.WriteArrayHeader(5); writer.Write(command.Id); writer.Write(command.ServerName); writer.Write((byte)command.Action); writer.Write(command.GroupName); writer.Write(command.ConnectionId); writer.Flush(); return(memoryBufferWriter.ToArray()); } finally { MemoryBufferWriter.Return(memoryBufferWriter); } }
public void GlobalSetup() { _protocol = new RedisProtocol(new [] { new DummyProtocol("protocol1"), new DummyProtocol("protocol2") }); _groupCommand = new RedisGroupCommand(id: 42, serverName: "Server", GroupAction.Add, groupName: "group", connectionId: "connection"); // Because of the DummyProtocol, the args don't really matter _args = Array.Empty <object>(); _methodName = "Method"; _excludedIdsSmall = GenerateIds(2); _excludedIdsLarge = GenerateIds(20); _writtenAck = _protocol.WriteAck(42); _writtenGroupCommand = _protocol.WriteGroupCommand(_groupCommand); _writtenInvocationNoExclusions = _protocol.WriteInvocation(_methodName, _args, null); _writtenInvocationSmallExclusions = _protocol.WriteInvocation(_methodName, _args, _excludedIdsSmall); _writtenInvocationLargeExclusions = _protocol.WriteInvocation(_methodName, _args, _excludedIdsLarge); }