Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyoshiaki committed May 29, 2023
1 parent 2ad60a7 commit 3310df5
Show file tree
Hide file tree
Showing 31 changed files with 330 additions and 120 deletions.
8 changes: 4 additions & 4 deletions THIRD_PARTY_LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SOFTWARE.

---

@skyway-sdk/core@1.2.5
@skyway-sdk/core@1.3.0

MIT

Expand Down Expand Up @@ -68,7 +68,7 @@ MIT

---

@skyway-sdk/room@1.2.5
@skyway-sdk/room@1.3.0

MIT

Expand Down Expand Up @@ -192,7 +192,7 @@ SOFTWARE.

---

@skyway-sdk/sfu-bot@1.2.5
@skyway-sdk/sfu-bot@1.3.0

MIT

Expand Down Expand Up @@ -285,7 +285,7 @@ SOFTWARE.

---

@types/[email protected].7
@types/[email protected].8

MIT

Expand Down
46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@skyway-sdk/core",
"version": "1.2.5",
"version": "1.3.0",
"description": "The official Next Generation JavaScript SDK for SkyWay",
"homepage": "https://skyway.ntt.com/",
"repository": {
Expand Down Expand Up @@ -32,7 +32,7 @@
"graph": "dependency-cruiser --include-only '^src' --output-type dot src | dot -T svg > docs/dependencygraph.svg",
"pre:test": "cd ../../ && npm run build && cd packages/core",
"publish:npm": "npx can-npm-publish --verbose && npm run build && npm publish --access public",
"test-all": "npm run test-large && npm run test-middle && npm run test-small",
"test-all": "npm-run-all -p test-large test-middle test-small",
"test-large": "karma start ./karma.large.js --single-run --browsers chrome_headless_with_fake_device",
"test-large:dev": "karma start ./karma.large.js --browsers chrome_with_fake_device",
"test-middle": "karma start ./karma.middle.js --single-run --browsers chrome_headless_with_fake_device",
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export type SkyWayConfigOptions = {
timeout?: number;
turnPolicy?: TurnPolicy;
turnProtocol?: TurnProtocol;
/**
* @internal
* @description ms
* */
iceDisconnectBufferTimeout?: number;
};
token: { updateReminderSec?: number };
log: Partial<{ level: LogLevel; format: LogFormat }>;
Expand Down Expand Up @@ -71,6 +76,7 @@ export class ContextConfig implements SkyWayConfigOptions {
turnPolicy: 'enable',
turnProtocol: 'all',
encodedInsertableStreams: false,
iceDisconnectBufferTimeout: 5000,
};
token: Required<SkyWayConfigOptions['token']> = {
updateReminderSec: 30,
Expand Down
27 changes: 14 additions & 13 deletions packages/core/src/external/signaling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class SignalingSession {
readonly onConnectionFailed = new Event();
readonly onConnectionStateChanged = new Event<ConnectionState>();
readonly onMessage = new Event<MessageEvent>();
closed = false;

private _chunkedMessageBuffer: { [messageId: string]: string[] } = {};
private _backoffUpdateSkyWayAuthToken = new BackOff({
Expand Down Expand Up @@ -115,6 +116,7 @@ export class SignalingSession {
}

await reply({}).catch((e) => {
if (this.closed) return;
log.warn(
'failed to reply',
createWarnPayload({
Expand Down Expand Up @@ -179,7 +181,8 @@ export class SignalingSession {
log.debug('[end] connect signalingService');
}

disconnect() {
close() {
this.closed = true;
this._client.disconnect();
}

Expand Down Expand Up @@ -224,18 +227,16 @@ export class SignalingSession {
await this._client.request(target, chunkMessage as any, timeout / 1000);
}
} catch (error: any) {
if (target.state === 'joined') {
throw createError({
operationName: 'SignalingSession.send',
context: this.context,
info: { ...errors.internal, detail: 'signalingClient' },
error,
path: log.prefix,
payload: { target, data },
});
} else {
log.warn('target already left', error);
}
if (this.closed || target.state !== 'joined') return;

throw createError({
operationName: 'SignalingSession.send',
context: this.context,
info: { ...errors.internal, detail: 'signalingClient' },
error,
path: log.prefix,
payload: { target, data },
});
}
}
}
Expand Down
34 changes: 29 additions & 5 deletions packages/core/src/media/stream/local/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ import { Stream, WebRTCStats, ContentType } from '../base';
export abstract class LocalStreamBase implements Stream {
readonly side = 'local';
/**
* @deprecated
* @use Publication.onConnectionStateChanged
* @description [japanese] メディア通信の状態が変化した時に発火するイベント
*/
readonly onConnectionStateChanged = new Event<{
remoteMember: RemoteMember;
state: TransportConnectionState;
}>();
/**@internal */
readonly _onConnectionStateChanged = new Event<{
remoteMember: RemoteMember;
state: TransportConnectionState;
}>();
readonly id: string = uuidV4();
/**@internal */
_label = '';
Expand All @@ -28,9 +35,14 @@ export abstract class LocalStreamBase implements Stream {
_getStatsCallbacks: {
[remoteMemberId: string]: () => Promise<WebRTCStats>;
} = {};
private _connectionState: {
[remoteMemberId: string]: TransportConnectionState;
} = {};

/**@internal */
constructor(readonly contentType: ContentType) {}
constructor(readonly contentType: ContentType) {
this._onConnectionStateChanged.pipe(this.onConnectionStateChanged);
}

/**@internal */
_setLabel(label: string) {
Expand All @@ -50,6 +62,16 @@ export abstract class LocalStreamBase implements Stream {
return this._getTransportCallbacks[id]?.();
}

/**@internal */
_setConnectionState(
remoteMember: RemoteMember,
state: TransportConnectionState
) {
if (this._connectionState[remoteMember.id] === state) return;
this._connectionState[remoteMember.id] = state;
this._onConnectionStateChanged.emit({ remoteMember, state });
}

/**
* @deprecated
* @use Publication.getStats
Expand Down Expand Up @@ -101,14 +123,16 @@ export abstract class LocalStreamBase implements Stream {

/**@internal */
_getConnectionState(selector: Member | string): TransportConnectionState {
return this._getTransport(selector)?.connectionState ?? 'new';
const id = typeof selector === 'string' ? selector : selector.id;
return this._connectionState[id] ?? 'new';
}

/**@internal */
_getConnectionStateAll() {
return Object.entries(this._getTransportCallbacks).map(
([memberId, cb]) => ({ memberId, connectionState: cb().connectionState })
);
return Object.keys(this._getTransportCallbacks).map((memberId) => ({
memberId,
connectionState: this._getConnectionState(memberId),
}));
}

/**@internal */
Expand Down
18 changes: 16 additions & 2 deletions packages/core/src/media/stream/remote/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,27 @@ import { Stream, ContentType, WebRTCStats } from '../base';
export abstract class RemoteStreamBase implements Stream {
readonly side = 'remote';
/**
* @deprecated
* @use Subscription.onConnectionStateChanged
* @description [japanese] メディア通信の状態が変化した時に発火するイベント
*/
readonly onConnectionStateChanged = new Event<TransportConnectionState>();
/**@internal */
readonly _onConnectionStateChanged = new Event<TransportConnectionState>();
codec!: Codec;
private _connectionState: TransportConnectionState = 'new';

/**@internal */
constructor(readonly id: string, readonly contentType: ContentType) {
this._onConnectionStateChanged.pipe(this.onConnectionStateChanged);
}

/**@internal */
constructor(readonly id: string, readonly contentType: ContentType) {}
_setConnectionState(state: TransportConnectionState) {
if (this._connectionState === state) return;
this._connectionState = state;
this._onConnectionStateChanged.emit(state);
}

/**@internal */
_getTransport: () => Transport | undefined = () => undefined;
Expand Down Expand Up @@ -46,7 +60,7 @@ export abstract class RemoteStreamBase implements Stream {
}
/**@internal */
_getConnectionState() {
return this._getTransport()?.connectionState ?? 'new';
return this._connectionState;
}

/**@internal */
Expand Down
Loading

0 comments on commit 3310df5

Please sign in to comment.