internal async ValueTask ProcessConnection(RabbitMQProtocolReader protocol, FrameHeader header, MethodHeader method, CancellationToken token = default) { if (header.Channel != 0) { ReaderThrowHelper.ThrowIfFrameTypeMissmatch(); } switch (method.MethodId) { case 10: { var serverConf = await protocol.ReadStartAsync(token).ConfigureAwait(false); await _connectionHandler.OnStartAsync(serverConf).ConfigureAwait(false); break; } case 30: { var tuneConf = await protocol.ReadTuneMethodAsync(token).ConfigureAwait(false); await _connectionHandler.OnTuneAsync(tuneConf).ConfigureAwait(false); break; } case 41: { var result = await protocol.ReadConnectionOpenOkAsync(token).ConfigureAwait(false); await _connectionHandler.OnOpenOkAsync(); break; } case 50: //close { var closeInfo = await protocol.ReadCloseAsync(token).ConfigureAwait(false); await _connectionHandler.OnCloseAsync(closeInfo).ConfigureAwait(false); break; } case 51: //close-ok { var result = await protocol.ReadCloseOkAsync(token).ConfigureAwait(false); await _connectionHandler.OnCloseOkAsync().ConfigureAwait(false); break; } default: throw new RabbitMQMethodException(nameof(ProcessConnection), method.ClassId, method.MethodId); } }
public bool ReadValue(out object value) { value = default; if (!ReadOctet(out byte type)) { return(false); } switch ((char)type) { case 'F': { var tryRead = ReadTable(out Dictionary <string, object> table); value = table; return(tryRead); } case 't': { var tryRead = ReadBool(out bool boolValue); value = boolValue; return(tryRead); } case 's': { var tryRead = ReadShortStr(out string stringValue); value = stringValue; return(tryRead); } case 'S': { var tryRead = ReadLongStr(out string stringValue); value = stringValue; return(tryRead); } default: { ReaderThrowHelper.ThrowIfUnrecognisedType(); return(false); } } }