-
Notifications
You must be signed in to change notification settings - Fork 96
Sockets
- Client socket connects and sends an
IDENTIFY
payload
{
"r":"identify",
"d":{
"clientType":"client"
}
}
The clientType is used to determine whether the socket should be used when counting how many players are on place. The clientType
would be different, for example, when the popout screen is loaded but in an iframe where it cannot use the main place
socket.
The only time the socket connection will be used to count the players connected is when clientType
=== client
.
All other strings will not count as a client connection.
2. Server sends HELLO payload with timeout options
{
"e":"hello",
"d":{
"options":{
"activityTimeout":30000
}
}
}
The activityTimeout
is how long, in milliseconds, after the last recorded user action should the user be flagged as AFK.
3. Server begins dispatching events
{
"e":"user_change",
"d":0
}
The data payload is the number of users connected to place
The activity check payload is sent by the server and is essentially asking the client if the user is active right now. If the user is active at the time the payload (shown below) is received, the client will dispatch the activity payload (show below).
Activity Check Payload (Sent by server)
{
"e":"activity_check"
}
Activity Payload (Sent by client)
{
"r":"activity"
}
The timeout warning payload is the server's way of telling the client that the connection will be closed soon due to idling. At any time between this packet being received and the connection being closed, the client can send an activity payload which will reset the activity/timeout state (because the user is no longer AFK.)
Timeout Warning Payload (Sent by server)
{
"e":"timeout_warning"
}
The idle timeout payload is sent to the client right before the connection is closed due to idling. It is the server's way of telling the client "the connection is about to be closed because you are AFK. do not re-connect until you are no-longer AFK."
Do not attempt to reconnect to the server after being disconnected with this payload until the user is no-longer AFK.
Idle Timeout Payload (Sent by server)
{
"e":"idle_timeout"
}
Place 2.0 is licensed under the APGL-3.0 license. Please see it for details.