Skip to content

Commit

Permalink
Pass Client UTC Offset inside join message over signalling channel (#…
Browse files Browse the repository at this point in the history
…2618)

* Pass Client UTC Offset inside join message over signalling channel

* Address comments of revision 1

* Address comments of revision 2
  • Loading branch information
aman-aguptaaa authored Mar 31, 2023
1 parent 4d205b5 commit 5799946
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 21 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [3.13.0] - 2023-03-28

### Added
- Send client UTC offset with attendee JOIN frame over signalling channel.

### Removed

Expand All @@ -17,7 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [3.12.0] - 2023-02-14

### Added
### Added

### Removed

Expand Down
36 changes: 18 additions & 18 deletions docs/classes/defaultsignalingclient.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ <h3>constructor</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L56">src/signalingclient/DefaultSignalingClient.ts:56</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L57">src/signalingclient/DefaultSignalingClient.ts:57</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand Down Expand Up @@ -163,7 +163,7 @@ <h3>close<wbr>Connection</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#closeconnection">closeConnection</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L228">src/signalingclient/DefaultSignalingClient.ts:228</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L230">src/signalingclient/DefaultSignalingClient.ts:230</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -189,7 +189,7 @@ <h3>demote<wbr>From<wbr>Primary<wbr>Meeting</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#demotefromprimarymeeting">demoteFromPrimaryMeeting</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L492">src/signalingclient/DefaultSignalingClient.ts:492</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L494">src/signalingclient/DefaultSignalingClient.ts:494</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -212,7 +212,7 @@ <h3>join</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#join">join</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L91">src/signalingclient/DefaultSignalingClient.ts:91</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L92">src/signalingclient/DefaultSignalingClient.ts:92</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -241,7 +241,7 @@ <h3>leave</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#leave">leave</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L204">src/signalingclient/DefaultSignalingClient.ts:204</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L206">src/signalingclient/DefaultSignalingClient.ts:206</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -264,7 +264,7 @@ <h3>mute</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#mute">mute</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L274">src/signalingclient/DefaultSignalingClient.ts:274</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L276">src/signalingclient/DefaultSignalingClient.ts:276</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -293,7 +293,7 @@ <h3>open<wbr>Connection</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#openconnection">openConnection</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L76">src/signalingclient/DefaultSignalingClient.ts:76</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L77">src/signalingclient/DefaultSignalingClient.ts:77</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -327,7 +327,7 @@ <h3>pause</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#pause">pause</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L283">src/signalingclient/DefaultSignalingClient.ts:283</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L285">src/signalingclient/DefaultSignalingClient.ts:285</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -356,7 +356,7 @@ <h3>ping<wbr>Pong</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#pingpong">pingPong</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L82">src/signalingclient/DefaultSignalingClient.ts:82</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L83">src/signalingclient/DefaultSignalingClient.ts:83</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -385,7 +385,7 @@ <h3>promote<wbr>ToPrimary<wbr>Meeting</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#promotetoprimarymeeting">promoteToPrimaryMeeting</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L477">src/signalingclient/DefaultSignalingClient.ts:477</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L479">src/signalingclient/DefaultSignalingClient.ts:479</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -419,7 +419,7 @@ <h3>ready</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#ready">ready</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L268">src/signalingclient/DefaultSignalingClient.ts:268</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L270">src/signalingclient/DefaultSignalingClient.ts:270</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -442,7 +442,7 @@ <h3>register<wbr>Observer</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#registerobserver">registerObserver</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L66">src/signalingclient/DefaultSignalingClient.ts:66</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L67">src/signalingclient/DefaultSignalingClient.ts:67</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -471,7 +471,7 @@ <h3>remote<wbr>Video<wbr>Update</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#remotevideoupdate">remoteVideoUpdate</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L175">src/signalingclient/DefaultSignalingClient.ts:175</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L177">src/signalingclient/DefaultSignalingClient.ts:177</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -507,7 +507,7 @@ <h3>remove<wbr>Observer</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#removeobserver">removeObserver</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L71">src/signalingclient/DefaultSignalingClient.ts:71</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L72">src/signalingclient/DefaultSignalingClient.ts:72</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -536,7 +536,7 @@ <h3>resume</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#resume">resume</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L291">src/signalingclient/DefaultSignalingClient.ts:291</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L293">src/signalingclient/DefaultSignalingClient.ts:293</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -565,7 +565,7 @@ <h3>send<wbr>Client<wbr>Metrics</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#sendclientmetrics">sendClientMetrics</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L214">src/signalingclient/DefaultSignalingClient.ts:214</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L216">src/signalingclient/DefaultSignalingClient.ts:216</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -594,7 +594,7 @@ <h3>send<wbr>Data<wbr>Message</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#senddatamessage">sendDataMessage</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L221">src/signalingclient/DefaultSignalingClient.ts:221</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L223">src/signalingclient/DefaultSignalingClient.ts:223</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -623,7 +623,7 @@ <h3>subscribe</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/signalingclient.html">SignalingClient</a>.<a href="../interfaces/signalingclient.html#subscribe">subscribe</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L125">src/signalingclient/DefaultSignalingClient.ts:125</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/signalingclient/DefaultSignalingClient.ts#L127">src/signalingclient/DefaultSignalingClient.ts:127</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down
1 change: 1 addition & 0 deletions protocol/SignalingProtocol.proto
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ message SdkClientDetails {
optional string platform_version = 6;
optional string client_source = 7;
optional string chime_sdk_version = 8;
optional string client_utc_offset = 9;
}

