Rename: waitForHandshake() -> handshake()
This commit is contained in:
parent
7af5c5376e
commit
80a612ea11
|
@ -10,7 +10,7 @@ export newClientConnection
|
|||
export newServerConnection
|
||||
export receive, send
|
||||
export isHandshakeCompleted
|
||||
export waitForHandshake
|
||||
export handshake
|
||||
export Stream
|
||||
export openStream
|
||||
export close
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
import chronos
|
||||
import ngtcp2
|
||||
import connection
|
||||
import udp
|
||||
|
||||
proc isHandshakeCompleted*(connection: Connection): bool =
|
||||
ngtcp2_conn_get_handshake_completed(connection.conn).bool
|
||||
|
||||
proc handshake*(connection: Connection) {.async.} =
|
||||
while not connection.isHandshakeCompleted:
|
||||
await connection.send()
|
||||
|
|
|
@ -7,7 +7,6 @@ import ../congestion
|
|||
import connection
|
||||
import path
|
||||
import errors
|
||||
import handshake
|
||||
|
||||
proc trySend(connection: Connection): Datagram =
|
||||
var packetInfo: ngtcp2_pkt_info
|
||||
|
@ -36,10 +35,6 @@ proc send*(connection: Connection) {.async.} =
|
|||
datagram = connection.trySend()
|
||||
await connection.outgoing.put(datagram)
|
||||
|
||||
proc waitForHandshake*(connection: Connection) {.async.} =
|
||||
while not connection.isHandshakeCompleted:
|
||||
await connection.send()
|
||||
|
||||
proc receive*(connection: Connection, datagram: DatagramBuffer, ecn = ecnNonCapable) =
|
||||
var packetInfo: ngtcp2_pkt_info
|
||||
packetInfo.ecn = ecn.uint32
|
||||
|
|
|
@ -10,13 +10,13 @@ proc sendLoop(source, destination: Connection) {.async.} =
|
|||
proc performHandshake*: Future[tuple[client, server: Connection]] {.async.} =
|
||||
|
||||
let client = newClientConnection(zeroAddress, zeroAddress)
|
||||
let clientHandshake = client.waitForHandshake()
|
||||
let clientHandshake = client.handshake()
|
||||
|
||||
let datagram = await client.outgoing.get()
|
||||
|
||||
let server = newServerConnection(zeroAddress, zeroAddress, datagram.data)
|
||||
server.receive(datagram)
|
||||
let serverHandshake = server.waitForHandshake()
|
||||
let serverHandshake = server.handshake()
|
||||
|
||||
let clientLoop = sendLoop(client, server)
|
||||
let serverLoop = sendLoop(server, client)
|
||||
|
|
Loading…
Reference in New Issue