more docs
This commit is contained in:
parent
16b2d1780b
commit
967558aed3
@ -81,6 +81,10 @@ open class Adapter<T: WithAdapter>(
|
|||||||
/**
|
/**
|
||||||
* If you plaan to cancel the adapter from outside its context (e.g. from API command or like)
|
* 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).
|
* 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")}
|
var onCancel: suspend ()->Unit = { throw NotImplementedError("this adapted has no onCancel implementation, provide it")}
|
||||||
|
|
||||||
@ -195,8 +199,13 @@ open class Adapter<T: WithAdapter>(
|
|||||||
class CloseError : IOException("adapter is closed")
|
class CloseError : IOException("adapter is closed")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees any allocater resources, for example, pending commands.
|
* Frees any allocated resources, for example, pending commands.
|
||||||
* Any protocol implementatino MUST call it when connection is closed.
|
* 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() {
|
fun close() {
|
||||||
val error = CloseError()
|
val error = CloseError()
|
||||||
|
Loading…
Reference in New Issue
Block a user