enum SdkServerSideNetworkAdaption {
Expand Down
2 changes: 1 addition & 1 deletion script/check-lockfile-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const lockFileVersion = require('../package-lock.json').lockfileVersion;
if (lockFileVersion === 2) {
process.exit(0);
} else {
console.log(`In-correct package-lock verson detected, should be 2, found ${lockFileVersion}`);
console.log(`In-correct package-lock version detected, should be 2, found ${lockFileVersion}`);
console.log('Check if you are using npm v7, if not update to npm v7 and re-run build:release');
process.exit(1);
}
2 changes: 2 additions & 0 deletions src/signalingclient/DefaultSignalingClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
SdkSubscribeFrame,
SdkVideoSubscriptionConfiguration,
} from '../signalingprotocol/SignalingProtocol.js';
import { getFormattedOffset } from '../utils/Utils';
import Versioning from '../versioning/Versioning';
import WebSocketAdapter from '../websocketadapter/WebSocketAdapter';
import WebSocketReadyState from '../websocketadapter/WebSocketReadyState';
Expand Down Expand Up @@ -99,6 +100,7 @@ export default class DefaultSignalingClient implements SignalingClient {
platformVersion: browserBehavior.version(),
clientSource: Versioning.sdkName,
chimeSdkVersion: Versioning.sdkVersion,
clientUtcOffset: getFormattedOffset(new Date().getTimezoneOffset()),
};
if (settings.applicationMetadata) {
const { appName, appVersion } = settings.applicationMetadata;
Expand Down
6 changes: 6 additions & 0 deletions src/signalingprotocol/SignalingProtocol.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@ export interface ISdkClientDetails {

/** SdkClientDetails chimeSdkVersion */
chimeSdkVersion?: (string|null);

/** SdkClientDetails clientUtcOffset */
clientUtcOffset?: (string|null);
}

/** Represents a SdkClientDetails. */
Expand Down Expand Up @@ -414,6 +417,9 @@ export class SdkClientDetails implements ISdkClientDetails {
/** SdkClientDetails chimeSdkVersion. */
public chimeSdkVersion: string;

/** SdkClientDetails clientUtcOffset. */
public clientUtcOffset: string;

/**
* Creates a new SdkClientDetails instance using the specified properties.
* @param [properties] Properties to set
Expand Down
22 changes: 22 additions & 0 deletions src/signalingprotocol/SignalingProtocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,7 @@ $root.SdkClientDetails = (function() {
* @property {string|null} [platformVersion] SdkClientDetails platformVersion
* @property {string|null} [clientSource] SdkClientDetails clientSource
* @property {string|null} [chimeSdkVersion] SdkClientDetails chimeSdkVersion
* @property {string|null} [clientUtcOffset] SdkClientDetails clientUtcOffset
*/

/**
Expand Down Expand Up @@ -1281,6 +1282,14 @@ $root.SdkClientDetails = (function() {
*/
SdkClientDetails.prototype.chimeSdkVersion = "";

/**
* SdkClientDetails clientUtcOffset.
* @member {string} clientUtcOffset
* @memberof SdkClientDetails
* @instance
*/
SdkClientDetails.prototype.clientUtcOffset = "";

/**
* Creates a new SdkClientDetails instance using the specified properties.
* @function create
Expand Down Expand Up @@ -1321,6 +1330,8 @@ $root.SdkClientDetails = (function() {
writer.uint32(/* id 7, wireType 2 =*/58).string(message.clientSource);
if (message.chimeSdkVersion != null && Object.hasOwnProperty.call(message, "chimeSdkVersion"))
writer.uint32(/* id 8, wireType 2 =*/66).string(message.chimeSdkVersion);
if (message.clientUtcOffset != null && Object.hasOwnProperty.call(message, "clientUtcOffset"))
writer.uint32(/* id 9, wireType 2 =*/74).string(message.clientUtcOffset);
return writer;
};

