mirror of https://github.com/vacp2p/nim-quic.git
Rename: Connection.read() -> Connection.receive()
This commit is contained in:
parent
38433d723f
commit
805fefe50c
|
@ -8,7 +8,7 @@ import ngtcp2/streams
|
|||
export Connection
|
||||
export newClientConnection
|
||||
export newServerConnection
|
||||
export read, write
|
||||
export receive, write
|
||||
export isHandshakeCompleted
|
||||
export waitForHandshake
|
||||
export Stream
|
||||
|
|
|
@ -40,7 +40,7 @@ proc waitForHandshake*(connection: Connection) {.async.} =
|
|||
while not connection.isHandshakeCompleted:
|
||||
await connection.write()
|
||||
|
||||
proc read*(connection: Connection, datagram: DatagramBuffer, ecn = ecnNonCapable) =
|
||||
proc receive*(connection: Connection, datagram: DatagramBuffer, ecn = ecnNonCapable) =
|
||||
var packetInfo: ngtcp2_pkt_info
|
||||
packetInfo.ecn = ecn.uint32
|
||||
checkResult ngtcp2_conn_read_pkt(
|
||||
|
@ -53,5 +53,5 @@ proc read*(connection: Connection, datagram: DatagramBuffer, ecn = ecnNonCapable
|
|||
)
|
||||
connection.flowing.fire()
|
||||
|
||||
proc read*(connection: Connection, datagram: Datagram) =
|
||||
connection.read(datagram.data, datagram.ecn)
|
||||
proc receive*(connection: Connection, datagram: Datagram) =
|
||||
connection.receive(datagram.data, datagram.ecn)
|
||||
|
|
|
@ -5,7 +5,7 @@ import addresses
|
|||
proc sendLoop(source, destination: Connection) {.async.} =
|
||||
while true:
|
||||
let datagram = await source.outgoing.get()
|
||||
destination.read(datagram)
|
||||
destination.receive(datagram)
|
||||
|
||||
proc performHandshake*: Future[tuple[client, server: Connection]] {.async.} =
|
||||
|
||||
|
@ -15,7 +15,7 @@ proc performHandshake*: Future[tuple[client, server: Connection]] {.async.} =
|
|||
let datagram = await client.outgoing.get()
|
||||
|
||||
let server = newServerConnection(zeroAddress, zeroAddress, datagram.data)
|
||||
server.read(datagram)
|
||||
server.receive(datagram)
|
||||
let serverHandshake = server.waitForHandshake()
|
||||
|
||||
let clientLoop = sendLoop(client, server)
|
||||
|
|
|
@ -13,22 +13,22 @@ suite "udp":
|
|||
let datagram = await client.outgoing.get()
|
||||
check datagram.len > 0
|
||||
|
||||
asynctest "reads packets from datagram":
|
||||
asynctest "processes received datagrams":
|
||||
let client = newClientConnection(zeroAddress, zeroAddress)
|
||||
await client.write()
|
||||
let datagram = await client.outgoing.get()
|
||||
let server = newServerConnection(zeroAddress, zeroAddress, datagram.data)
|
||||
server.read(datagram)
|
||||
server.receive(datagram)
|
||||
|
||||
test "raises error when reading datagram fails":
|
||||
test "raises error when receiving bad datagram":
|
||||
let datagram = repeat(0'u8, 4096)
|
||||
let server = newServerConnection(zeroAddress, zeroAddress, datagram)
|
||||
|
||||
expect IOError:
|
||||
server.read(datagram)
|
||||
server.receive(datagram)
|
||||
|
||||
test "raises error when reading empty datagram":
|
||||
test "raises error when receiving empty datagram":
|
||||
let client = newClientConnection(zeroAddress, zeroAddress)
|
||||
|
||||
expect IOError:
|
||||
client.read(@[])
|
||||
client.receive(@[])
|
||||
|
|
Loading…
Reference in New Issue