Skip to content

Social live (Cocos)

FRVRSDK.instance.socialLive* opens a WebSocket to FRVR’s social server for real‑time events — friends coming online / changing status, game invites landing. Use it for in‑lobby “who’s playing?” UIs and instant game‑invite banners.

FRVRSDK.instance.socialLiveConnect();

Call once after sign‑in. The connection is maintained for the life of the session; close it on onDestroy or before leaving the scene that uses it:

onDestroy() {
  FRVRSDK.instance.socialLiveClose();
}
import { SocialEvent } from './frvr-sdk/FRVRSDK';

FRVRSDK.instance.socialLiveOn(SocialEvent.ON_FRIEND_STATUS_UPDATED, (event) => {
  // event contains the friend's id and new status payload
  updateFriendRow(event);
});

FRVRSDK.instance.socialLiveOn(SocialEvent.ON_GAME_INVITE, (event) => {
  // event describes the incoming invite (from, lobbyId, payload)
  showInviteBanner(event);
});

Tell friends what you’re doing (in a lobby, in level 5, etc.):

FRVRSDK.instance.socialLiveUpdateStatus({ level: 1, state: 'lobby' });

Whatever object you pass is forwarded verbatim to subscribed friends’ ON_FRIEND_STATUS_UPDATED handlers.

FRVRSDK.instance.socialLiveSendGameInvite(
  userId,
  lobbyId,
  { level: 1, role: 'host' },   // arbitrary payload
);

The receiver gets an ON_GAME_INVITE event with the payload you sent.

Synchronous snapshot of everyone’s last broadcast status:

const statuses = FRVRSDK.instance.socialLiveGetFriendsStatus();
// { friendId: { ...status }, ... }

Use this to populate a friends list on scene load, then let the ON_FRIEND_STATUS_UPDATED event stream keep it in sync.

socialLiveConnect()           // open the socket
socialLiveOn(event, handler)  // subscribe
socialLiveUpdateStatus(...)   // broadcast
socialLiveSendGameInvite(...) // 1:1 invite
socialLiveGetFriendsStatus()  // snapshot
socialLiveClose()             // close the socket

Social live is for real‑time signals. For one‑shot queries (a friend list at scene load, last match results), just call the plain social APIs — no socket needed.