NetHost class

The authoritative side: listens on a port, numbers each client that joins and tells the game through onJoin, onMessage and onLeave.

Properties

hashCode → int
The hash code for this object.
no setterinherited
onJoin ↔ void Function(NetPeer peer)?
A client connected.
getter/setter pair
onLeave ↔ void Function(NetPeer peer)?
A client left.
getter/setter pair
onMessage ↔ void Function(NetPeer peer, NetMessage message)?
A client sent a message.
getter/setter pair
peers → Map<int, NetPeer>
The connected peers by id.
final
port → int
The port listened on.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

broadcast(NetMessage message, {int? except}) → void
Sends message to every peer but except, encoded once for all.
close() → Future<void>
Stops listening and drops every peer.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

bind({int port = 7777}) → Future<NetHost>
Listens on port of every interface (0 picks a free one).