Game Method (Custom API)
Low-level method invocation layer: custom(), callGameMethod(), and setMethodMap().
custom
Calls a custom backend game function by name.
js
gametegra.custom('getInventory', { userId: 'd2f2e862-7db2-46ce-9bc7-469739fcb618' })csharp
var result = await gametegra.custom<object>("getInventory", gametegra.@params("userId","d2f2e862-7db2-46ce-9bc7-469739fcb618"));gdscript
var result = await gametegra.custom('getInventory', { 'userId': 'd2f2e862-7db2-46ce-9bc7-469739fcb618' })Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
functionName | string | Yes | The registered backend function name. |
params | object | No | Parameters to pass to the function. |
Response:
json
{
"onClientSuccess": true,
"onHostSuccess": false,
"data": {
"error": "Do not give consent for custom Method"
},
"errorMessage": null
}callGameMethod
Calls a game method by its key or mapped name. Useful when method names are overridden via setMethodMap.
js
gametegra.callGameMethod('createRoom', { maxPlayers: 2 })Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
methodKeyOrName | string | Yes | The method key or mapped name. |
params | object | No | Parameters to pass. |
Response:
json
{
"onClientSuccess": true,
"onHostSuccess": true,
"data": {
"match_id": "ece32adc-1208-4385-b126-9e1be36bb683.supergamefy",
"success": true
},
"errorMessage": null
}setMethodMap
Overrides the default backend method names with custom names.
js
gametegra.setMethodMap({ createRoom: 'MyCreateRoom' })Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
map | object | Yes | Key-value pairs where key is the SDK method and value is the backend method name. |
Response:
json
{
"createRoom": "MyCreateRoom",
"joinRoom": "joinRoom",
"leaveRoom": "leaveRoom",
"getScore": "getScore",
"sendData": "sendData",
"sentData": "sendData",
"listenData": "listenData",
"loadData": "loadData",
"saveData": "saveData",
"showAd": "showAd",
"createLeaderboard": "createLeaderboard",
"getLeaderboard": "getLeaderboard",
"updateLeaderboard": "updateLeaderboard"
}Which method should I use?
| Scenario | Recommended |
|---|---|
| SDK has a built-in method | gametegra.createRoom(), gametegra.saveData(), etc. |
| Custom backend function | gametegra.custom('myFunction', params) |
| Alias-based dispatch | gametegra.setMethodMap() + gametegra.callGameMethod() |