Class: module:PushModelBase

module:PushModelBase

new module:PushModelBase(skipLocalModel)

Constructor for Push models.
Parameters:
Name Type Description
skipLocalModel boolean Controls constructor call for LocalModel.

Methods

activate()

Activates this push model by opening the connection and registering event handlers. Connection is not ready to receive messages until method onOpen is called.

close()

Closes the underlying connection.

deactivate()

Deactivates this push model by closing the underlying connection.

getUrl() → {string}

Returns underlying URL for this model. If the URL is relative, it is absolutized to ensure it starts with "ws:".
Returns:
URL for model.
Type
string

onError(event)

Default error handler for this model. Outputs error message to console, if available.
Parameters:
Name Type Description
event object Error message event.

onMessage(event)

Event handler called when a message is received. By default, it deserializes the event's data into the model.
Parameters:
Name Type Description
event object Event message received.

onOpen()

Event handler called once the connection has been opened. Will be called before any onMessage.

setUrl(url)

Updates the underlying URL for this model.
Parameters:
Name Type Description
url string URL for model.