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