don't block main loop
This commit is contained in:
parent
36917c5adc
commit
1b02c5e4e4
|
@ -44,6 +44,7 @@ type
|
||||||
closedLocal*: bool
|
closedLocal*: bool
|
||||||
closedRemote*: bool
|
closedRemote*: bool
|
||||||
mplex*: Mplex
|
mplex*: Mplex
|
||||||
|
handlerFuture*: Future[void]
|
||||||
|
|
||||||
proc newMplexUnknownMsgError*(): ref MplexUnknownMsgError =
|
proc newMplexUnknownMsgError*(): ref MplexUnknownMsgError =
|
||||||
result = newException(MplexUnknownMsgError, "Unknown mplex message type")
|
result = newException(MplexUnknownMsgError, "Unknown mplex message type")
|
||||||
|
@ -136,7 +137,7 @@ proc handle*(m: Mplex): Future[void] {.async, gcsafe.} =
|
||||||
case msgType:
|
case msgType:
|
||||||
of MessageType.New:
|
of MessageType.New:
|
||||||
let channel = await m.newStreamInternal(false, id.int)
|
let channel = await m.newStreamInternal(false, id.int)
|
||||||
await m.streamHandler(newConnection(channel))
|
channel.handlerFuture = m.streamHandler(newConnection(channel))
|
||||||
of MessageType.MsgIn, MessageType.MsgOut:
|
of MessageType.MsgIn, MessageType.MsgOut:
|
||||||
let channel = m.getChannelList(initiator)[id.int]
|
let channel = m.getChannelList(initiator)[id.int]
|
||||||
let msg = await m.connection.readLp()
|
let msg = await m.connection.readLp()
|
||||||
|
|
Loading…
Reference in New Issue