diff --git a/src/commonMain/kotlin/net.sergeych.parsec3/Adapter.kt b/src/commonMain/kotlin/net.sergeych.parsec3/Adapter.kt index d47ed5d..7a0bbd3 100644 --- a/src/commonMain/kotlin/net.sergeych.parsec3/Adapter.kt +++ b/src/commonMain/kotlin/net.sergeych.parsec3/Adapter.kt @@ -81,6 +81,10 @@ open class Adapter( /** * If you plaan to cancel the adapter from outside its context (e.g. from API command or like) * provide specific close code that frees resource for this adapter (like closing websocket connection). + * + * Typically this method should be set by the transport when connection is established. It is, still, an option, + * as not any adapter/trasport combination requires it. Default websock transport implements it + * out of the box. */ var onCancel: suspend ()->Unit = { throw NotImplementedError("this adapted has no onCancel implementation, provide it")} @@ -195,8 +199,13 @@ open class Adapter( class CloseError : IOException("adapter is closed") /** - * Frees any allocater resources, for example, pending commands. - * Any protocol implementatino MUST call it when connection is closed. + * Frees any allocated resources, for example, pending commands. + * Any protocol implementation MUST call it when connection is closed. + * Note that penging commands are completed exceptionally woth [CloseError]. + * + * Normally, end user does not call it. Instead, it should call [cancel] if adapter needs + * to be explicitedly cancelled. Instead, [Parsec3Transport] inplementations _must_ call `close()` + * on the adapter instance it create when the connection is closed. */ fun close() { val error = CloseError()