Import std.net.game.host
std.net.game.host
std.net.game's hosts: GameHost, one end of any number of connections over a GameLink, a UdpSocket's or a test's, which it services at each Update, giving what happened as GameEvents: a peer that connected, a message that came, and a peer that disconnected.
std/net/game/host.fb
Types
GameEventKind
enum
Public Enum GameEventKind
What a GameEvent says happened.
-
A peer connected.
-
A peer's message came.
-
A peer disconnected, for its Reason.
GameEvent
struct
Public Struct GameEvent Implements Printable
Something that happened at a GameHost's Update: a peer connected, a message came from one on a channel, or a peer disconnected, and why.
-
What happened.
-
The peer it happened to.
-
The channel a RECEIVE's message came on.
-
A RECEIVE's message.
-
Why a DISCONNECT's peer went.
-
A message's bytes as UTF-8.
-
As "CONNECT 127.0.0.1:5000", "RECEIVE 127.0.0.1:5000 on 0, 5 bytes", or "DISCONNECT 127.0.0.1:5000, TIMEOUT".
GameHost
class
Public Class GameHost
One end of connections over a GameLink. Connect asks another host for one, and a host takes those others ask for, up to its MaxPeers; each is a GamePeer, whose Send queues messages. Update takes what's come, sends what's due, and gives the events since the last; Service waits for some. A host whose link is its own, from Bind, closes it at Close.
-
@PanicsAtCaller Public New(link: GameLink, settings: GameSettings, seed: Int64? = Null)constructor #A host over
link, withsettings, whose salts and first sequences are random, or come fromseed, so a test repeats. Panics forsettingsthat don't make sense. -
@PanicsAtCaller Public Static Method Bind(address: SocketAddress, settings: GameSettings): GameHost Throws NetErrorstatic method #A host over a UDP socket bound to
address, as UdpSocket.Bind binds it, withsettings. -
A host over a UDP socket bound to
address, with GameSettings(). -
Where its link receives.
-
The peers it's connected to, connecting to, or disconnecting from.
-
Whether it's closed.
-
Asks the host at
addressfor a connection, at the next Update and each ConnectRetry after, which gives a CONNECT event once it's accepted, or a DISCONNECT one when it's refused or the Timeout passes. A peer it has ataddressalready is the one it gives. MaxPeers limits only the peers that connect to it. Panics once it's closed. -
Sends
bytesonchannelto every peer that's connected. Panics, peers or not, for a channel the host doesn't have, or a message past its MaxMessageSize, as a peer's Send does. -
Takes what's come, then sends what's due, all as of
now, and gives the events since the last Update. A closed host gives none. Throws a NetError only when its link fails for good. -
Update as of the clock's now.
-
Updates until there are events, waiting for what comes, up to
timeout, and gives them, or none oncetimeoutpasses. A timeout too long for the clock waits as long as it takes. -
Service's Async twin, which waits on the main thread.
-
Tells each peer it's connected to that it's going, without waiting for acks, and closes its link, giving no more events.
Report an issue with this page or with FutureBlitz on GitHub.