Difference between revisions of "enet.event"

(Created page with "== Description == An event is a table generated by host:service() or peer:recieve() which will '''always''' conta...")
 
(Added missing field "channel" to receive event)
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
== Description ==
 
== Description ==
An [[enet.event | event]] is a table generated by [[enet.host:service | host:service()]] or [[enet.peer:receive | peer:recieve()]] which will '''always''' contain a [[string]] named ''type'', a ''[[enet.peer]]'' named ''peer'', and a [[string]] or [[number]] named ''data'' depending on the kind of event.
+
An [[enet.event | event]] is a table generated by [[enet.host:service | host:service()]] or [[enet.peer:receive | peer:receive()]] which will '''always''' contain a [[string]] named ''type'', a [[enet.peer]] named ''peer'', and a [[string]] or [[number]] named ''data'' depending on the kind of event. Receive has an additional field named ''channel'' which contains the channel the data was received on specified by [[enet.peer:send]], by default this is 0.
 +
 
 +
Though be wary that [[enet.host:service | host:service()]] and [[enet.peer:receive | peer:receive()]] can return [[nil]] if no events are in the queue.
  
 
== Structure ==
 
== Structure ==
Line 7: Line 9:
 
!event.peer
 
!event.peer
 
!event.data
 
!event.data
 +
!event.channel
 
|-
 
|-
 
|"receive"
 
|"receive"
 
|[[enet.peer | peer]]
 
|[[enet.peer | peer]]
 
|[[string]]
 
|[[string]]
 +
|[[number]]
 
|-
 
|-
 
|"disconnect"
 
|"disconnect"
 
|[[enet.peer | peer]]
 
|[[enet.peer | peer]]
 
|[[number]]
 
|[[number]]
 +
|
 
|-
 
|-
 
|"connect"
 
|"connect"
 
|[[enet.peer | peer]]
 
|[[enet.peer | peer]]
 
|[[number]]
 
|[[number]]
 +
|
 
|}
 
|}
  
Line 25: Line 31:
 
* [[enet.host:service]]
 
* [[enet.host:service]]
 
* [[enet.peer:receive]]
 
* [[enet.peer:receive]]
 +
 +
== Other Languages ==
 +
{{i18n|enet.event}}

Latest revision as of 16:52, 7 March 2022

Description

An event is a table generated by host:service() or peer:receive() which will always contain a string named type, a enet.peer named peer, and a string or number named data depending on the kind of event. Receive has an additional field named channel which contains the channel the data was received on specified by enet.peer:send, by default this is 0.

Though be wary that host:service() and peer:receive() can return nil if no events are in the queue.

Structure

event.type event.peer event.data event.channel
"receive" peer string number
"disconnect" peer number
"connect" peer number

See Also

Other Languages