public async Task ParseOrConnEventAsync() { string data = "650 ORCONN $A1B28D636A56AAFFE92ADCCA937AA4BD5333BB4C~bakunin4 LAUNCHED ID=5\r\n"; TorControlReply rawReply = await TorControlReplyReaderTest.ParseAsync(data); OrConnEvent orConnEvent = OrConnEvent.FromReply(rawReply); Assert.Equal("$A1B28D636A56AAFFE92ADCCA937AA4BD5333BB4C~bakunin4", orConnEvent.Target); Assert.Equal(OrStatus.LAUNCHED, orConnEvent.OrStatus); Assert.Null(orConnEvent.NCircs); Assert.Equal("5", orConnEvent.ConnId); }
/// <exception cref="TorControlReplyParseException"/> public static IAsyncEvent Parse(TorControlReply reply) { if (reply.StatusCode != StatusCode.AsynchronousEventNotify) { throw new TorControlReplyParseException($"Event: Expected {StatusCode.AsynchronousEventNotify} status code."); } (string value, _) = Tokenizer.ReadUntilSeparator(reply.ResponseLines[0]); return(value switch { StatusEvent.EventNameStatusClient or StatusEvent.EventNameStatusServer or StatusEvent.EventNameStatusGeneral => StatusEvent.FromReply(reply), CircEvent.EventName => CircEvent.FromReply(reply), NetworkLivenessEvent.EventName => NetworkLivenessEvent.FromReply(reply), OrConnEvent.EventName => OrConnEvent.FromReply(reply), _ => throw new NotSupportedException("This should never happen."), });