allow multiple codecs per protocol (without breaking things)
This commit is contained in:
parent
ee6e545878
commit
3568b073fd
|
@ -16,7 +16,16 @@ type
|
||||||
Future[void] {.gcsafe, closure.}
|
Future[void] {.gcsafe, closure.}
|
||||||
|
|
||||||
LPProtocol* = ref object of RootObj
|
LPProtocol* = ref object of RootObj
|
||||||
codec*: string
|
codecs*: seq[string]
|
||||||
handler*: LPProtoHandler ## this handler gets invoked by the protocol negotiator
|
handler*: LPProtoHandler ## this handler gets invoked by the protocol negotiator
|
||||||
|
|
||||||
method init*(p: LPProtocol) {.base, gcsafe.} = discard
|
method init*(p: LPProtocol) {.base, gcsafe.} = discard
|
||||||
|
|
||||||
|
func codec*(p: LPProtocol): string =
|
||||||
|
assert(p.codecs.len > 0, "Codecs sequence was empty!")
|
||||||
|
p.codecs[0]
|
||||||
|
|
||||||
|
func `codec=`*(p: LPProtocol, codec: string) =
|
||||||
|
# always insert as first codec
|
||||||
|
# if we use this abstraction
|
||||||
|
p.codecs.insert(codec, 0)
|
||||||
|
|
|
@ -18,6 +18,7 @@ import metrics
|
||||||
|
|
||||||
export PubSubPeer
|
export PubSubPeer
|
||||||
export PubSubObserver
|
export PubSubObserver
|
||||||
|
export protocol
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
topics = "pubsub"
|
topics = "pubsub"
|
||||||
|
|
|
@ -14,6 +14,8 @@ import ../protocol,
|
||||||
../../stream/connection,
|
../../stream/connection,
|
||||||
../../peerinfo
|
../../peerinfo
|
||||||
|
|
||||||
|
export protocol
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
topics = "secure"
|
topics = "secure"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue