new Connection()
Main Connection.
This class encapsulates:
- connection state management;
- commands sending to the server over ajax;
- keep alive messages (LiveMessage commands).
The class uses ConnectionRequest to generate XML and perform the actual AJAX call with the command.
Most commands methods (if not all), such as getViews and requestStream return a connectionRequest object to the callee.
This object can be used to cancel the request if needed via the cancelRequest method.
Members
DSServerStatus
Indicates the configuration of DS comming from the Mobile Server
connectionId
Read-only: Connection ID, supplied by the server
Properties:
Name | Type | Description |
---|---|---|
connectionId |
String |
currentUserEmail
Keeps the email provided by the server of the currently logged in user
Properties:
Name | Type | Description |
---|---|---|
currentUserEmail |
String |
currentUserName
Keeps the username provided by the server of the currently logged in user
Properties:
Name | Type | Description |
---|---|---|
currentUserName |
String |
decrease
Decreases the FPS within the given boundies.
increase
Increases the FPS within the given boundies.
manage
Manages FPS increase/decrease depending on the given queue length, as well as the number of consecutive zero queue lengths.
e.g. If the LiveMessage queue length parameter reaches 2 (meaning that by the sending of the third LiveMessage the previous 2 are still waiting for response), the FPS has to be dropped so,
that the LiveMessage responses can be received from the server. The drop is to a safe FPS level we know of, bellow the current one, or to 1 FPS (in order to free the communication channel ASAP).
e.g. If the LiveMessage queue length is zero and was zero for the past 5 consecutive LiveMessages, there will be an attempt to recover the FPS (if bellow maximum) up to its maximum by increasing it with 1 FPS at a time.
serverId
Read-only: Server ID, supplied by the server
Properties:
Name | Type | Description |
---|---|---|
serverId |
String |
serverTimeout
Session timeout in seconds, supplied by the server. It is needed so we know how often to send keep-alive messages
Properties:
Name | Type | Description |
---|---|---|
serverTimeout |
Number |
state
Read-only: Connection state. See ConnectionStates constants for possible values
Properties:
Name | Type | Description |
---|---|---|
state |
Number |
(inner) fps
This singleton manages the FPS of all Cameras in the VideoConnectionPool (increasing/decreasing FPS), but never dropping bellow minFps and not exceeding the maxFps.
It is triggered by the LiveMessage in push mode, when the message has difficulties receiving its response from the server due to low bandwidth and heavy incoming traffic for the VideoConnections.
(inner) liveMessagesWaiting
Number of previous LiveMessages still waiting for response from the server.
(inner) maxFps
Maximum FPS supported. In push mode this FPS value is used as highest value when adjusting the frame rate.
(inner) minFps
Minimum FPS supported. In push mode this FPS value is used as lowest value when adjusting the frame rate
(inner) observers
Observers are objects that receive certain events from the connection. These objects should implement methods from
the ConnectionObserverInterface. To add/remove an observer use the addObserver/removeObsever methods, don't modify this
array directly - it is supposed to be private property
(inner) requests
All requests currently waiting for response
(inner) sequenceID
Each command send to the server has a sequenceID which starts from 1 and is increased with every next request.
Methods
ChangeStream(params:, successCallback:, failCallback:)
Sends a ChangeStream command to the server.
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
Returns:
the request object
CloseStream(params:, successCallback:, failCallback:)
Sends a CloseStream command to the server.
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
Returns:
the request object
Connect(params:, successCallback:, failCallback:)
Sends a Connect command to the server.
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
Returns:
the request object
Login(params:, successCallback:, failCallback:)
Sends a Login command to the server. Log-in has to be performed before any other normal requests (except connect and some other special cases).
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
Returns:
the request object
RequestAudioStream(params:, successCallback:, failCallback:)
Sends a RequestAudioStream command to the server.
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
Returns:
the request object
RequestStream(params:, successCallback:, failCallback:)
Sends a RequestStream command to the server.
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
Returns:
the request object
acknowledgeAlarm(alarmId:, successCallback:, failCallback:)
Acknowledges the given alarm.
Parameters:
Name | Type | Description |
---|---|---|
alarmId: |
String | Unique ID of the alarm |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
cancelInvestigation(investigationId)
Cancels investigation creation when in progress.
Parameters:
Name | Type | Description |
---|---|---|
investigationId |
object Id of investigation to delete |
changeMultipleStreams(params:, successCallback:, failCallback:)
Change several streams at a time
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
createInvestigation(params:, successCallback:, failCallback:)
Create investigation to the server
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
createPlaybackController(params:, successCallback:, failCallback:)
Create playback controller
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
deleteInvestigation(investigationId:, successCallback:, failCallback:)
Delete investigation from the server
Parameters:
Name | Type | Description |
---|---|---|
investigationId: |
String | Id of investigation to delete |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
getAlarm(params:, successCallback:, failCallback:)
Gets a single alarm.
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
getAlarmDataSettings(successCallback:, failCallback:)
Gets settings for alarms (Priority, State).
Parameters:
Name | Type | Description |
---|---|---|
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
getAlarmList(params:, successCallback:, failCallback:)
Get alarms from server.
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
getAlarmUsers(alarmId:, successCallback:, failCallback:)
Gets list of users for the specified alarm. The alarm can be assigned to any one of these users.
Parameters:
Name | Type | Description |
---|---|---|
alarmId: |
String | Unique ID of the alarm |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
getAllInvestigations(successCallback:, failCallback:)
Get all investigations from server
Parameters:
Name | Type | Description |
---|---|---|
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
getBookmarks(params:, successCallback:, failCallback:)
Get bookmarks from server.
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
getInvestigation(id:, successCallback:, failCallback:)
Gets a specific investigation by its id
Parameters:
Name | Type | Description |
---|---|---|
id: |
string, the investigation id | |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
getThumbnailByTime(params, successCallback:, failCallback:)
Gets thumbnail by the given camera id and time.
Parameters:
Name | Type | Description |
---|---|---|
params |
Object | Object containing the following properties:
- {String} cameraId - Id of the requested camera thumbnail - {Number} time - Miliseconds since start of UNIX epoch, in UTC. - {Number} width - Max width of the requested camera thumbnail - {Number} height - Max height of the requested camera thumbnail |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
getUserInvestigations(successCallback:, failCallback:)
Get user investigations from server
Parameters:
Name | Type | Description |
---|---|---|
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
nextCarouselCamera(videoId:)
Request the next camera for the given carousel.
Parameters:
Name | Type | Description |
---|---|---|
videoId: |
String | Id of the video |
pauseCarousel(videoId:)
Pauses a carousel.
Parameters:
Name | Type | Description |
---|---|---|
videoId: |
string |
prevCarouselCamera(videoId:)
Request the next camera for the given carousel.
Parameters:
Name | Type | Description |
---|---|---|
videoId: |
string |
requestChallenges(params:, successCallback:, failCallback:)
Get new challenges from server
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
updateAlarm(params, successCallback:, failCallback:)
Updates an alarm.
Parameters:
Name | Type | Description |
---|---|---|
params |
||
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
updateInvestigation(params:, successCallback:, failCallback:)
Update investigation on the server
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
updateInvestigationData(params:, successCallback:, failCallback:)
Update investigation data on the server (avoids reexport).
Parameters:
Name | Type | Description |
---|---|---|
params: |
Object | Parameters to sent to the server |
successCallback: |
function | function that is called when the command execution was successful and the result is passed as a parameter. |
failCallback: |
function | function that is called when the command execution has failed and the error is passed as a parameter. |
(inner) acknowledgeAlarmCallback(connectionRequest)
Called when GetPermittedUsers reponse is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) addDirectStreamingStatus()
Adds the status of the Direct streaming to the XPMobileSDK.features object.
XPMobileSDK.features.DirectStreaming == 0 - DS not available
XPMobileSDK.features.DirectStreaming == 1 - do not enforce
XPMobileSDK.features.DirectStreaming == 2 - enforce whenever possible
XPMobileSDK.features.DirectStreaming == 3 - enforce for all clients
(inner) callbackAfterRequest(errorMessage:, callback)
A general callback to be called after a request operation.
Notifies that the request is finished, checks the response for errors, print error message if necessary and calls the callee callback with the appropriate argument(s).
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest. |
||
errorMessage: |
logged in the console in case of an error. | |
callback |
(inner) cancelInvestigationCallback(connectionRequest)
Called when CancelInvestigationUpdate reposne is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) changeMultipleStreamsCallback(connectionRequest)
Called when ChangeMultipleStreams reposne is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) connectionRequestResponseIsTerminal()
Tests if response of a request contains an error that is terminal for the connection, such as connection timeout error!
(inner) controlPTZCallback()
Called after ptzMove and ptzPreset response is returned.
(inner) createExportDownloadLinkCallback()
Called after createExportDownloadLink response is returned.
(inner) createInvestigationCallback(connectionRequest)
Called when CreateInvestigation reposne is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) createPlaybackControllerCallback(connectionRequest)
Called when CreatePlaybackController reposne is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) deleteBookmarkCallback()
Called after deleteBookmark response is returned.
(inner) deleteInvestigationCallback(connectionRequest)
Called when DeleteInvestigation reposne is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) deleteInvestigationExportCallback(connectionRequest)
Called when deleteInvestigationExport response is returned
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) getAlarmCallback(connectionRequest)
Called when GetAlarmList reponse is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) getAlarmDataSettingsCallback(connectionRequest)
Called when GetAlarmList reponse is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) getAlarmUsersCallback(connectionRequest)
Called when GetPermittedUsers reponse is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) getAlarmsCallback(connectionRequest)
Called when GetAlarmList reponse is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) getAllCamerasCallback(connectionRequest)
Called when getAllViews response is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) getAllExportsCallback()
Called after getAllExports response is returned.
(inner) getAllViewsCallback(connectionRequest)
Called when getAllViews response is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) getBookmarksCallback(connectionRequest)
Called when GetAlarmList reponse is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) getCameraCapabilitiesCallback()
Called after getCameraCapabilities response is returned.
(inner) getDBStartTimeCallback()
Called after getDBStartTime response is returned.
(inner) getExportCallback()
Called after getExport response is returned.
(inner) getFeatures(features)
Parses the features that are returned from server and puts them in local storage
Parameters:
Name | Type | Description |
---|---|---|
features |
object Features that the server is supporting |
(inner) getInvestigationCallback(connectionRequest)
Called when getInvestigation reponse is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) getInvestigationsCallback(connectionRequest)
Called when getAllInvestigations or getUserInvestigations reponse is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) getNextSequenceID()
Each command send to the server has a sequenceID which starts from 1 and is increased with every next request.
(inner) getServerStatusCallback(connectionRequest)
Called after getServerStatus command is executed
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) getThumbnailByTimeCallback()
Called after getThumbnailByTime response is returned.
(inner) getUserExportsCallback()
Called after getUserExports response is returned.
(inner) logOutCallback(connectionRequest)
logOut callback
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object XMLHttpResponse |
(inner) nextCarouselCameraCallback(connectionRequest)
Called when prevCarouselCamera response is returned
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) pauseCarouselCallback(connectionRequest)
Called when pauseCarousel response is returned
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) prevCarouselCameraCallback(connectionRequest)
Called when prevCarouselCamera response is returned
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) requestChallengesCallback(connectionRequest)
Called after RequestChallenges command is executed
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) resumeCarouselCallback(connectionRequest)
Called when resumeCarousel response is returned
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) scheduleLiveMessage()
Live message
Live message methods are used to "ping" the server with LiveMessage commands to keep the connection ID alive.
All commands sent to the server should cancel the live message and schedule it again on response. The idea is that if
there is a constant stream of communication going on with the server there is no point in sending live messages. Instead
we send it only if there is some period of time that we haven't sent any commands.
TODO possible bug: when we have video connections they consume a lot of AJAX calls. And the live messages may get queued.
If that happens it is possible to timeout the connection even though the video is still properly running and everything.
All these methods are private!
(inner) startInvestigationExportCallback(connectionRequest)
Called when startInvestigationExport response is returned
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) triggerOutputOrEventCallback()
If the command succeeded, the connectionRequest.options.successCallback is called without arguments if defined.
If the command failed, the connectionRequest.options.successCallback is called with the error code if defined.
(inner) updateAlarmCallback(connectionRequest)
Called when UpdateAlarm reponse is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |
(inner) updateInvestigationCallback(connectionRequest)
Called when CreateInvestigation reposne is received
Parameters:
Name | Type | Description |
---|---|---|
connectionRequest |
object Response from AXAJ call |