beamable-sdk / core/BeamServer / BeamServer
Class: BeamServer¶
Defined in: src/core/BeamServer.ts:30
The main class for interacting with the Beam Server SDK.
Extends¶
BeamBase<this>.BeamServerServiceType
Properties¶
account()¶
account: (
userId) =>AccountService
Parameters¶
userId¶
string
Returns¶
announcements()¶
announcements: (
userId) =>AnnouncementsService
Parameters¶
userId¶
string
Returns¶
auth()¶
auth: (
userId) =>AuthService
Parameters¶
userId¶
string
Returns¶
cid¶
cid:
string
Defined in: src/core/BeamBase.ts:34
The Beamable Customer ID.
Inherited from¶
content()¶
content: (
userId) =>ContentService
Parameters¶
userId¶
string
Returns¶
leaderboards()¶
leaderboards: (
userId) =>LeaderboardsService
Parameters¶
userId¶
string
Returns¶
pid¶
pid:
string
Defined in: src/core/BeamBase.ts:36
The Beamable Project ID.
Inherited from¶
requester¶
readonlyrequester:HttpRequester
Defined in: src/core/BeamBase.ts:32
The HTTP requester instance used by the Beam SDK.
Inherited from¶
stats()¶
stats: (
userId) =>StatsService
Parameters¶
userId¶
string
Returns¶
tokenStorage¶
tokenStorage:
TokenStorage
Defined in: src/core/BeamBase.ts:42
The token storage instance used by the client SDK.
Defaults to BrowserTokenStorage in browser environments and NodeTokenStorage in Node.js environments.
Can be overridden via the tokenStorage option in the BeamConfig.
Inherited from¶
Accessors¶
env¶
Get Signature¶
get
staticenv():BeamEnvVars
Defined in: src/core/BeamServer.ts:61
Environment variables that can be set to configure the Beam SDK.
Remarks¶
These values must be supplied at runtime via real environment variables
(e.g. process.env.REALM_SECRET), and must not be committed directly into your source code.
Example¶
Returns¶
Overrides¶
Methods¶
off()¶
off<
K>(eventType,handler?):void
Defined in: src/core/BeamServer.ts:168
Unsubscribes from a specific server-event or removes all subscriptions if no handler is provided.
Type Parameters¶
K¶
K extends ServerEventType
Parameters¶
eventType¶
K
The server-event to unsubscribe from, e.g., 'content.manifest'.
handler?¶
(data) => void
The callback to remove. If not provided, all handlers for the server-event are removed.
Returns¶
void
Example¶
beamServer.off('content.manifest', handler);
// or to remove all handlers for the server-event
beamServer.off('content.manifest');
on()¶
on<
K>(eventType,handler):void
Defined in: src/core/BeamServer.ts:137
Subscribes to a server-event and listens for messages.
Type Parameters¶
K¶
K extends ServerEventType
Parameters¶
eventType¶
K
The server-event to subscribe to, e.g., 'content.manifest'.
handler¶
(data) => void
The callback to process the data when a message is received.
Returns¶
void
Example¶
const handler = (data) => {
console.log('Content manifest received:', data);
};
beamServer.on('content.manifest', handler);
use()¶
Call Signature¶
use<
T>(ctors):this
Defined in: src/core/BeamServer.ts:65
Dynamically adds multiple api services or microservice clients to the Beam SDK.
Type Parameters¶
T¶
T extends ApiServiceCtor<any> | BeamMicroServiceClientCtor<any>
Parameters¶
ctors¶
readonly T[]
An array of constructors for the api service or microservice client.
Returns¶
this
The current instance of BeamBase.
Example¶
orOverrides¶
Call Signature¶
use<
T>(ctor):this
Defined in: src/core/BeamServer.ts:68
Dynamically adds a single api service or microservice client to the Beam SDK.
Type Parameters¶
T¶
T extends ApiServiceCtor<any> | BeamMicroServiceClientCtor<any>
Parameters¶
ctor¶
T
The constructor for the api service or microservice client.
Returns¶
this
The current instance of BeamBase.
Example¶
orOverrides¶
init()¶
staticinit(config):Promise<BeamServer>
Defined in: src/core/BeamServer.ts:36
Initialize a new Beam server instance.
Parameters¶
config¶
Returns¶
Promise<BeamServer>