Expand Down Expand Up @@ -1379,6 +1390,9 @@ $root.SdkClientDetails = (function() {
case 8:
message.chimeSdkVersion = reader.string();
break;
case 9:
message.clientUtcOffset = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
Expand Down Expand Up @@ -1438,6 +1452,9 @@ $root.SdkClientDetails = (function() {
if (message.chimeSdkVersion != null && message.hasOwnProperty("chimeSdkVersion"))
if (!$util.isString(message.chimeSdkVersion))
return "chimeSdkVersion: string expected";
if (message.clientUtcOffset != null && message.hasOwnProperty("clientUtcOffset"))
if (!$util.isString(message.clientUtcOffset))
return "clientUtcOffset: string expected";
return null;
};

Expand Down Expand Up @@ -1469,6 +1486,8 @@ $root.SdkClientDetails = (function() {
message.clientSource = String(object.clientSource);
if (object.chimeSdkVersion != null)
message.chimeSdkVersion = String(object.chimeSdkVersion);
if (object.clientUtcOffset != null)
message.clientUtcOffset = String(object.clientUtcOffset);
return message;
};

Expand All @@ -1494,6 +1513,7 @@ $root.SdkClientDetails = (function() {
object.platformVersion = "";
object.clientSource = "";
object.chimeSdkVersion = "";
object.clientUtcOffset = "";
}
if (message.appName != null && message.hasOwnProperty("appName"))
object.appName = message.appName;
Expand All @@ -1511,6 +1531,8 @@ $root.SdkClientDetails = (function() {
object.clientSource = message.clientSource;
if (message.chimeSdkVersion != null && message.hasOwnProperty("chimeSdkVersion"))
object.chimeSdkVersion = message.chimeSdkVersion;
if (message.clientUtcOffset != null && message.hasOwnProperty("clientUtcOffset"))
object.clientUtcOffset = message.clientUtcOffset;
return object;
};

Expand Down
17 changes: 17 additions & 0 deletions src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,20 @@ export function toLowerCasePropertyNames(input: any): any {
return result;
}, {});
}

/**
* Get UTC offset in (+|-)HH:mm format
* E.g. For Asia/Calcutta timezone, +05:30 UTC offset value is returned
*/
export function getFormattedOffset(utcOffset: number): string {
const offset = Math.abs(utcOffset);
const offsetOperator = utcOffset < 0 ? '+' : '-';
const offsetHours = Math.floor(offset / 60)
.toString()
.padStart(2, '0');
const offsetMinutes = Math.floor(offset % 60)
.toString()
.padStart(2, '0');

return `${offsetOperator}${offsetHours}:${offsetMinutes}`;
}
Loading

0 comments on commit 5799946

Please sign in to comment.