Class Common.NetMessage
Network Message Builder class.
Used to builds network messages that will be sent from server to client(s).
Data Structures
.netMessageArgumentProperty | The net message argument properties. |
Tables
Common.NetMessage.MSG | Network message destination types. |
Common.NetMessage.TYPE | Network message types. |
Common.NetMessage.ARGFORMAT | Argument formats. |
Fields
Common.NetMessage.name | Name of this network message. |
Methods
Common.NetMessage:Create (name) | Constructs a network message. |
Common.NetMessage:IsRegistered ([name]) | Checks whether the network message is registered. |
Common.NetMessage:Register ([...]) | Registers the network message into Common.NetMessage.TYPE table. |
Common.NetMessage:Unregister ([name]) | Unregisters the network message from Common.NetMessage.TYPE table. |
Common.NetMessage:ToString () | Returns the name of this network message. |
Common.NetMessage:ToFormatType (FormatType, Value) | Converts a value into a proper data type value. |
Event Callbacks
Common.NetMessage:OnSent (args) | Called when this network message is sent to client. |
Common.NetMessage:OnReceived (args) | Called when this network message is received from server. |
Metamethods
Common.NetMessage.__index | Base class. |
Common.NetMessage.__tostring | Returns the name of this network message. |
Data Structures
- .netMessageArgumentProperty
-
The net message argument properties.
- value anything The argument value.
- format string The argument format/datatype.
Tables
- Common.NetMessage.MSG
-
Network message destination types.
Fields:
- BROADCAST Same as ALL unreliable to all.
- ONE reliable to one (msg_entity).
- ALL reliable to all.
- INIT Unsupported write to the init string.
- PVS Unsupported Ents in PVS of org.
- PAS Unsupported Ents in PAS of org.
- PVS_R Unsupported Reliable to PVS.
- PAS_R Unsupported Reliable to PAS.
- ONE_UNRELIABLE Same as ONE Send to one client, got don't put in reliable stream, put in unreliable datagram ( could be dropped ).
- SPEC Unsupported Sends to all spectator proxies.
See also:
- Common.NetMessage.TYPE
-
Network message types.
Fields:
- SHOWMENU This message displays a "menu" to a player (text on the left side of the screen).
- SCREENFADE This message fades the screen.
- BARTIME This message draws a HUD progress bar which is filled from 0% to 100% for the time Duration seconds. Once the bar is fully filled it will be removed from the screen automatically.
- BARTIME2 The message is the same as BarTime, but StartPercent specifies how much of the bar is (already) filled.
- TE_TEXTMESSAGE This message draws a HUD text message.
See also:
- Common.NetMessage.ARGFORMAT
-
Argument formats.
Fields:
- BYTE Unsigned char
- CHAR Signed char.
- SHORT Signed short.
- LONG Signed long.
- ANGLE Float in signed char form.
- FLOAT Float.
- VECTOR Vector string.
- STRING String.
- NUMBER Lua number.
Fields
- Common.NetMessage.name
-
Name of this network message.
- name string
Methods
- Common.NetMessage:Create (name)
-
Constructs a network message.
Note: This will not register the network message.
Parameters:
- name string The name of this network message.
Returns:
-
Common.NetMessage
The new network message.
See also:
Usage:
local myMsg = Common.NetMessage:Create( "MyNetMessage" );
- Common.NetMessage:IsRegistered ([name])
-
Checks whether the network message is registered.
Parameters:
- name string The network message name. (optional)
Returns:
-
bool
Returns true if already registered.
- Common.NetMessage:Register ([...])
-
Registers the network message into Common.NetMessage.TYPE table.
The table index will be formatted as upper-case string.
Parameters:
- ... Arguments will be passed to constructs a new network message. (optional)
Returns:
-
Common.NetMessage
This network message.
See also:
Usage:
local myMsg = Common.NetMessage:Register( "MyNetMessage" ); print( Common.NetMessage.TYPE.MYNETMESSAGE:ToString() ); -- print "MyNetMessage". print( myMsg:ToString() ); -- also print "MyNetMessage".
- Common.NetMessage:Unregister ([name])
-
Unregisters the network message from Common.NetMessage.TYPE table.
Parameters:
- name string The network message name. (optional)
Returns:
-
Common.NetMessage
This network message.
Usage:
-- you can do this, myMsg:Unregister(); -- or you can do this, Common.NetMessage:Unregister( "MyNetMessage" ); -- but not doing both!
- Common.NetMessage:ToString ()
-
Returns the name of this network message.
Returns:
-
string
The name of this network message.
- Common.NetMessage:ToFormatType (FormatType, Value)
-
Converts a value into a proper data type value.
Parameters:
- FormatType Common.NetMessage.ARGFORMAT The format data type.
- Value anything Any value.
Returns:
-
anything or nil
Returns a proper value. | Returns
nil
if invalid format type.See also:
Event Callbacks
- Common.NetMessage:OnSent (args)
-
Called when this network message is sent to client.
Note: This event is called in Game module.
Note: This event is using Hook management.
Parameters:
- args .netMessageArgumentProperty[] The network message arguments.
See also:
Usage:
local myMsg = Common.NetMessage:Register( "MyNetMessage" ); function myMsg:OnSent (args, format) print (self.name .. 'is sent!' ); end
- Common.NetMessage:OnReceived (args)
-
Called when this network message is received from server.
Note: This event is called in UI module.
Note: This event is using Hook management.
Parameters:
- args .netMessageArgumentProperty[] The network message arguments.
See also:
Usage:
local myMsg = Common.NetMessage:Register( "MyNetMessage" ); function myMsg:OnReceived (args, format) print (self.name .. 'is received!' ); end
Metamethods
- Common.NetMessage.__index
-
Base class.
- __index Common.NetMessage
- Common.NetMessage.__tostring
-
Returns the name of this network message.
- __tostring Common.NetMessage.ToString