GS2-Chat Script Trigger Reference
Trigger
createRoom
Room creation
Synchronous Execution Script
The script is executed synchronously before the room creation process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| room | Room | Room |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | Whether to allow room creation |
Implementation Example
-- Request
local namespace = args.namespace
local room = args.room
-- Business logic:
local permit = true
-- Result
result = {
permit=permit
}Asynchronous Execution Script
The script is executed asynchronously after the room creation process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| room | Room | Room |
Implementation Example
-- Request
local namespace = args.namespace
local room = args.room
-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.
result = {
}deleteRoom
Room deletion
Synchronous Execution Script
The script is executed synchronously before the room deletion process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| room | Room | Room |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | Whether to allow room deletion |
Implementation Example
-- Request
local namespace = args.namespace
local room = args.room
-- Business logic:
local permit = true
-- Result
result = {
permit=permit
}Asynchronous Execution Script
The script is executed asynchronously after the room deletion process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| room | Room | Room |
Implementation Example
-- Request
local namespace = args.namespace
local room = args.room
-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.
result = {
}postMessage
Message posting
Synchronous Execution Script
The script is executed synchronously before the message posting process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| room | Room | Room |
| message | Message | Message |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | Whether to allow message posting |
Implementation Example
-- Request
local namespace = args.namespace
local room = args.room
local message = args.message
-- Business logic:
local permit = true
-- Result
result = {
permit=permit
}Asynchronous Execution Script
The script is executed asynchronously after the message posting process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| room | Room | Room |
| message | Message | Message |
Implementation Example
-- Request
local namespace = args.namespace
local room = args.room
local message = args.message
-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.
result = {
}subscribeRoom
Room subscription
Synchronous Execution Script
The script is executed synchronously before the room subscription process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| room | Room | Room |
| subscribe | Subscribe | Subscribe |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | Whether to allow room subscription |
Implementation Example
-- Request
local namespace = args.namespace
local room = args.room
local subscribe = args.subscribe
-- Business logic:
local permit = true
-- Result
result = {
permit=permit
}Asynchronous Execution Script
The script is executed asynchronously after the room subscription process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| room | Room | Room |
| subscribe | Subscribe | Subscribe |
Implementation Example
-- Request
local namespace = args.namespace
local room = args.room
local subscribe = args.subscribe
-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.
result = {
}unsubscribeRoom
Room unsubscription
Synchronous Execution Script
The script is executed synchronously before the room unsubscription process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| room | Room | Room |
| subscribe | Subscribe | Subscribe |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | Whether to allow room unsubscription |
Implementation Example
-- Request
local namespace = args.namespace
local room = args.room
local subscribe = args.subscribe
-- Business logic:
local permit = true
-- Result
result = {
permit=permit
}Asynchronous Execution Script
The script is executed asynchronously after the room unsubscription process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| room | Room | Room |
| subscribe | Subscribe | Subscribe |
Implementation Example
-- Request
local namespace = args.namespace
local room = args.room
local subscribe = args.subscribe
-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.
result = {
}