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