Open Bouke opened 3 years ago
Unfortunately the debug event handlers aren't that helpful in this instance. NIOAny
is an opaque type which isn't meant to -- and indeed can't -- be unwrapped manually with public API as it stands. The enum case for the read(data: NIOAny)
event in the callback for these handlers should have been read(data: Any)
which would have allowed you to cast the Any
to the appropriate type (see also: https://github.com/apple/swift-nio-extras/pull/81).
Your best bet here is creating your own ChannelHandler
which unwraps, logs, and then forward events.
Expected behavior
I'd like to print/log plain text conversations between client and server. Using the Debug(In|Out)boundEventsHandler, I'm only getting "NIOAny { ... }", which I don't understand how to convert to plain text.
After making this change the following change to the handler I'm able to print the conversation. However this cannot be done in the callback, as it doesn't have access to
self.unwrapOutboundIn
.Actual behavior
SwiftNIO-Extras version
Swift & OS version