protocol handler method should receive context

This commit is contained in:
Dmitriy Ryajov 2019-08-29 14:55:30 -06:00
parent b85d616a13
commit 054bd365af
1 changed files with 9 additions and 8 deletions

View File

@ -9,21 +9,22 @@
import chronos import chronos
import connection, transport, stream, import connection, transport, stream,
peerinfo, multiaddress, multistreamselect peerinfo, multiaddress
type type
ProtoHandler* = proc (conn: Connection, proto: string): Future[void] {.gcsafe.} LPProtoHandler* = proc (protocol: LPProtocol,
Protocol* = ref object of RootObj conn: Connection,
proto: string): Future[void] {.gcsafe.}
LPProtocol* = ref object of RootObj
peerInfo*: PeerInfo peerInfo*: PeerInfo
codec*: string codec*: string
proc newProtocol*(p: typedesc[Protocol], proc newProtocol*(p: typedesc[LPProtocol],
peerInfo: PeerInfo): p = peerInfo: PeerInfo): p =
new result new result
result.peerInfo = peerInfo result.peerInfo = peerInfo
result.init() result.init()
method init*(p: Protocol) {.base.} = discard method init*(p: LPProtocol) {.base.} = discard
method handle*(protocol: LPProtocol, conn: Connection, proto: string): Future[void]
method handle*(p: Protocol, peerInfo: PeerInfo, handler: ProtoHandler) {.base, async.} = discard
{.base, async, error: "not implemented!".} = discard