Skip to content

Commit

Permalink
Merge pull request #229 from zelloptt/EET-382-Alarm-service-clients-o…
Browse files Browse the repository at this point in the history
…nboarding

EET-382|Alarm service clients onboarding
  • Loading branch information
EugeneP-Zello authored Jul 9, 2024
2 parents d6d0005 + dd71858 commit a76eea7
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 22 deletions.
3 changes: 3 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ Connecting to multiple channels (up to 100) is currently supported for Zello Wor
| `password` | string | (optional) Password to logon with. Required if username is provided.
| `channels` | array of strings | The list of names of the channels to connect to.
| `listen_only` | boolean | (optional) Set to `true` to connect in listen-only mode.
| `version` | string | (optional) Client version string. If not provided, the server will use the Channel API server version.
| `platform_type` | string | (optional) Client platform type, any string
| `platform_name` | string | (optional) Client platform name, any string. If includes `Gateway` or `Kiosk` (case-insensitive), the Zello Alarms service will track the online status of this client.

#### Request:

Expand Down
22 changes: 12 additions & 10 deletions sdks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,24 @@ When you create the `ZCC.Session` object, you provide it with the address for th
```javascript
var session = new ZCC.Session({
serverUrl: 'wss://zellowork.io/ws/[yournetworkname]',
username: [username],
password: [password]
channel: [channel],
authToken: [authToken],
maxConnectAttempts: 5,
connectRetryTimeoutMs: 1000,
autoSendAudio: true
);
serverUrl: 'wss://zellowork.io/ws/[yournetworkname]',
username: [username],
password: [password],
channel: [channel],
authToken: [authToken],
maxConnectAttempts: 5,
connectRetryTimeoutMs: 1000,
autoSendAudio: true
});
session.connect().then(function() {
// connected
});
```

`serverURL` can be one of the [API entry points](https://github.com/zelloptt/zello-channel-api/blob/master/API.md#api-entry-points).
`serverURL` can be one of the [API entry points](https://github.com/zelloptt/zello-channel-api/blob/master/API.md#api-entry-points).
You may want to provide any string as a version of your app as `version`
You can also provide `platformName` string to identify your platform. If the provided value include "gateway" substring, Zello Alarm service will track the online status of this client (if enabled).

### Sending voice messages

Expand Down
2 changes: 1 addition & 1 deletion sdks/js/dist/zcc.session.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion sdks/js/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "zello-channels-js-sdk",
"copyright": "Copyright © 2023 Zello Inc.",
"version": "1.0.2",
"version": "1.1.2",
"description": "Zello channels JS SDK",
"main": "index.js",
"homepage": "https://zello.com/work",
"scripts": {
"build": "cross-env NODE_ENV=production npx webpack",
"build-dev": "cross-env NODE_ENV=development npx webpack",
"watch": "cross-env npx webpack --watch",
"docs": "npx jsdoc -d ./../../docs/js/ src/classes/"
},
Expand Down
10 changes: 10 additions & 0 deletions sdks/js/src/classes/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Session extends Emitter {
this.wsConnection = null;
this.refreshToken = null;
this.seq = 0;
this.version = this.options.version || VERSION;
this.maxConnectAttempts = this.options.maxConnectAttempts;
this.connectAttempts = this.maxConnectAttempts;
this.connectRetryTimeoutMs = this.options.connectRetryTimeoutMs;
Expand Down Expand Up @@ -136,6 +137,7 @@ session.connect(function(err, result) {
dfd.resolve(result);
})
.catch((err) => {
this.disconnect(); // this prevents reconnect on ws.close event
if (this.connectAttempts) {
this.clearExistingReconnectTimeout();
this.reconnectTimeout = setTimeout(() => {
Expand Down Expand Up @@ -225,6 +227,14 @@ session.connect(function(err, result) {
params.password = this.options.password;
}

params.version = this.version;
if (this.options.platformName) {
params.platform_name = this.options.platformName;
}
if (this.options.platformType) {
params.platform_type = this.options.platformType;
}

let callback = (err, data) => {
if (err) {
dfd.reject(err);
Expand Down
19 changes: 10 additions & 9 deletions sdks/js/tests/test-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ var streamId = null;


describe('session', function() {
it ('wrong password should fail to login', function(done) {
it('wrong password should fail to login', function(done) {
session = globals.createSessionAWrongPassword();
session.connect(function(err, result) {
chai.expect(err).to.not.be.null;
done();
chai.expect(err).to.not.be.null;
done();
});
});

Expand All @@ -33,13 +33,14 @@ describe('session', function() {

it('should fail to start stream with wrong params', function(done) {
session = globals.createSessionA();
session.connect()
.then(function() {
session.startStream({}, function(err) {
chai.expect(err).to.not.be.null;
done();
})
session.on('status', function(result) {
chai.expect(result.status).to.equal('online');
session.startStream({}, function(err) {
chai.expect(err).to.not.be.null;
done();
});
});
session.connect();
});

it('should start stream with correct params', function(done) {
Expand Down
8 changes: 7 additions & 1 deletion sdks/js/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path');
const settings = require('./settings');
const TerserPlugin = require("terser-webpack-plugin");
const webpack = require('webpack');

let entryFiles = {
'Sdk': './src/classes/sdk.js',
Expand Down Expand Up @@ -88,5 +89,10 @@ module.exports = {
}
}
]
}
},
plugins: [
new webpack.DefinePlugin({
VERSION: JSON.stringify(require("./package.json").version),
}),
],
};

0 comments on commit a76eea7

Please sign in to comment.