Import std.net.game.link
GameLink
interface
Public Interface GameLink
What a GameHost's datagrams go over, as UDP's do: each one whole or not at all, maybe more than once, in no promised order.
Examples
// A link that loses every packet, as a test of what a host does then can have.
Class Nowhere Implements GameLink
Public Property LocalAddress: SocketAddress
Get => SocketAddress(IpAddress.Loopback, 9)
End Property
Public Method Send(bytes: UInt8[], to: SocketAddress) Throws NetError
End Method
Public Method Receive(timeout: Duration): (UInt8[], SocketAddress)? Throws NetError => Null
Public Method Close()
End Method
End Class
Local host = GameHost(Nowhere(), GameSettings())
Local peer = host.Connect(SocketAddress(IpAddress.Loopback, 7777))
Expect(peer.State == PeerState.CONNECTING)
host.Close()-
Where it receives, as the other side sends to it.
-
Sends
bytestotoas one datagram. -
The next datagram that's come, and where from, waiting for
timeoutat most, or Null when none came by then. A timeout of 0 takes what's come without waiting. -
Receive's Async twin, which waits on the main thread.
-
Closes it, if it holds anything to close.
Report an issue with this page or with FutureBlitz on GitHub.