NetConnection¶
Extends EngineObject.
One connection to another program, made by NetSystem.Connect or accepted by a NetSystem.Listen. Messages are sent on it and arrive as signals of the NetSystem.
Objects of this class are refused to mods.
Properties¶
address: stringThe other side's address (the one that was asked for, for a connection we made). Read-only.is_incoming: booleanTrue for a connection that somebody made to our port, false for one we made. Read-only.state: NetStateRead-only.ping: numberThe round trip time in milliseconds, or -1 when it is not known yet. Read-only.quality: number0 to 1: the share of our packets that arrive, as the other side measures it. Read-only.bytes_out: numberBytes a second being sent. Read-only.bytes_in: numberBytes a second being received. Read-only.
Methods¶
send¶
function send(self, data: string, reliable: boolean?, lane: number?): boolean
Sends text (UTF-8) to the other side. reliable messages arrive, once and in order; the others may be lost, never twice, and are for what is out of date a moment later (positions). lane is the lane set by ConfigureLanes (0 is the default one). Returns false when it could not be queued.
configure_lanes¶
function configure_lanes(self, count: number): boolean
Gives the connection count lanes: messages on one lane arrive in order and a slow one does not hold up the others. Before the first message.
close¶
function close(self, reason: string?, linger: boolean?): ()
Ends the connection. Messages still waiting are sent first when linger. The other side gets NetSystem.Disconnected with reason; here no signal is emitted (we asked for it).
refuse¶
function refuse(self): ()
In a handler of NetSystem.ConnectionRequested: turns the connection down.