The scripts are called by the framework when appropriate. You can put logic inside of them and handle it as needed for your game. They are used to notify you of events that happen from within the framework, and allow you to decide on what to do when they do happen.
Syntax:
gnet_OnConnectionReply(ConnectionAddResult, ConnectionId);
Argument name | Type | Description |
---|---|---|
ConnectionAddResult | Enum | The add result receieved |
ConnectionId | Number | The connectionId that sent the message |
Description:
System Callback This is called when a response has been receieved from a sent Connection Request
FRAMEWORK NOTE: This is CALLED FROM Connection -> USER EVENT 3
Syntax:
gnet_OnConnectionProblem(Connection);
Argument name | Type | Description |
---|---|---|
Connection | Connection | This is the "Connection" instance. This is passed in so that you can have access to all of that instances properties. In general you should only need to access Connection.connectionId. |
Description:
System Callback This function is called when communication with a client has been interupted This means that no data has been received from the given connection even though it has been tryed. (Time can be configured with gnet_set_connection_timeout. Default is 8 seconds) NOTE:** Maybe you have peer to peer. You cant just disconnect yours, what if that connection is communicating to other people just fine? You would do that logic here to perform checks and things.
Syntax:
gnet_OnDisconnection(Connection);
Argument name | Type | Description |
---|---|---|
Connection | Number | This is the connectionId of the disconnected connection. |
Description:
System Callback This function is called when communication has stopped and the Connection destroyed.
Syntax:
gnet_OnNetworkShutdown();
Description:
System Callback This function is called when the Network has been destroyed
Syntax:
gnet_OnNewConnection(Connection);
Argument name | Type | Description |
---|---|---|
Connection | Number | This is the connectionId of the disconnected connection. |
Description:
System Callback This function is called when a new connection has been established successfully. This is a good place to for example; Save the connection id in a list. This connectionId can be used in the future to send data or identify who sent the data. For example
Example:
// Script is called
var _connectionId = argument0;
ds_list_add(Server.clientList, _connectionId);
Syntax:
gnet_OnRPCMessage(Buffer, Script, Arguments);
Argument name | Type | Description |
---|---|---|
Buffer | Buffer | The received buffer. The data in this buffer has already been unpacked into _arguments. This is provided if you would like to resend the RPC instead of processing it (Client / Server). |
Script | Script | The script to execute |
Arguments | [Argument] | An array of arguments that should be executed with the script |
Description:
This script is called when you receive an RPC Message. You can handle RPC messages as you would like. The buffer is passed in in case you want to resend it, but the buffer has also been unpacked and data stored into the _arguments variable as an array.