Home Reference Source
import Core from '@osjs/server/src/core.js'
public class | source

Core

Extends:

CoreBase → Core

OS.js Server Core

Static Method Summary

Static Public Methods
public static

Gets the server instance

Constructor Summary

Public Constructor
public

constructor(cfg: Object, options: Object)

Creates a new instance

Member Summary

Public Members
public

app: Express

public

httpServer: http.Server | https.Server

public
public
public

Method Summary

Public Methods
public

async boot(): Promise<boolean>

Initializes the server

public

broadcast(name: string, params: Array, filter: Function)

Broadcast given event to client

public

broadcastAll(name: string): *

Broadcast given event to all clients

public

broadcastUser(username: String, name: string): *

Broadcast given event to client filtered by username

public

Destroys the instance

public

async listen(): *

Opens HTTP server

public

async start(): Promise<boolean>

Starts the server

Static Public Methods

public static getInstance(): Core source

Gets the server instance

Return:

Core

Public Constructors

public constructor(cfg: Object, options: Object) source

Creates a new instance

Params:

NameTypeAttributeDescription
cfg Object

Configuration tree

options Object
  • optional

Options

Public Members

public app: Express source

public httpServer: http.Server | https.Server source

public session: object source

public ws: object source

public wss: object source

Public Methods

public async boot(): Promise<boolean> source

Initializes the server

Return:

Promise<boolean>

public broadcast(name: string, params: Array, filter: Function) source

Broadcast given event to client

Params:

NameTypeAttributeDescription
name string

Event name

params Array

A list of parameters to send to client

filter Function
  • optional

A function to filter clients

public broadcastAll(name: string): * source

Broadcast given event to all clients

Params:

NameTypeAttributeDescription
name string

Event name

...params Array

A list of parameters to send to client

Return:

*

public broadcastUser(username: String, name: string): * source

Broadcast given event to client filtered by username

Params:

NameTypeAttributeDescription
username String

Username to send to

name string

Event name

...params Array

A list of parameters to send to client

Return:

*

public async destroy(done: Function): Promise<undefined> source

Destroys the instance

Params:

NameTypeAttributeDescription
done Function
  • optional

Callback when done

Return:

Promise<undefined>

public async listen(): * source

Opens HTTP server

Return:

*

public async start(): Promise<boolean> source

Starts the server

Return:

Promise<boolean>