misc: removing unneded accessors
This commit is contained in:
parent
73a309027f
commit
fe3c1d45bb
|
@ -22,42 +22,26 @@ type
|
||||||
streamHandler*: StreamHandler
|
streamHandler*: StreamHandler
|
||||||
connection*: Connection
|
connection*: Connection
|
||||||
|
|
||||||
MuxerCreator* = proc(conn: Connection): Muxer {.gcsafe, closure.}
|
# user provider proc that returns a constructed Muxer
|
||||||
|
MuxerConstructor* = proc(conn: Connection): Muxer {.gcsafe, closure.}
|
||||||
|
|
||||||
# this wraps a creator proc that knows how to make muxers
|
# this wraps a creator proc that knows how to make muxers
|
||||||
MuxerProvider* = ref object of LPProtocol
|
MuxerProvider* = ref object of LPProtocol
|
||||||
newMuxer*: MuxerCreator
|
newMuxer*: MuxerConstructor
|
||||||
streamHandler*: StreamHandler
|
streamHandler*: StreamHandler # triggered every time there is a new stream, called for any muxer instance
|
||||||
muxerHandler*: MuxerHandler
|
muxerHandler*: MuxerHandler # triggered every time there is a new muxed connection created
|
||||||
|
|
||||||
|
# muxer interface
|
||||||
method newStream*(m: Muxer, name: string = ""): Future[Connection] {.base, async, gcsafe.} = discard
|
method newStream*(m: Muxer, name: string = ""): Future[Connection] {.base, async, gcsafe.} = discard
|
||||||
method close*(m: Muxer) {.base, async, gcsafe.} = discard
|
method close*(m: Muxer) {.base, async, gcsafe.} = discard
|
||||||
method handle*(m: Muxer): Future[void] {.base, async, gcsafe.} = discard
|
method handle*(m: Muxer): Future[void] {.base, async, gcsafe.} = discard
|
||||||
method `streamHandler=`*(m: Muxer, handler: StreamHandler) {.base, gcsafe.} =
|
|
||||||
m.streamHandler = handler
|
|
||||||
|
|
||||||
proc newMuxerProvider*(creator: MuxerCreator, codec: string): MuxerProvider {.gcsafe.} =
|
proc newMuxerProvider*(creator: MuxerConstructor, codec: string): MuxerProvider {.gcsafe.} =
|
||||||
new result
|
new result
|
||||||
result.newMuxer = creator
|
result.newMuxer = creator
|
||||||
result.codec = codec
|
result.codec = codec
|
||||||
result.init()
|
result.init()
|
||||||
|
|
||||||
method `streamHandler=`*(m: MuxerProvider, handler: StreamHandler) {.base, gcsafe.} =
|
|
||||||
## new stream (channels) handler
|
|
||||||
##
|
|
||||||
## triggered every time there is a new
|
|
||||||
## stream (channel) oppened over a muxed
|
|
||||||
## connection
|
|
||||||
##
|
|
||||||
m.streamHandler = handler
|
|
||||||
|
|
||||||
method `muxerHandler=`*(m: MuxerProvider, handler: MuxerHandler) {.base, gcsafe.} =
|
|
||||||
## new muxer (muxed connections) handler
|
|
||||||
##
|
|
||||||
## triggered every time there is a new muxed
|
|
||||||
## connection created
|
|
||||||
##
|
|
||||||
m.muxerHandler = handler
|
|
||||||
|
|
||||||
method init(c: MuxerProvider) =
|
method init(c: MuxerProvider) =
|
||||||
proc handler(conn: Connection, proto: string) {.async, gcsafe, closure.} =
|
proc handler(conn: Connection, proto: string) {.async, gcsafe, closure.} =
|
||||||
let muxer = c.newMuxer(conn)
|
let muxer = c.newMuxer(conn)
|
||||||
|
|
Loading…
Reference in New Issue