Socket
Book a DemoInstallSign in
Socket

@skyway-sdk/rtc-rpc-api-client

Package Overview
Dependencies
Maintainers
3
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@skyway-sdk/rtc-rpc-api-client - npm Package Compare versions

Comparing version

to
0.2.0-beta.11

26

dist/client.d.ts

@@ -1,2 +0,2 @@

import { Events, LogLevel, SkyWayError } from '@skyway-sdk/common';
import { LogLevel, SkyWayError } from '@skyway-sdk/common';
import model, { Channel, Codec, ContentType, Encoding, Member, Publication } from '@skyway-sdk/model';

@@ -18,4 +18,5 @@ import { ChannelEvent } from './event';

private _subscribingChannelEvents;
private _subscribingChannelVersions;
private readonly _httpClient;
readonly _events: Events;
private readonly _events;
readonly onEvent: import("@skyway-sdk/common").Event<{

@@ -32,6 +33,7 @@ channelId: string;

connect(): Promise<void>;
createChannel({ name, metadata, subscribeChannelEvents, appId, }: {
private _channelSubscribed;
private _isSubscribingChannel;
createChannel({ name, metadata, appId, }: {
name?: Channel['name'];
metadata?: string;
subscribeChannelEvents?: boolean;
appId: string;

@@ -42,7 +44,6 @@ }): Promise<{

}>;
findOrCreateChannel({ name, metadata, subscribeChannelEvents, appId, }: {
findOrCreateChannel({ name, metadata, appId, }: {
appId: string;
name?: Channel['name'];
metadata?: string;
subscribeChannelEvents?: boolean;
}): Promise<model.Channel>;

@@ -132,13 +133,12 @@ getChannel({ id, appId }: {

}): Promise<void>;
listChannelEvents({ channelId, limit, offset, appId, }: {
/** @description
* - 指定した Channel の Event を Subscribe していなければ Event が生じるたびに Notification が送られるようになります。
* - Subscribeした時点で、指定された offset (default to 0) の version から、最新の version までのイベントが送られます。
*/
subscribeChannelEvents({ appId, channelId, offset, }: {
appId: string;
channelId: string;
limit?: number;
channelId: Channel['id'];
offset?: number;
}): Promise<object & ChannelEvent[]>;
subscribeChannelEvents({ appId, channelId, }: {
appId: string;
channelId: Channel['id'];
}): Promise<void>;
}
//# sourceMappingURL=client.d.ts.map

@@ -27,2 +27,3 @@ "use strict";

this._subscribingChannelEvents = new Set();
this._subscribingChannelVersions = {};
this._httpClient = new common_1.HttpClient(`http${this.args.secure ? 's' : ''}://${this.args.host}`);

@@ -40,2 +41,4 @@ this._events = new common_1.Events();

const event = notify.params;
this._subscribingChannelVersions[event.data.channel.id] =
event.data.channel.version;
this.onEvent.emit({ channelId: event.data.channel.id, event });

@@ -93,3 +96,9 @@ }

const [appId, channelId] = s.split(':');
yield this.subscribeChannelEvents({ appId, channelId });
const offset = this._subscribingChannelVersions[channelId];
log.debug('subscribeChannelEvents', { offset });
yield this.subscribeChannelEvents({
appId,
channelId,
offset,
});
}));

@@ -99,3 +108,9 @@ });

}
createChannel({ name, metadata, subscribeChannelEvents, appId, }) {
_channelSubscribed(appId, channelId) {
this._subscribingChannelEvents.add(appId + ':' + channelId);
}
_isSubscribingChannel(appId, channelId) {
return this._subscribingChannelEvents.has(appId + ':' + channelId);
}
createChannel({ name, metadata, appId, }) {
return __awaiter(this, void 0, void 0, function* () {

@@ -105,13 +120,10 @@ const { channel } = yield this._rpc.request('createChannel', {

metadata,
subscribeChannelEvents,
appId,
authToken: this._token,
});
if (subscribeChannelEvents) {
this._subscribingChannelEvents.add(appId + ':' + channel.id);
}
this._channelSubscribed(appId, channel.id);
return channel;
});
}
findOrCreateChannel({ name, metadata, subscribeChannelEvents, appId, }) {
findOrCreateChannel({ name, metadata, appId, }) {
return __awaiter(this, void 0, void 0, function* () {

@@ -121,9 +133,6 @@ const { channel } = yield this._rpc.request('findOrCreateChannel', {

metadata,
subscribeChannelEvents,
appId,
authToken: this._token,
});
if (subscribeChannelEvents) {
this._subscribingChannelEvents.add(appId + ':' + channel.id);
}
this._channelSubscribed(appId, channel.id);
return channel;

@@ -139,2 +148,11 @@ });

});
// getChannelは暗黙的にEventがsubscribeされない
if (!this._isSubscribingChannel(appId, id)) {
yield this.subscribeChannelEvents({
appId,
channelId: id,
offset: res.channel.version,
});
this._channelSubscribed(appId, id);
}
return res.channel;

@@ -290,25 +308,13 @@ });

}
listChannelEvents({ channelId, limit, offset, appId, }) {
/** @description
* - 指定した Channel の Event を Subscribe していなければ Event が生じるたびに Notification が送られるようになります。
* - Subscribeした時点で、指定された offset (default to 0) の version から、最新の version までのイベントが送られます。
*/
subscribeChannelEvents({ appId, channelId, offset, }) {
return __awaiter(this, void 0, void 0, function* () {
limit = 100;
offset = 0;
return this._rpc.request('listChannelEvents', {
channelId,
limit,
offset,
yield this._rpc.request('subscribeChannelEvents', {
appId,
authToken: this._token,
});
});
}
subscribeChannelEvents({ appId, channelId, }) {
return __awaiter(this, void 0, void 0, function* () {
if (this._subscribingChannelEvents.has(appId + ':' + channelId)) {
return;
}
this._subscribingChannelEvents.add(appId + ':' + channelId);
yield this._rpc.notify('subscribeChannelEvents', {
appId,
authToken: this._token,
channelId,
offset,
});

@@ -315,0 +321,0 @@ });

@@ -125,2 +125,3 @@ "use strict";

if (this._ws.readyState === this._ws.CLOSED) {
log.warn('already closed');
return;

@@ -127,0 +128,0 @@ }

{
"name": "@skyway-sdk/rtc-rpc-api-client",
"version": "0.2.0-beta.10",
"version": "0.2.0-beta.11",
"description": "The official Next Generation JavaScript SDK for SkyWay",

@@ -5,0 +5,0 @@ "homepage": "https://beta.skyway.ntt.com/",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet