Server class.

Note: Most of the API in this class is not thread-safe and intended to be called only from the main worker thread with the one exception: Server.work().

Constructor

new (metav:MetaServer)

Fields

read only asyncDatabaseManager:AsyncDatabaseManager

Asynchronous queries database manager link.

read only asyncWorker:AsyncWorker

Asynchronous worker threads manager link.

read only blockManager:BlockManager

Data blocks manager.

read only clientTimer:ClientTimer

Temp directory reader/writer.

read only config:Config

Server configuration file access.

read only configCompression:Int

Cached configuration variable. Enables message compression.

read only configCompressionLevel:Int

Cached configuration variable. Message compression level (1-9).

read only configLogTime:Bool

Cached configuration variable. If set to true, will log time spent on each client request.

read only coreModuleParams:_CoreModuleParams

Core module parameters.

read only externalHost:String

External server host.

read only externalPort:Int

External server port.

read only host:String

Local server host.

read only id:Int

Unique server ID (within this server type).

read only isDev:Bool

Cached configuration variable. Is this server dev or live?

read only localeManager:LocaleManager

Localization manager.

read only metrics:ServerMetrics

Server-wide metrics

read only name:String

Local server name.

read only notifyManager:NotifyManager

Server to server notifications manager.

read only port:Int

Local server port.

read only profiler:Profiler

Server profiler.

read only projectManager:ProjectManager

Project info manager.

read only redis:Redis

Redis connection to main database (0/1). Use only from main server thread.

read only redis1:Redis

Redis connection to persistent project database (10+, has to be selected). Use only from main server thread.

read only redisNotify:Redis

Redis connection to entity notification database (3). Use only from main server thread.

read only serverType:String

Server type.

read only timer:Timer

Timer for running recurring tasks.

read only url:URLRequester

Threaded HTTP request manager.

read only webSocket:String

WebSocket URL.

Methods

inline alert (projectID:String, type:String, s:String):Void

inline debug (projectID:String, type:String, s:String):Void

inline disconnect (c:ClientInfo):Void

Immediately disconnects a client and triggers disconnect hooks.

Parameters:

c

Client.

inline error (projectID:String, type:String, s:String):Void

getClientByConnectionID (id:Int):ClientInfo

Returns client by his connection id.

Parameters:

id

Connection ID.

Returns:

Client. Returns null, if no such client is online.

inline log (projectID:String, type:String, s:String):Void

Adds a typed message to server log.

Parameters:

projectID

Message project ID.

type

Message type.

s

Message to log.

nextID (t:String):Int

Returns next available row ID from sequence for given database table.

Parameters:

t

Database table name.

Returns:

Next available row ID.

inline pending (q:String):Void

Adds SQL query to the queue for later execution and immediately returns.

Parameters:

q

SQL query string.

inline print (s:String):Void

Prints a string to stdout.

Parameters:

s

String to output.

inline query (q:String):List<Dynamic>

Sends request to cache server and waits for response.

Parameters:

params

Request parameters. Should have the _type field that sets the request type in the <module>.<method> format.

Returns:

Cache server response parameters.

inline queryTrace (q:String):List<Dynamic>

Runs SQL query in database and logs it in trace log.

Parameters:

q

SQL query string.

Returns:

A list of results if the query is of SELECT type. Null otherwise.

inline quote (s:String):String

Escapes a string for using in SQL query as a row field.

Parameters:

s

String.

Returns:

Escaped string.

inline work (id:String, f:Void ‑> Void, ?logMsg:String):Void

Sends task to worker thread. The method given as an argument will be called in main worker thread. This method is thread-safe.

Parameters:

id

Task string ID. Used with extended profiling.

f

Method to call.

logMsg

Optional log message.

inline workExt (o:_WorkParams):Void

Sends task to worker thread. The method given as an argument will be called in main worker thread. This method is thread-safe.

Parameters:

o

Worker task parameters object.