From f2823911027273be6c343fb413383fe9ebb7a7ac Mon Sep 17 00:00:00 2001 From: Billy Lindeman Date: Wed, 30 Mar 2022 11:00:05 -0700 Subject: [PATCH] 1.8.2 --- package-lock.json | 4 +- package.json | 2 +- src/_library/apps/room/proto/room_pb.d.ts | 358 ++++---- .../apps/room/proto/room_pb_service.d.ts | 41 +- src/_library/proto/ion/ion_pb.d.ts | 36 +- src/_library/proto/ion/ion_pb_service.d.ts | 1 - src/_library/proto/rtc/rtc_pb.d.ts | 195 +++-- src/_library/proto/rtc/rtc_pb_service.d.ts | 9 +- src/_library/proto/sfu/sfu_pb.d.ts | 67 +- src/_library/proto/sfu/sfu_pb_service.d.ts | 9 +- src/connector/index.ts | 52 +- src/connector/ion.ts | 106 +-- src/connector/room.ts | 580 ++++++------- src/connector/rtc.ts | 798 +++++++++--------- src/signal/grpc-web-impl.ts | 3 +- src/stream.ts | 2 +- 16 files changed, 1136 insertions(+), 1127 deletions(-) diff --git a/package-lock.json b/package-lock.json index bd844bf2..4651b3f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "ion-sdk-js", - "version": "1.8.1", + "version": "1.8.2", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "1.8.1", + "version": "1.8.2", "license": "MIT", "dependencies": { "@grpc/grpc-js": "^1.3.7", diff --git a/package.json b/package.json index c68f5bb0..ccdb4838 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ion-sdk-js", - "version": "1.8.1", + "version": "1.8.2", "description": "A js sdk for ion-sfu or ion", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/_library/apps/room/proto/room_pb.d.ts b/src/_library/apps/room/proto/room_pb.d.ts index f762ac8e..fc954cbc 100644 --- a/src/_library/apps/room/proto/room_pb.d.ts +++ b/src/_library/apps/room/proto/room_pb.d.ts @@ -1,7 +1,7 @@ // package: room // file: apps/room/proto/room.proto -import * as jspb from "google-protobuf"; +import * as jspb from 'google-protobuf'; export class Error extends jspb.Message { getCode(): ErrorTypeMap[keyof ErrorTypeMap]; @@ -13,8 +13,8 @@ export class Error extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Error.AsObject; static toObject(includeInstance: boolean, msg: Error): Error.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Error, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Error; static deserializeBinaryFromReader(message: Error, reader: jspb.BinaryReader): Error; @@ -22,9 +22,9 @@ export class Error extends jspb.Message { export namespace Error { export type AsObject = { - code: ErrorTypeMap[keyof ErrorTypeMap], - reason: string, - } + code: ErrorTypeMap[keyof ErrorTypeMap]; + reason: string; + }; } export class Request extends jspb.Message { @@ -47,8 +47,8 @@ export class Request extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Request.AsObject; static toObject(includeInstance: boolean, msg: Request): Request.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Request, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Request; static deserializeBinaryFromReader(message: Request, reader: jspb.BinaryReader): Request; @@ -56,10 +56,10 @@ export class Request extends jspb.Message { export namespace Request { export type AsObject = { - join?: JoinRequest.AsObject, - leave?: LeaveRequest.AsObject, - sendmessage?: SendMessageRequest.AsObject, - } + join?: JoinRequest.AsObject; + leave?: LeaveRequest.AsObject; + sendmessage?: SendMessageRequest.AsObject; + }; export enum PayloadCase { PAYLOAD_NOT_SET = 0, @@ -109,8 +109,8 @@ export class Reply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Reply.AsObject; static toObject(includeInstance: boolean, msg: Reply): Reply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Reply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Reply; static deserializeBinaryFromReader(message: Reply, reader: jspb.BinaryReader): Reply; @@ -118,14 +118,14 @@ export class Reply extends jspb.Message { export namespace Reply { export type AsObject = { - join?: JoinReply.AsObject, - leave?: LeaveReply.AsObject, - sendmessage?: SendMessageReply.AsObject, - peer?: PeerEvent.AsObject, - message?: Message.AsObject, - disconnect?: Disconnect.AsObject, - room?: Room.AsObject, - } + join?: JoinReply.AsObject; + leave?: LeaveReply.AsObject; + sendmessage?: SendMessageReply.AsObject; + peer?: PeerEvent.AsObject; + message?: Message.AsObject; + disconnect?: Disconnect.AsObject; + room?: Room.AsObject; + }; export enum PayloadCase { PAYLOAD_NOT_SET = 0, @@ -148,8 +148,8 @@ export class CreateRoomRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): CreateRoomRequest.AsObject; static toObject(includeInstance: boolean, msg: CreateRoomRequest): CreateRoomRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: CreateRoomRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): CreateRoomRequest; static deserializeBinaryFromReader(message: CreateRoomRequest, reader: jspb.BinaryReader): CreateRoomRequest; @@ -157,8 +157,8 @@ export class CreateRoomRequest extends jspb.Message { export namespace CreateRoomRequest { export type AsObject = { - room?: Room.AsObject, - } + room?: Room.AsObject; + }; } export class CreateRoomReply extends jspb.Message { @@ -173,8 +173,8 @@ export class CreateRoomReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): CreateRoomReply.AsObject; static toObject(includeInstance: boolean, msg: CreateRoomReply): CreateRoomReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: CreateRoomReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): CreateRoomReply; static deserializeBinaryFromReader(message: CreateRoomReply, reader: jspb.BinaryReader): CreateRoomReply; @@ -182,9 +182,9 @@ export class CreateRoomReply extends jspb.Message { export namespace CreateRoomReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - } + success: boolean; + error?: Error.AsObject; + }; } export class DeleteRoomRequest extends jspb.Message { @@ -194,8 +194,8 @@ export class DeleteRoomRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): DeleteRoomRequest.AsObject; static toObject(includeInstance: boolean, msg: DeleteRoomRequest): DeleteRoomRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: DeleteRoomRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): DeleteRoomRequest; static deserializeBinaryFromReader(message: DeleteRoomRequest, reader: jspb.BinaryReader): DeleteRoomRequest; @@ -203,8 +203,8 @@ export class DeleteRoomRequest extends jspb.Message { export namespace DeleteRoomRequest { export type AsObject = { - sid: string, - } + sid: string; + }; } export class DeleteRoomReply extends jspb.Message { @@ -219,8 +219,8 @@ export class DeleteRoomReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): DeleteRoomReply.AsObject; static toObject(includeInstance: boolean, msg: DeleteRoomReply): DeleteRoomReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: DeleteRoomReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): DeleteRoomReply; static deserializeBinaryFromReader(message: DeleteRoomReply, reader: jspb.BinaryReader): DeleteRoomReply; @@ -228,9 +228,9 @@ export class DeleteRoomReply extends jspb.Message { export namespace DeleteRoomReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - } + success: boolean; + error?: Error.AsObject; + }; } export class JoinRequest extends jspb.Message { @@ -245,8 +245,8 @@ export class JoinRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): JoinRequest.AsObject; static toObject(includeInstance: boolean, msg: JoinRequest): JoinRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: JoinRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): JoinRequest; static deserializeBinaryFromReader(message: JoinRequest, reader: jspb.BinaryReader): JoinRequest; @@ -254,9 +254,9 @@ export class JoinRequest extends jspb.Message { export namespace JoinRequest { export type AsObject = { - peer?: Peer.AsObject, - password: string, - } + peer?: Peer.AsObject; + password: string; + }; } export class Room extends jspb.Message { @@ -281,8 +281,8 @@ export class Room extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Room.AsObject; static toObject(includeInstance: boolean, msg: Room): Room.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Room, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Room; static deserializeBinaryFromReader(message: Room, reader: jspb.BinaryReader): Room; @@ -290,13 +290,13 @@ export class Room extends jspb.Message { export namespace Room { export type AsObject = { - sid: string, - name: string, - lock: boolean, - password: string, - description: string, - maxpeers: number, - } + sid: string; + name: string; + lock: boolean; + password: string; + description: string; + maxpeers: number; + }; } export class JoinReply extends jspb.Message { @@ -319,8 +319,8 @@ export class JoinReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): JoinReply.AsObject; static toObject(includeInstance: boolean, msg: JoinReply): JoinReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: JoinReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): JoinReply; static deserializeBinaryFromReader(message: JoinReply, reader: jspb.BinaryReader): JoinReply; @@ -328,11 +328,11 @@ export class JoinReply extends jspb.Message { export namespace JoinReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - role: RoleMap[keyof RoleMap], - room?: Room.AsObject, - } + success: boolean; + error?: Error.AsObject; + role: RoleMap[keyof RoleMap]; + room?: Room.AsObject; + }; } export class LeaveRequest extends jspb.Message { @@ -345,8 +345,8 @@ export class LeaveRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): LeaveRequest.AsObject; static toObject(includeInstance: boolean, msg: LeaveRequest): LeaveRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: LeaveRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): LeaveRequest; static deserializeBinaryFromReader(message: LeaveRequest, reader: jspb.BinaryReader): LeaveRequest; @@ -354,9 +354,9 @@ export class LeaveRequest extends jspb.Message { export namespace LeaveRequest { export type AsObject = { - sid: string, - uid: string, - } + sid: string; + uid: string; + }; } export class LeaveReply extends jspb.Message { @@ -371,8 +371,8 @@ export class LeaveReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): LeaveReply.AsObject; static toObject(includeInstance: boolean, msg: LeaveReply): LeaveReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: LeaveReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): LeaveReply; static deserializeBinaryFromReader(message: LeaveReply, reader: jspb.BinaryReader): LeaveReply; @@ -380,9 +380,9 @@ export class LeaveReply extends jspb.Message { export namespace LeaveReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - } + success: boolean; + error?: Error.AsObject; + }; } export class Peer extends jspb.Message { @@ -421,8 +421,8 @@ export class Peer extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Peer.AsObject; static toObject(includeInstance: boolean, msg: Peer): Peer.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Peer, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Peer; static deserializeBinaryFromReader(message: Peer, reader: jspb.BinaryReader): Peer; @@ -430,17 +430,17 @@ export class Peer extends jspb.Message { export namespace Peer { export type AsObject = { - sid: string, - uid: string, - displayname: string, - extrainfo: Uint8Array | string, - destination: string, - role: RoleMap[keyof RoleMap], - protocol: ProtocolMap[keyof ProtocolMap], - avatar: string, - direction: Peer.DirectionMap[keyof Peer.DirectionMap], - vendor: string, - } + sid: string; + uid: string; + displayname: string; + extrainfo: Uint8Array | string; + destination: string; + role: RoleMap[keyof RoleMap]; + protocol: ProtocolMap[keyof ProtocolMap]; + avatar: string; + direction: Peer.DirectionMap[keyof Peer.DirectionMap]; + vendor: string; + }; export interface DirectionMap { INCOMING: 0; @@ -460,8 +460,8 @@ export class AddPeerRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): AddPeerRequest.AsObject; static toObject(includeInstance: boolean, msg: AddPeerRequest): AddPeerRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: AddPeerRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): AddPeerRequest; static deserializeBinaryFromReader(message: AddPeerRequest, reader: jspb.BinaryReader): AddPeerRequest; @@ -469,8 +469,8 @@ export class AddPeerRequest extends jspb.Message { export namespace AddPeerRequest { export type AsObject = { - peer?: Peer.AsObject, - } + peer?: Peer.AsObject; + }; } export class AddPeerReply extends jspb.Message { @@ -485,8 +485,8 @@ export class AddPeerReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): AddPeerReply.AsObject; static toObject(includeInstance: boolean, msg: AddPeerReply): AddPeerReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: AddPeerReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): AddPeerReply; static deserializeBinaryFromReader(message: AddPeerReply, reader: jspb.BinaryReader): AddPeerReply; @@ -494,9 +494,9 @@ export class AddPeerReply extends jspb.Message { export namespace AddPeerReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - } + success: boolean; + error?: Error.AsObject; + }; } export class GetPeersRequest extends jspb.Message { @@ -506,8 +506,8 @@ export class GetPeersRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): GetPeersRequest.AsObject; static toObject(includeInstance: boolean, msg: GetPeersRequest): GetPeersRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: GetPeersRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): GetPeersRequest; static deserializeBinaryFromReader(message: GetPeersRequest, reader: jspb.BinaryReader): GetPeersRequest; @@ -515,8 +515,8 @@ export class GetPeersRequest extends jspb.Message { export namespace GetPeersRequest { export type AsObject = { - sid: string, - } + sid: string; + }; } export class GetPeersReply extends jspb.Message { @@ -536,8 +536,8 @@ export class GetPeersReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): GetPeersReply.AsObject; static toObject(includeInstance: boolean, msg: GetPeersReply): GetPeersReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: GetPeersReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): GetPeersReply; static deserializeBinaryFromReader(message: GetPeersReply, reader: jspb.BinaryReader): GetPeersReply; @@ -545,10 +545,10 @@ export class GetPeersReply extends jspb.Message { export namespace GetPeersReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - peersList: Array, - } + success: boolean; + error?: Error.AsObject; + peersList: Array; + }; } export class Message extends jspb.Message { @@ -569,8 +569,8 @@ export class Message extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Message.AsObject; static toObject(includeInstance: boolean, msg: Message): Message.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Message, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Message; static deserializeBinaryFromReader(message: Message, reader: jspb.BinaryReader): Message; @@ -578,11 +578,11 @@ export class Message extends jspb.Message { export namespace Message { export type AsObject = { - from: string, - to: string, - type: string, - payload: Uint8Array | string, - } + from: string; + to: string; + type: string; + payload: Uint8Array | string; + }; } export class SendMessageRequest extends jspb.Message { @@ -597,8 +597,8 @@ export class SendMessageRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): SendMessageRequest.AsObject; static toObject(includeInstance: boolean, msg: SendMessageRequest): SendMessageRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: SendMessageRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): SendMessageRequest; static deserializeBinaryFromReader(message: SendMessageRequest, reader: jspb.BinaryReader): SendMessageRequest; @@ -606,9 +606,9 @@ export class SendMessageRequest extends jspb.Message { export namespace SendMessageRequest { export type AsObject = { - sid: string, - message?: Message.AsObject, - } + sid: string; + message?: Message.AsObject; + }; } export class SendMessageReply extends jspb.Message { @@ -623,8 +623,8 @@ export class SendMessageReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): SendMessageReply.AsObject; static toObject(includeInstance: boolean, msg: SendMessageReply): SendMessageReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: SendMessageReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): SendMessageReply; static deserializeBinaryFromReader(message: SendMessageReply, reader: jspb.BinaryReader): SendMessageReply; @@ -632,9 +632,9 @@ export class SendMessageReply extends jspb.Message { export namespace SendMessageReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - } + success: boolean; + error?: Error.AsObject; + }; } export class Disconnect extends jspb.Message { @@ -647,8 +647,8 @@ export class Disconnect extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Disconnect.AsObject; static toObject(includeInstance: boolean, msg: Disconnect): Disconnect.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Disconnect, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Disconnect; static deserializeBinaryFromReader(message: Disconnect, reader: jspb.BinaryReader): Disconnect; @@ -656,9 +656,9 @@ export class Disconnect extends jspb.Message { export namespace Disconnect { export type AsObject = { - sid: string, - reason: string, - } + sid: string; + reason: string; + }; } export class PeerEvent extends jspb.Message { @@ -673,8 +673,8 @@ export class PeerEvent extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): PeerEvent.AsObject; static toObject(includeInstance: boolean, msg: PeerEvent): PeerEvent.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: PeerEvent, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): PeerEvent; static deserializeBinaryFromReader(message: PeerEvent, reader: jspb.BinaryReader): PeerEvent; @@ -682,9 +682,9 @@ export class PeerEvent extends jspb.Message { export namespace PeerEvent { export type AsObject = { - peer?: Peer.AsObject, - state: PeerStateMap[keyof PeerStateMap], - } + peer?: Peer.AsObject; + state: PeerStateMap[keyof PeerStateMap]; + }; } export class UpdateRoomRequest extends jspb.Message { @@ -696,8 +696,8 @@ export class UpdateRoomRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): UpdateRoomRequest.AsObject; static toObject(includeInstance: boolean, msg: UpdateRoomRequest): UpdateRoomRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: UpdateRoomRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): UpdateRoomRequest; static deserializeBinaryFromReader(message: UpdateRoomRequest, reader: jspb.BinaryReader): UpdateRoomRequest; @@ -705,8 +705,8 @@ export class UpdateRoomRequest extends jspb.Message { export namespace UpdateRoomRequest { export type AsObject = { - room?: Room.AsObject, - } + room?: Room.AsObject; + }; } export class UpdateRoomReply extends jspb.Message { @@ -721,8 +721,8 @@ export class UpdateRoomReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): UpdateRoomReply.AsObject; static toObject(includeInstance: boolean, msg: UpdateRoomReply): UpdateRoomReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: UpdateRoomReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): UpdateRoomReply; static deserializeBinaryFromReader(message: UpdateRoomReply, reader: jspb.BinaryReader): UpdateRoomReply; @@ -730,9 +730,9 @@ export class UpdateRoomReply extends jspb.Message { export namespace UpdateRoomReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - } + success: boolean; + error?: Error.AsObject; + }; } export class EndRoomRequest extends jspb.Message { @@ -748,8 +748,8 @@ export class EndRoomRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): EndRoomRequest.AsObject; static toObject(includeInstance: boolean, msg: EndRoomRequest): EndRoomRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: EndRoomRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): EndRoomRequest; static deserializeBinaryFromReader(message: EndRoomRequest, reader: jspb.BinaryReader): EndRoomRequest; @@ -757,10 +757,10 @@ export class EndRoomRequest extends jspb.Message { export namespace EndRoomRequest { export type AsObject = { - sid: string, - reason: string, - pb_delete: boolean, - } + sid: string; + reason: string; + pb_delete: boolean; + }; } export class EndRoomReply extends jspb.Message { @@ -775,8 +775,8 @@ export class EndRoomReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): EndRoomReply.AsObject; static toObject(includeInstance: boolean, msg: EndRoomReply): EndRoomReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: EndRoomReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): EndRoomReply; static deserializeBinaryFromReader(message: EndRoomReply, reader: jspb.BinaryReader): EndRoomReply; @@ -784,25 +784,24 @@ export class EndRoomReply extends jspb.Message { export namespace EndRoomReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - } + success: boolean; + error?: Error.AsObject; + }; } export class GetRoomsRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): GetRoomsRequest.AsObject; static toObject(includeInstance: boolean, msg: GetRoomsRequest): GetRoomsRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: GetRoomsRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): GetRoomsRequest; static deserializeBinaryFromReader(message: GetRoomsRequest, reader: jspb.BinaryReader): GetRoomsRequest; } export namespace GetRoomsRequest { - export type AsObject = { - } + export type AsObject = {}; } export class GetRoomsReply extends jspb.Message { @@ -822,8 +821,8 @@ export class GetRoomsReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): GetRoomsReply.AsObject; static toObject(includeInstance: boolean, msg: GetRoomsReply): GetRoomsReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: GetRoomsReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): GetRoomsReply; static deserializeBinaryFromReader(message: GetRoomsReply, reader: jspb.BinaryReader): GetRoomsReply; @@ -831,10 +830,10 @@ export class GetRoomsReply extends jspb.Message { export namespace GetRoomsReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - roomsList: Array, - } + success: boolean; + error?: Error.AsObject; + roomsList: Array; + }; } export class UpdatePeerRequest extends jspb.Message { @@ -846,8 +845,8 @@ export class UpdatePeerRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): UpdatePeerRequest.AsObject; static toObject(includeInstance: boolean, msg: UpdatePeerRequest): UpdatePeerRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: UpdatePeerRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): UpdatePeerRequest; static deserializeBinaryFromReader(message: UpdatePeerRequest, reader: jspb.BinaryReader): UpdatePeerRequest; @@ -855,8 +854,8 @@ export class UpdatePeerRequest extends jspb.Message { export namespace UpdatePeerRequest { export type AsObject = { - peer?: Peer.AsObject, - } + peer?: Peer.AsObject; + }; } export class UpdatePeerReply extends jspb.Message { @@ -871,8 +870,8 @@ export class UpdatePeerReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): UpdatePeerReply.AsObject; static toObject(includeInstance: boolean, msg: UpdatePeerReply): UpdatePeerReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: UpdatePeerReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): UpdatePeerReply; static deserializeBinaryFromReader(message: UpdatePeerReply, reader: jspb.BinaryReader): UpdatePeerReply; @@ -880,9 +879,9 @@ export class UpdatePeerReply extends jspb.Message { export namespace UpdatePeerReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - } + success: boolean; + error?: Error.AsObject; + }; } export class RemovePeerRequest extends jspb.Message { @@ -895,8 +894,8 @@ export class RemovePeerRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): RemovePeerRequest.AsObject; static toObject(includeInstance: boolean, msg: RemovePeerRequest): RemovePeerRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: RemovePeerRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): RemovePeerRequest; static deserializeBinaryFromReader(message: RemovePeerRequest, reader: jspb.BinaryReader): RemovePeerRequest; @@ -904,9 +903,9 @@ export class RemovePeerRequest extends jspb.Message { export namespace RemovePeerRequest { export type AsObject = { - sid: string, - uid: string, - } + sid: string; + uid: string; + }; } export class RemovePeerReply extends jspb.Message { @@ -921,8 +920,8 @@ export class RemovePeerReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): RemovePeerReply.AsObject; static toObject(includeInstance: boolean, msg: RemovePeerReply): RemovePeerReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: RemovePeerReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): RemovePeerReply; static deserializeBinaryFromReader(message: RemovePeerReply, reader: jspb.BinaryReader): RemovePeerReply; @@ -930,9 +929,9 @@ export class RemovePeerReply extends jspb.Message { export namespace RemovePeerReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - } + success: boolean; + error?: Error.AsObject; + }; } export interface ErrorTypeMap { @@ -975,4 +974,3 @@ export interface PeerStateMap { } export const PeerState: PeerStateMap; - diff --git a/src/_library/apps/room/proto/room_pb_service.d.ts b/src/_library/apps/room/proto/room_pb_service.d.ts index 6e8671a4..f886664e 100644 --- a/src/_library/apps/room/proto/room_pb_service.d.ts +++ b/src/_library/apps/room/proto/room_pb_service.d.ts @@ -1,8 +1,8 @@ // package: room // file: apps/room/proto/room.proto -import * as apps_room_proto_room_pb from "../../../apps/room/proto/room_pb"; -import {grpc} from "@improbable-eng/grpc-web"; +import * as apps_room_proto_room_pb from '../../../apps/room/proto/room_pb'; +import { grpc } from '@improbable-eng/grpc-web'; type RoomServiceCreateRoom = { readonly methodName: string; @@ -102,8 +102,8 @@ export class RoomSignal { static readonly Signal: RoomSignalSignal; } -export type ServiceError = { message: string, code: number; metadata: grpc.Metadata } -export type Status = { details: string, code: number; metadata: grpc.Metadata } +export type ServiceError = { message: string; code: number; metadata: grpc.Metadata }; +export type Status = { details: string; code: number; metadata: grpc.Metadata }; interface UnaryResponse { cancel(): void; @@ -137,74 +137,74 @@ export class RoomServiceClient { createRoom( requestMessage: apps_room_proto_room_pb.CreateRoomRequest, metadata: grpc.Metadata, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.CreateRoomReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.CreateRoomReply | null) => void, ): UnaryResponse; createRoom( requestMessage: apps_room_proto_room_pb.CreateRoomRequest, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.CreateRoomReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.CreateRoomReply | null) => void, ): UnaryResponse; updateRoom( requestMessage: apps_room_proto_room_pb.UpdateRoomRequest, metadata: grpc.Metadata, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.UpdateRoomReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.UpdateRoomReply | null) => void, ): UnaryResponse; updateRoom( requestMessage: apps_room_proto_room_pb.UpdateRoomRequest, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.UpdateRoomReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.UpdateRoomReply | null) => void, ): UnaryResponse; endRoom( requestMessage: apps_room_proto_room_pb.EndRoomRequest, metadata: grpc.Metadata, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.EndRoomReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.EndRoomReply | null) => void, ): UnaryResponse; endRoom( requestMessage: apps_room_proto_room_pb.EndRoomRequest, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.EndRoomReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.EndRoomReply | null) => void, ): UnaryResponse; getRooms( requestMessage: apps_room_proto_room_pb.GetRoomsRequest, metadata: grpc.Metadata, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.GetRoomsReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.GetRoomsReply | null) => void, ): UnaryResponse; getRooms( requestMessage: apps_room_proto_room_pb.GetRoomsRequest, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.GetRoomsReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.GetRoomsReply | null) => void, ): UnaryResponse; addPeer( requestMessage: apps_room_proto_room_pb.AddPeerRequest, metadata: grpc.Metadata, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.AddPeerReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.AddPeerReply | null) => void, ): UnaryResponse; addPeer( requestMessage: apps_room_proto_room_pb.AddPeerRequest, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.AddPeerReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.AddPeerReply | null) => void, ): UnaryResponse; updatePeer( requestMessage: apps_room_proto_room_pb.UpdatePeerRequest, metadata: grpc.Metadata, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.UpdatePeerReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.UpdatePeerReply | null) => void, ): UnaryResponse; updatePeer( requestMessage: apps_room_proto_room_pb.UpdatePeerRequest, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.UpdatePeerReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.UpdatePeerReply | null) => void, ): UnaryResponse; removePeer( requestMessage: apps_room_proto_room_pb.RemovePeerRequest, metadata: grpc.Metadata, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.RemovePeerReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.RemovePeerReply | null) => void, ): UnaryResponse; removePeer( requestMessage: apps_room_proto_room_pb.RemovePeerRequest, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.RemovePeerReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.RemovePeerReply | null) => void, ): UnaryResponse; getPeers( requestMessage: apps_room_proto_room_pb.GetPeersRequest, metadata: grpc.Metadata, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.GetPeersReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.GetPeersReply | null) => void, ): UnaryResponse; getPeers( requestMessage: apps_room_proto_room_pb.GetPeersRequest, - callback: (error: ServiceError|null, responseMessage: apps_room_proto_room_pb.GetPeersReply|null) => void + callback: (error: ServiceError | null, responseMessage: apps_room_proto_room_pb.GetPeersReply | null) => void, ): UnaryResponse; } @@ -214,4 +214,3 @@ export class RoomSignalClient { constructor(serviceHost: string, options?: grpc.RpcOptions); signal(metadata?: grpc.Metadata): BidirectionalStream; } - diff --git a/src/_library/proto/ion/ion_pb.d.ts b/src/_library/proto/ion/ion_pb.d.ts index c5482274..7517bdc1 100644 --- a/src/_library/proto/ion/ion_pb.d.ts +++ b/src/_library/proto/ion/ion_pb.d.ts @@ -1,22 +1,21 @@ // package: ion // file: proto/ion/ion.proto -import * as jspb from "google-protobuf"; +import * as jspb from 'google-protobuf'; export class Empty extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Empty.AsObject; static toObject(includeInstance: boolean, msg: Empty): Empty.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Empty, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Empty; static deserializeBinaryFromReader(message: Empty, reader: jspb.BinaryReader): Empty; } export namespace Empty { - export type AsObject = { - } + export type AsObject = {}; } export class RPC extends jspb.Message { @@ -31,8 +30,8 @@ export class RPC extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): RPC.AsObject; static toObject(includeInstance: boolean, msg: RPC): RPC.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: RPC, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): RPC; static deserializeBinaryFromReader(message: RPC, reader: jspb.BinaryReader): RPC; @@ -40,10 +39,10 @@ export class RPC extends jspb.Message { export namespace RPC { export type AsObject = { - protocol: string, - addr: string, - paramsMap: Array<[string, string]>, - } + protocol: string; + addr: string; + paramsMap: Array<[string, string]>; + }; } export class Node extends jspb.Message { @@ -64,8 +63,8 @@ export class Node extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Node.AsObject; static toObject(includeInstance: boolean, msg: Node): Node.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Node, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Node; static deserializeBinaryFromReader(message: Node, reader: jspb.BinaryReader): Node; @@ -73,10 +72,9 @@ export class Node extends jspb.Message { export namespace Node { export type AsObject = { - dc: string, - nid: string, - service: string, - rpc?: RPC.AsObject, - } + dc: string; + nid: string; + service: string; + rpc?: RPC.AsObject; + }; } - diff --git a/src/_library/proto/ion/ion_pb_service.d.ts b/src/_library/proto/ion/ion_pb_service.d.ts index e669f3a6..e3d26cae 100644 --- a/src/_library/proto/ion/ion_pb_service.d.ts +++ b/src/_library/proto/ion/ion_pb_service.d.ts @@ -1,3 +1,2 @@ // package: ion // file: proto/ion/ion.proto - diff --git a/src/_library/proto/rtc/rtc_pb.d.ts b/src/_library/proto/rtc/rtc_pb.d.ts index 6f1e5ef8..f2df4d15 100644 --- a/src/_library/proto/rtc/rtc_pb.d.ts +++ b/src/_library/proto/rtc/rtc_pb.d.ts @@ -1,7 +1,7 @@ // package: rtc // file: proto/rtc/rtc.proto -import * as jspb from "google-protobuf"; +import * as jspb from 'google-protobuf'; export class JoinRequest extends jspb.Message { getSid(): string; @@ -20,8 +20,8 @@ export class JoinRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): JoinRequest.AsObject; static toObject(includeInstance: boolean, msg: JoinRequest): JoinRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: JoinRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): JoinRequest; static deserializeBinaryFromReader(message: JoinRequest, reader: jspb.BinaryReader): JoinRequest; @@ -29,11 +29,11 @@ export class JoinRequest extends jspb.Message { export namespace JoinRequest { export type AsObject = { - sid: string, - uid: string, - configMap: Array<[string, string]>, - description?: SessionDescription.AsObject, - } + sid: string; + uid: string; + configMap: Array<[string, string]>; + description?: SessionDescription.AsObject; + }; } export class JoinReply extends jspb.Message { @@ -53,8 +53,8 @@ export class JoinReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): JoinReply.AsObject; static toObject(includeInstance: boolean, msg: JoinReply): JoinReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: JoinReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): JoinReply; static deserializeBinaryFromReader(message: JoinReply, reader: jspb.BinaryReader): JoinReply; @@ -62,10 +62,10 @@ export class JoinReply extends jspb.Message { export namespace JoinReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - description?: SessionDescription.AsObject, - } + success: boolean; + error?: Error.AsObject; + description?: SessionDescription.AsObject; + }; } export class TrackInfo extends jspb.Message { @@ -102,8 +102,8 @@ export class TrackInfo extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): TrackInfo.AsObject; static toObject(includeInstance: boolean, msg: TrackInfo): TrackInfo.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: TrackInfo, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): TrackInfo; static deserializeBinaryFromReader(message: TrackInfo, reader: jspb.BinaryReader): TrackInfo; @@ -111,17 +111,17 @@ export class TrackInfo extends jspb.Message { export namespace TrackInfo { export type AsObject = { - id: string, - kind: string, - muted: boolean, - type: MediaTypeMap[keyof MediaTypeMap], - streamid: string, - label: string, - layer: string, - width: number, - height: number, - framerate: number, - } + id: string; + kind: string; + muted: boolean; + type: MediaTypeMap[keyof MediaTypeMap]; + streamid: string; + label: string; + layer: string; + width: number; + height: number; + framerate: number; + }; } export class SessionDescription extends jspb.Message { @@ -142,8 +142,8 @@ export class SessionDescription extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): SessionDescription.AsObject; static toObject(includeInstance: boolean, msg: SessionDescription): SessionDescription.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: SessionDescription, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): SessionDescription; static deserializeBinaryFromReader(message: SessionDescription, reader: jspb.BinaryReader): SessionDescription; @@ -151,11 +151,11 @@ export class SessionDescription extends jspb.Message { export namespace SessionDescription { export type AsObject = { - target: TargetMap[keyof TargetMap], - type: string, - sdp: string, - trackinfosList: Array, - } + target: TargetMap[keyof TargetMap]; + type: string; + sdp: string; + trackinfosList: Array; + }; } export class Trickle extends jspb.Message { @@ -168,8 +168,8 @@ export class Trickle extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Trickle.AsObject; static toObject(includeInstance: boolean, msg: Trickle): Trickle.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Trickle, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Trickle; static deserializeBinaryFromReader(message: Trickle, reader: jspb.BinaryReader): Trickle; @@ -177,9 +177,9 @@ export class Trickle extends jspb.Message { export namespace Trickle { export type AsObject = { - target: TargetMap[keyof TargetMap], - init: string, - } + target: TargetMap[keyof TargetMap]; + init: string; + }; } export class Error extends jspb.Message { @@ -192,8 +192,8 @@ export class Error extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Error.AsObject; static toObject(includeInstance: boolean, msg: Error): Error.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Error, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Error; static deserializeBinaryFromReader(message: Error, reader: jspb.BinaryReader): Error; @@ -201,9 +201,9 @@ export class Error extends jspb.Message { export namespace Error { export type AsObject = { - code: number, - reason: string, - } + code: number; + reason: string; + }; } export class TrackEvent extends jspb.Message { @@ -221,8 +221,8 @@ export class TrackEvent extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): TrackEvent.AsObject; static toObject(includeInstance: boolean, msg: TrackEvent): TrackEvent.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: TrackEvent, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): TrackEvent; static deserializeBinaryFromReader(message: TrackEvent, reader: jspb.BinaryReader): TrackEvent; @@ -230,10 +230,10 @@ export class TrackEvent extends jspb.Message { export namespace TrackEvent { export type AsObject = { - state: TrackEvent.StateMap[keyof TrackEvent.StateMap], - uid: string, - tracksList: Array, - } + state: TrackEvent.StateMap[keyof TrackEvent.StateMap]; + uid: string; + tracksList: Array; + }; export interface StateMap { ADD: 0; @@ -260,8 +260,8 @@ export class Subscription extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Subscription.AsObject; static toObject(includeInstance: boolean, msg: Subscription): Subscription.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Subscription, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Subscription; static deserializeBinaryFromReader(message: Subscription, reader: jspb.BinaryReader): Subscription; @@ -269,11 +269,11 @@ export class Subscription extends jspb.Message { export namespace Subscription { export type AsObject = { - trackid: string, - mute: boolean, - subscribe: boolean, - layer: string, - } + trackid: string; + mute: boolean; + subscribe: boolean; + layer: string; + }; } export class SubscriptionRequest extends jspb.Message { @@ -285,8 +285,8 @@ export class SubscriptionRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): SubscriptionRequest.AsObject; static toObject(includeInstance: boolean, msg: SubscriptionRequest): SubscriptionRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: SubscriptionRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): SubscriptionRequest; static deserializeBinaryFromReader(message: SubscriptionRequest, reader: jspb.BinaryReader): SubscriptionRequest; @@ -294,8 +294,8 @@ export class SubscriptionRequest extends jspb.Message { export namespace SubscriptionRequest { export type AsObject = { - subscriptionsList: Array, - } + subscriptionsList: Array; + }; } export class SubscriptionReply extends jspb.Message { @@ -310,8 +310,8 @@ export class SubscriptionReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): SubscriptionReply.AsObject; static toObject(includeInstance: boolean, msg: SubscriptionReply): SubscriptionReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: SubscriptionReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): SubscriptionReply; static deserializeBinaryFromReader(message: SubscriptionReply, reader: jspb.BinaryReader): SubscriptionReply; @@ -319,9 +319,9 @@ export class SubscriptionReply extends jspb.Message { export namespace SubscriptionReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - } + success: boolean; + error?: Error.AsObject; + }; } export class UpdateTrackReply extends jspb.Message { @@ -336,8 +336,8 @@ export class UpdateTrackReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): UpdateTrackReply.AsObject; static toObject(includeInstance: boolean, msg: UpdateTrackReply): UpdateTrackReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: UpdateTrackReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): UpdateTrackReply; static deserializeBinaryFromReader(message: UpdateTrackReply, reader: jspb.BinaryReader): UpdateTrackReply; @@ -345,9 +345,9 @@ export class UpdateTrackReply extends jspb.Message { export namespace UpdateTrackReply { export type AsObject = { - success: boolean, - error?: Error.AsObject, - } + success: boolean; + error?: Error.AsObject; + }; } export class ActiveSpeaker extends jspb.Message { @@ -359,8 +359,8 @@ export class ActiveSpeaker extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): ActiveSpeaker.AsObject; static toObject(includeInstance: boolean, msg: ActiveSpeaker): ActiveSpeaker.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: ActiveSpeaker, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): ActiveSpeaker; static deserializeBinaryFromReader(message: ActiveSpeaker, reader: jspb.BinaryReader): ActiveSpeaker; @@ -368,8 +368,8 @@ export class ActiveSpeaker extends jspb.Message { export namespace ActiveSpeaker { export type AsObject = { - speakersList: Array, - } + speakersList: Array; + }; } export class AudioLevelSpeaker extends jspb.Message { @@ -385,8 +385,8 @@ export class AudioLevelSpeaker extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): AudioLevelSpeaker.AsObject; static toObject(includeInstance: boolean, msg: AudioLevelSpeaker): AudioLevelSpeaker.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: AudioLevelSpeaker, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): AudioLevelSpeaker; static deserializeBinaryFromReader(message: AudioLevelSpeaker, reader: jspb.BinaryReader): AudioLevelSpeaker; @@ -394,10 +394,10 @@ export class AudioLevelSpeaker extends jspb.Message { export namespace AudioLevelSpeaker { export type AsObject = { - sid: string, - level: number, - active: boolean, - } + sid: string; + level: number; + active: boolean; + }; } export class Request extends jspb.Message { @@ -425,8 +425,8 @@ export class Request extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Request.AsObject; static toObject(includeInstance: boolean, msg: Request): Request.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Request, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Request; static deserializeBinaryFromReader(message: Request, reader: jspb.BinaryReader): Request; @@ -434,11 +434,11 @@ export class Request extends jspb.Message { export namespace Request { export type AsObject = { - join?: JoinRequest.AsObject, - description?: SessionDescription.AsObject, - trickle?: Trickle.AsObject, - subscription?: SubscriptionRequest.AsObject, - } + join?: JoinRequest.AsObject; + description?: SessionDescription.AsObject; + trickle?: Trickle.AsObject; + subscription?: SubscriptionRequest.AsObject; + }; export enum PayloadCase { PAYLOAD_NOT_SET = 0, @@ -484,8 +484,8 @@ export class Reply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Reply.AsObject; static toObject(includeInstance: boolean, msg: Reply): Reply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Reply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Reply; static deserializeBinaryFromReader(message: Reply, reader: jspb.BinaryReader): Reply; @@ -493,13 +493,13 @@ export class Reply extends jspb.Message { export namespace Reply { export type AsObject = { - join?: JoinReply.AsObject, - description?: SessionDescription.AsObject, - trickle?: Trickle.AsObject, - trackevent?: TrackEvent.AsObject, - subscription?: SubscriptionReply.AsObject, - error?: Error.AsObject, - } + join?: JoinReply.AsObject; + description?: SessionDescription.AsObject; + trickle?: Trickle.AsObject; + trackevent?: TrackEvent.AsObject; + subscription?: SubscriptionReply.AsObject; + error?: Error.AsObject; + }; export enum PayloadCase { PAYLOAD_NOT_SET = 0, @@ -529,4 +529,3 @@ export interface MediaTypeMap { } export const MediaType: MediaTypeMap; - diff --git a/src/_library/proto/rtc/rtc_pb_service.d.ts b/src/_library/proto/rtc/rtc_pb_service.d.ts index 9e1dee1a..46ee1962 100644 --- a/src/_library/proto/rtc/rtc_pb_service.d.ts +++ b/src/_library/proto/rtc/rtc_pb_service.d.ts @@ -1,8 +1,8 @@ // package: rtc // file: proto/rtc/rtc.proto -import * as proto_rtc_rtc_pb from "../../proto/rtc/rtc_pb"; -import {grpc} from "@improbable-eng/grpc-web"; +import * as proto_rtc_rtc_pb from '../../proto/rtc/rtc_pb'; +import { grpc } from '@improbable-eng/grpc-web'; type RTCSignal = { readonly methodName: string; @@ -18,8 +18,8 @@ export class RTC { static readonly Signal: RTCSignal; } -export type ServiceError = { message: string, code: number; metadata: grpc.Metadata } -export type Status = { details: string, code: number; metadata: grpc.Metadata } +export type ServiceError = { message: string; code: number; metadata: grpc.Metadata }; +export type Status = { details: string; code: number; metadata: grpc.Metadata }; interface UnaryResponse { cancel(): void; @@ -52,4 +52,3 @@ export class RTCClient { constructor(serviceHost: string, options?: grpc.RpcOptions); signal(metadata?: grpc.Metadata): BidirectionalStream; } - diff --git a/src/_library/proto/sfu/sfu_pb.d.ts b/src/_library/proto/sfu/sfu_pb.d.ts index 85e191d0..7afea776 100644 --- a/src/_library/proto/sfu/sfu_pb.d.ts +++ b/src/_library/proto/sfu/sfu_pb.d.ts @@ -1,7 +1,7 @@ // package: sfu // file: proto/sfu/sfu.proto -import * as jspb from "google-protobuf"; +import * as jspb from 'google-protobuf'; export class SignalRequest extends jspb.Message { getId(): string; @@ -28,8 +28,8 @@ export class SignalRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): SignalRequest.AsObject; static toObject(includeInstance: boolean, msg: SignalRequest): SignalRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: SignalRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): SignalRequest; static deserializeBinaryFromReader(message: SignalRequest, reader: jspb.BinaryReader): SignalRequest; @@ -37,11 +37,11 @@ export class SignalRequest extends jspb.Message { export namespace SignalRequest { export type AsObject = { - id: string, - join?: JoinRequest.AsObject, - description: Uint8Array | string, - trickle?: Trickle.AsObject, - } + id: string; + join?: JoinRequest.AsObject; + description: Uint8Array | string; + trickle?: Trickle.AsObject; + }; export enum PayloadCase { PAYLOAD_NOT_SET = 0, @@ -86,8 +86,8 @@ export class SignalReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): SignalReply.AsObject; static toObject(includeInstance: boolean, msg: SignalReply): SignalReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: SignalReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): SignalReply; static deserializeBinaryFromReader(message: SignalReply, reader: jspb.BinaryReader): SignalReply; @@ -95,13 +95,13 @@ export class SignalReply extends jspb.Message { export namespace SignalReply { export type AsObject = { - id: string, - join?: JoinReply.AsObject, - description: Uint8Array | string, - trickle?: Trickle.AsObject, - iceconnectionstate: string, - error: string, - } + id: string; + join?: JoinReply.AsObject; + description: Uint8Array | string; + trickle?: Trickle.AsObject; + iceconnectionstate: string; + error: string; + }; export enum PayloadCase { PAYLOAD_NOT_SET = 0, @@ -130,8 +130,8 @@ export class JoinRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): JoinRequest.AsObject; static toObject(includeInstance: boolean, msg: JoinRequest): JoinRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: JoinRequest, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): JoinRequest; static deserializeBinaryFromReader(message: JoinRequest, reader: jspb.BinaryReader): JoinRequest; @@ -139,11 +139,11 @@ export class JoinRequest extends jspb.Message { export namespace JoinRequest { export type AsObject = { - sid: string, - uid: string, - description: Uint8Array | string, - configMap: Array<[string, string]>, - } + sid: string; + uid: string; + description: Uint8Array | string; + configMap: Array<[string, string]>; + }; } export class JoinReply extends jspb.Message { @@ -155,8 +155,8 @@ export class JoinReply extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): JoinReply.AsObject; static toObject(includeInstance: boolean, msg: JoinReply): JoinReply.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: JoinReply, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): JoinReply; static deserializeBinaryFromReader(message: JoinReply, reader: jspb.BinaryReader): JoinReply; @@ -164,8 +164,8 @@ export class JoinReply extends jspb.Message { export namespace JoinReply { export type AsObject = { - description: Uint8Array | string, - } + description: Uint8Array | string; + }; } export class Trickle extends jspb.Message { @@ -178,8 +178,8 @@ export class Trickle extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Trickle.AsObject; static toObject(includeInstance: boolean, msg: Trickle): Trickle.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static extensions: { [key: number]: jspb.ExtensionFieldInfo }; + static extensionsBinary: { [key: number]: jspb.ExtensionFieldBinaryInfo }; static serializeBinaryToWriter(message: Trickle, writer: jspb.BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Trickle; static deserializeBinaryFromReader(message: Trickle, reader: jspb.BinaryReader): Trickle; @@ -187,9 +187,9 @@ export class Trickle extends jspb.Message { export namespace Trickle { export type AsObject = { - target: Trickle.TargetMap[keyof Trickle.TargetMap], - init: string, - } + target: Trickle.TargetMap[keyof Trickle.TargetMap]; + init: string; + }; export interface TargetMap { PUBLISHER: 0; @@ -198,4 +198,3 @@ export namespace Trickle { export const Target: TargetMap; } - diff --git a/src/_library/proto/sfu/sfu_pb_service.d.ts b/src/_library/proto/sfu/sfu_pb_service.d.ts index 24d9b087..4921f7b4 100644 --- a/src/_library/proto/sfu/sfu_pb_service.d.ts +++ b/src/_library/proto/sfu/sfu_pb_service.d.ts @@ -1,8 +1,8 @@ // package: sfu // file: proto/sfu/sfu.proto -import * as proto_sfu_sfu_pb from "../../proto/sfu/sfu_pb"; -import {grpc} from "@improbable-eng/grpc-web"; +import * as proto_sfu_sfu_pb from '../../proto/sfu/sfu_pb'; +import { grpc } from '@improbable-eng/grpc-web'; type SFUSignal = { readonly methodName: string; @@ -18,8 +18,8 @@ export class SFU { static readonly Signal: SFUSignal; } -export type ServiceError = { message: string, code: number; metadata: grpc.Metadata } -export type Status = { details: string, code: number; metadata: grpc.Metadata } +export type ServiceError = { message: string; code: number; metadata: grpc.Metadata }; +export type Status = { details: string; code: number; metadata: grpc.Metadata }; interface UnaryResponse { cancel(): void; @@ -52,4 +52,3 @@ export class SFUClient { constructor(serviceHost: string, options?: grpc.RpcOptions); signal(metadata?: grpc.Metadata): BidirectionalStream; } - diff --git a/src/connector/index.ts b/src/connector/index.ts index 009764e0..ae5a2418 100644 --- a/src/connector/index.ts +++ b/src/connector/index.ts @@ -2,26 +2,38 @@ import { Configuration } from '../client'; import { LocalStream, RemoteStream, Constraints } from '../stream'; import { Connector, Service } from './ion'; import { RTC, Subscription } from './rtc'; -import { Room, JoinResult, Peer, PeerState, PeerEvent, Role, Protocol, Direction, Message, RoomInfo, Disconnect } from './room'; +import { + Room, + JoinResult, + Peer, + PeerState, + PeerEvent, + Role, + Protocol, + Direction, + Message, + RoomInfo, + Disconnect, +} from './room'; export { - Configuration, - LocalStream, - RemoteStream, - Constraints, - Connector, - Service, - RTC, - Room, - JoinResult, - Peer, - PeerState, - PeerEvent, - Role, - Protocol, - Direction, - Message, - RoomInfo, - Disconnect, - Subscription + Configuration, + LocalStream, + RemoteStream, + Constraints, + Connector, + Service, + RTC, + Room, + JoinResult, + Peer, + PeerState, + PeerEvent, + Role, + Protocol, + Direction, + Message, + RoomInfo, + Disconnect, + Subscription, }; diff --git a/src/connector/ion.ts b/src/connector/ion.ts index 88dbbf89..3fa3d759 100644 --- a/src/connector/ion.ts +++ b/src/connector/ion.ts @@ -4,70 +4,70 @@ import { grpc } from '@improbable-eng/grpc-web'; * Service interface */ export interface Service { - name: string; - // connect(): void; - connected: boolean; - close(): void; + name: string; + // connect(): void; + connected: boolean; + close(): void; } /** * Connector class * support multiple services */ export class Connector { - public metadata: grpc.Metadata; - public uri: string; - public services: Map; - onopen?: (service: Service) => void; - onclose?: (service: Service, ev: Event) => void; + public metadata: grpc.Metadata; + public uri: string; + public services: Map; + onopen?: (service: Service) => void; + onclose?: (service: Service, ev: Event) => void; - constructor(uri: string, token?: string) { - this.uri = uri; - this.metadata = new grpc.Metadata(); - this.services = new Map(); + constructor(uri: string, token?: string) { + this.uri = uri; + this.metadata = new grpc.Metadata(); + this.services = new Map(); - if (token) { - this.metadata.append("authorization", token); - } + if (token) { + this.metadata.append('authorization', token); } + } - public grpcClientRpcOptions(): grpc.ClientRpcOptions { - return { - host: this.uri, - transport: grpc.WebsocketTransport(), - }; - } + public grpcClientRpcOptions(): grpc.ClientRpcOptions { + return { + host: this.uri, + transport: grpc.WebsocketTransport(), + }; + } - public close(): void { - this.services.forEach((service: Service) => { - if (service.connected) { - service.close(); - } - }); - } + public close(): void { + this.services.forEach((service: Service) => { + if (service.connected) { + service.close(); + } + }); + } - public onHeaders(service: Service, headers: grpc.Metadata): void { - // Merge metadata. - headers.forEach((key, value) => { - if (key.toLowerCase() !== "trailer" && key.toLowerCase() !== "content-type") { - this.metadata.append(key, value); - } - }); - service.connected = true; - this.onopen?.call(this, service); - } + public onHeaders(service: Service, headers: grpc.Metadata): void { + // Merge metadata. + headers.forEach((key, value) => { + if (key.toLowerCase() !== 'trailer' && key.toLowerCase() !== 'content-type') { + this.metadata.append(key, value); + } + }); + service.connected = true; + this.onopen?.call(this, service); + } - public onEnd(service: Service, status: grpc.Code, statusMessage: string, trailers: grpc.Metadata): void { - service.connected = false; - this.onclose?.call(this, service, new CustomEvent(service.name, { "detail": { status, statusMessage, trailers } })); - } + public onEnd(service: Service, status: grpc.Code, statusMessage: string, trailers: grpc.Metadata): void { + service.connected = false; + this.onclose?.call(this, service, new CustomEvent(service.name, { detail: { status, statusMessage, trailers } })); + } - /** - * register service to connector - * @date 2021-11-03 - * @param {any} service:Service - * @returns {any} - */ - registerService(service: Service) { - this.services.set(service.name, service); - } -} \ No newline at end of file + /** + * register service to connector + * @date 2021-11-03 + * @param {any} service:Service + * @returns {any} + */ + registerService(service: Service) { + this.services.set(service.name, service); + } +} diff --git a/src/connector/room.ts b/src/connector/room.ts index 04716294..3e1001a8 100644 --- a/src/connector/room.ts +++ b/src/connector/room.ts @@ -8,387 +8,395 @@ import { EventEmitter } from 'events'; * PeerState: The state of a peer */ export enum PeerState { - NONE, - JOIN, - UPDATE, - LEAVE, + NONE, + JOIN, + UPDATE, + LEAVE, } /** * Role: Role of the peer */ export enum Role { - HOST = 0, - GUEST = 1 + HOST = 0, + GUEST = 1, } /** * Protocol: The protocol of the peer */ export enum Protocol { - PROTOCOLUNKNOWN = 0, - WEBRTC = 1, - SIP = 2, - RTMP = 3, - RTSP = 4, + PROTOCOLUNKNOWN = 0, + WEBRTC = 1, + SIP = 2, + RTMP = 3, + RTSP = 4, } /** * ErrorType: The type of error */ export enum ErrorType { - NONE = 0, - UNKOWNERROR = 1, - PERMISSIONDENIED = 2, - SERVICEUNAVAILABLE = 3, - ROOMLOCKED = 4, - PASSWORDREQUIRED = 5, - ROOMALREADYEXIST = 6, - ROOMNOTEXIST = 7, - INVALIDPARAMS = 8, - PEERALREADYEXIST = 9, - PEERNOTEXIST = 10, + NONE = 0, + UNKOWNERROR = 1, + PERMISSIONDENIED = 2, + SERVICEUNAVAILABLE = 3, + ROOMLOCKED = 4, + PASSWORDREQUIRED = 5, + ROOMALREADYEXIST = 6, + ROOMNOTEXIST = 7, + INVALIDPARAMS = 8, + PEERALREADYEXIST = 9, + PEERNOTEXIST = 10, } /** * Error: The error */ export interface Error { - errType: ErrorType; - reason: string; + errType: ErrorType; + reason: string; } /** * JoinResult: The result of join */ export interface JoinResult { - success: boolean; - error: Error; - role: Role; - room: RoomInfo; + success: boolean; + error: Error; + role: Role; + room: RoomInfo; } /** * Direction: The direction of the stream */ export enum Direction { - INCOMING = 0, - OUTGOING = 1, - BILATERAL = 2, + INCOMING = 0, + OUTGOING = 1, + BILATERAL = 2, } /** * Peer: The peer interface */ export interface Peer { - sid: string, - uid: string, - displayname: string, - extrainfo: Uint8Array | string, - destination: string, - role: Role, - protocol: Protocol, - avatar: string, - direction: Direction, - vendor: string, + sid: string; + uid: string; + displayname: string; + extrainfo: Uint8Array | string; + destination: string; + role: Role; + protocol: Protocol; + avatar: string; + direction: Direction; + vendor: string; } /** * PeerEvent: The event of peer */ export interface PeerEvent { - state: PeerState; - peer: Peer; + state: PeerState; + peer: Peer; } /** * Message: The message interface */ export interface Message { - from: string; - to: string; - type: string; - payload: any; + from: string; + to: string; + type: string; + payload: any; } /** * RoomInfo: The room info interface */ export interface RoomInfo { - sid: string, - name: string, - lock: boolean, - password: string, - description: string, - maxpeers: number, + sid: string; + name: string; + lock: boolean; + password: string; + description: string; + maxpeers: number; } /** * Disconnect: The disconnect interface */ export interface Disconnect { - sid: string, - reason: string, + sid: string; + reason: string; } /** * Room: The room class */ export class Room implements Service { - // public - name: string; - connector: Connector; - connected: boolean; - onerror?: (err: Event) => void; - onjoin?: (result: JoinResult) => void; - onleave?: (reason: string) => void; - onpeerevent?: (ev: PeerEvent) => void; - onmessage?: (msg: Message) => void; - onroominfo?: (info: RoomInfo) => void; - ondisconnect?: (dis: Disconnect) => void; + // public + name: string; + connector: Connector; + connected: boolean; + onerror?: (err: Event) => void; + onjoin?: (result: JoinResult) => void; + onleave?: (reason: string) => void; + onpeerevent?: (ev: PeerEvent) => void; + onmessage?: (msg: Message) => void; + onroominfo?: (info: RoomInfo) => void; + ondisconnect?: (dis: Disconnect) => void; - constructor(connector: Connector) { - this.name = "room"; - this.connected = false; - this.connector = connector; - this.connector.registerService(this); - this.connect(); - } + constructor(connector: Connector) { + this.name = 'room'; + this.connected = false; + this.connector = connector; + this.connector.registerService(this); + this.connect(); + } - async join(peer: Peer, password: string | undefined): Promise { - return this._rpc?.join(peer, password); - } + async join(peer: Peer, password: string | undefined): Promise { + return this._rpc?.join(peer, password); + } - async leave(sid: string, uid: string): Promise { - return this._rpc?.leave(sid, uid); - } + async leave(sid: string, uid: string): Promise { + return this._rpc?.leave(sid, uid); + } - async message(sid: string, from: string, to: string, mineType: string, data: Map): Promise { - return this._rpc?.sendMessage(sid, from, to, mineType, data); - } + async message(sid: string, from: string, to: string, mineType: string, data: Map): Promise { + return this._rpc?.sendMessage(sid, from, to, mineType, data); + } - connect(): void { - if (!this._rpc) { - this._rpc = new RoomGRPCClient(this, this.connector); - this._rpc.on("join-reply", (result: JoinResult) => { this.onjoin?.call(this, result); }); - this._rpc.on("leave-reply", (reason: string) => this.onleave?.call(this, reason)); - this._rpc.on("peer-event", (ev: PeerEvent) => this.onpeerevent?.call(this, ev)); - this._rpc.on("message", (msg: Message) => this.onmessage?.call(this, msg)); - this._rpc.on("room-info", (info: RoomInfo) => this.onroominfo?.call(this, info)); - this._rpc.on("disconnect", (dis: Disconnect) => this.ondisconnect?.call(this, dis)); - } + connect(): void { + if (!this._rpc) { + this._rpc = new RoomGRPCClient(this, this.connector); + this._rpc.on('join-reply', (result: JoinResult) => { + this.onjoin?.call(this, result); + }); + this._rpc.on('leave-reply', (reason: string) => this.onleave?.call(this, reason)); + this._rpc.on('peer-event', (ev: PeerEvent) => this.onpeerevent?.call(this, ev)); + this._rpc.on('message', (msg: Message) => this.onmessage?.call(this, msg)); + this._rpc.on('room-info', (info: RoomInfo) => this.onroominfo?.call(this, info)); + this._rpc.on('disconnect', (dis: Disconnect) => this.ondisconnect?.call(this, dis)); } + } - close(): void { - if (this._rpc) { - this._rpc.close(); - } + close(): void { + if (this._rpc) { + this._rpc.close(); } + } - // private - _rpc?: RoomGRPCClient; + // private + _rpc?: RoomGRPCClient; } /** * RoomGRPCClient: The room grpc client */ class RoomGRPCClient extends EventEmitter { - connector: Connector; - protected _client: grpc.Client; - constructor(service: Service, connector: Connector) { - super(); - this.connector = connector; - const client = grpc.client(room_rpc.RoomSignal.Signal, connector.grpcClientRpcOptions()) as grpc.Client; - - client.onEnd((status: grpc.Code, statusMessage: string, trailers: grpc.Metadata) => - connector.onEnd(service, status, statusMessage, trailers)); - client.onHeaders((headers: grpc.Metadata) => connector.onHeaders(service, headers)); + connector: Connector; + protected _client: grpc.Client; + constructor(service: Service, connector: Connector) { + super(); + this.connector = connector; + const client = grpc.client(room_rpc.RoomSignal.Signal, connector.grpcClientRpcOptions()) as grpc.Client< + room.Request, + room.Reply + >; - client.onMessage((reply: room.Reply) => { - switch (reply.getPayloadCase()) { - case room.Reply.PayloadCase.JOIN: - this.emit('join-reply', { - success: reply.getJoin()?.getSuccess() || false, - error: reply.getJoin()?.getError() || { errType: ErrorType.NONE, reason: '' }, - role: reply.getJoin()?.getRole() || Role.HOST, - room: reply.getJoin()? { - sid: reply.getJoin()?.getRoom()?.getSid() || '', - name: reply.getJoin()?.getRoom()?.getName() || '', - lock: reply.getJoin()?.getRoom()?.getLock() || false, - password: reply.getJoin()?.getRoom()?.getPassword() || '', - description: reply.getJoin()?.getRoom()?.getDescription() || '', - maxpeers: reply.getJoin()?.getRoom()?.getMaxpeers() || 0, - } : undefined, - }); - break; - case room.Reply.PayloadCase.LEAVE: - const reason = reply.getLeave()?.getError()?.getReason() || "unkown reason"; - this.emit('leave-reply', reason); - break; - case room.Reply.PayloadCase.PEER: - const evt = reply.getPeer(); - let state = PeerState.NONE; - switch (evt?.getState()) { - case room.PeerState.JOIN: - state = PeerState.JOIN; - break; - case room.PeerState.UPDATE: - state = PeerState.UPDATE; - break; - case room.PeerState.LEAVE: - state = PeerState.LEAVE; - break; - } - const peer = { - uid: evt?.getPeer()?.getUid() || "", - sid: evt?.getPeer()?.getSid() || "", - displayname: evt?.getPeer()?.getDisplayname() || "", - extrainfo: evt?.getPeer()?.getExtrainfo() || "", - destination: evt?.getPeer()?.getDestination() || "", - role: evt?.getPeer()?.getRole() || "", - protocol: evt?.getPeer()?.getProtocol() || "", - avatar: evt?.getPeer()?.getAvatar() || "", - direction: evt?.getPeer()?.getDirection() || "", - vendor: evt?.getPeer()?.getVendor() || "", - } - this.emit("peer-event", { state, peer }); - break; - case room.Reply.PayloadCase.MESSAGE: - const msg = reply.getMessage(); - this.emit('message', { - from: msg?.getFrom() || "", - to: msg?.getTo() || "", - type: msg?.getType() || "", - data: msg?.getPayload() || {}, - }); - break; - case room.Reply.PayloadCase.ROOM: - const info = reply.getRoom() || undefined; - this.emit('room-info', { - sid: info?.getSid() || "", - name: info?.getName() || "", - lock: info?.getLock() || false, - password: info?.getPassword() || "", - description: info?.getDescription() || "", - maxpeers: info?.getMaxpeers() || 0, - }); - break; - case room.Reply.PayloadCase.DISCONNECT: - const dis = reply.getDisconnect() || {}; - this.emit('disconnect', dis); - break; - } - }); + client.onEnd((status: grpc.Code, statusMessage: string, trailers: grpc.Metadata) => + connector.onEnd(service, status, statusMessage, trailers), + ); + client.onHeaders((headers: grpc.Metadata) => connector.onHeaders(service, headers)); - this._client = client; - this._client.start(connector.metadata); - } + client.onMessage((reply: room.Reply) => { + switch (reply.getPayloadCase()) { + case room.Reply.PayloadCase.JOIN: + this.emit('join-reply', { + success: reply.getJoin()?.getSuccess() || false, + error: reply.getJoin()?.getError() || { errType: ErrorType.NONE, reason: '' }, + role: reply.getJoin()?.getRole() || Role.HOST, + room: reply.getJoin() + ? { + sid: reply.getJoin()?.getRoom()?.getSid() || '', + name: reply.getJoin()?.getRoom()?.getName() || '', + lock: reply.getJoin()?.getRoom()?.getLock() || false, + password: reply.getJoin()?.getRoom()?.getPassword() || '', + description: reply.getJoin()?.getRoom()?.getDescription() || '', + maxpeers: reply.getJoin()?.getRoom()?.getMaxpeers() || 0, + } + : undefined, + }); + break; + case room.Reply.PayloadCase.LEAVE: + const reason = reply.getLeave()?.getError()?.getReason() || 'unkown reason'; + this.emit('leave-reply', reason); + break; + case room.Reply.PayloadCase.PEER: + const evt = reply.getPeer(); + let state = PeerState.NONE; + switch (evt?.getState()) { + case room.PeerState.JOIN: + state = PeerState.JOIN; + break; + case room.PeerState.UPDATE: + state = PeerState.UPDATE; + break; + case room.PeerState.LEAVE: + state = PeerState.LEAVE; + break; + } + const peer = { + uid: evt?.getPeer()?.getUid() || '', + sid: evt?.getPeer()?.getSid() || '', + displayname: evt?.getPeer()?.getDisplayname() || '', + extrainfo: evt?.getPeer()?.getExtrainfo() || '', + destination: evt?.getPeer()?.getDestination() || '', + role: evt?.getPeer()?.getRole() || '', + protocol: evt?.getPeer()?.getProtocol() || '', + avatar: evt?.getPeer()?.getAvatar() || '', + direction: evt?.getPeer()?.getDirection() || '', + vendor: evt?.getPeer()?.getVendor() || '', + }; + this.emit('peer-event', { state, peer }); + break; + case room.Reply.PayloadCase.MESSAGE: + const msg = reply.getMessage(); + this.emit('message', { + from: msg?.getFrom() || '', + to: msg?.getTo() || '', + type: msg?.getType() || '', + data: msg?.getPayload() || {}, + }); + break; + case room.Reply.PayloadCase.ROOM: + const info = reply.getRoom() || undefined; + this.emit('room-info', { + sid: info?.getSid() || '', + name: info?.getName() || '', + lock: info?.getLock() || false, + password: info?.getPassword() || '', + description: info?.getDescription() || '', + maxpeers: info?.getMaxpeers() || 0, + }); + break; + case room.Reply.PayloadCase.DISCONNECT: + const dis = reply.getDisconnect() || {}; + this.emit('disconnect', dis); + break; + } + }); - /** - * join a session/room - * @date 2021-11-03 - * @param {any} peer:Peer - * @param {any} password:string|undefined - * @returns {any} - */ - async join(peer: Peer, password: string | undefined): Promise { - const request = new room.Request(); - const join = new room.JoinRequest(); - const p = new room.Peer(); + this._client = client; + this._client.start(connector.metadata); + } - p.setUid(peer.uid); - p.setSid(peer.sid); - p.setDisplayname(peer.displayname); - p.setExtrainfo(peer.extrainfo); - p.setDestination(peer.destination); - p.setRole(peer.role); - p.setProtocol(peer.protocol); - p.setAvatar(peer.avatar); - p.setDirection(peer.direction); - p.setVendor(peer.vendor); - join.setPeer(p); - if (password) { - join.setPassword(password); - } - request.setJoin(join); - this._client.send(request); + /** + * join a session/room + * @date 2021-11-03 + * @param {any} peer:Peer + * @param {any} password:string|undefined + * @returns {any} + */ + async join(peer: Peer, password: string | undefined): Promise { + const request = new room.Request(); + const join = new room.JoinRequest(); + const p = new room.Peer(); - return new Promise((resolve, reject) => { - const handler = (result: JoinResult) => { - resolve(result); - this.removeListener('join-reply', handler); - }; - this.addListener('join-reply', handler); - }); + p.setUid(peer.uid); + p.setSid(peer.sid); + p.setDisplayname(peer.displayname); + p.setExtrainfo(peer.extrainfo); + p.setDestination(peer.destination); + p.setRole(peer.role); + p.setProtocol(peer.protocol); + p.setAvatar(peer.avatar); + p.setDirection(peer.direction); + p.setVendor(peer.vendor); + join.setPeer(p); + if (password) { + join.setPassword(password); } + request.setJoin(join); + this._client.send(request); - /** - * leave a session/room - * @date 2021-11-03 - * @param {any} sid:string - * @param {any} uid:string - * @returns - */ - async leave(sid: string, uid: string) { - const request = new room.Request(); - const leave = new room.LeaveRequest(); - leave.setSid(sid); - leave.setUid(uid); - request.setLeave(leave); + return new Promise((resolve, reject) => { + const handler = (result: JoinResult) => { + resolve(result); + this.removeListener('join-reply', handler); + }; + this.addListener('join-reply', handler); + }); + } - this._client.send(request); + /** + * leave a session/room + * @date 2021-11-03 + * @param {any} sid:string + * @param {any} uid:string + * @returns + */ + async leave(sid: string, uid: string) { + const request = new room.Request(); + const leave = new room.LeaveRequest(); + leave.setSid(sid); + leave.setUid(uid); + request.setLeave(leave); - return new Promise((resolve, reject) => { - const handler = (reason: string) => { - resolve(reason); - this.removeListener('leave-reply', handler); - }; - this.addListener('leave-reply', handler); - }); - } + this._client.send(request); - mapToObj(map: Map){ - if (!map) { - return {}; - } - const obj: {[key: string]: any} = {}; - map.forEach((value: any, key: string) => { - obj[key] = value; - }); - return obj; - } - - /** - * send a message to a session/room - * @date 2021-11-03 - * @param {any} sid:string - * @param {any} from:string - * @param {any} to:string - * @param {any} mineType:string - * @param {any} data:Map - * @returns - */ - async sendMessage(sid: string, from: string, to: string, mineType: string, data: Map) { - const request = new room.Request(); - const sendMessage = new room.SendMessageRequest(); - const message = new room.Message(); - message.setFrom(from); - message.setTo(to); - const obj = this.mapToObj(data); - const buffer = Uint8Array.from(JSON.stringify(obj), (c) => c.charCodeAt(0)); - message.setType(mineType); - message.setPayload(buffer); - sendMessage.setSid(sid); - sendMessage.setMessage(message); - request.setSendmessage(sendMessage); - this._client.send(request); - } + return new Promise((resolve, reject) => { + const handler = (reason: string) => { + resolve(reason); + this.removeListener('leave-reply', handler); + }; + this.addListener('leave-reply', handler); + }); + } - /** - * close client - * @date 2021-11-03 - * @returns - */ - close() { - this._client.finishSend(); + mapToObj(map: Map) { + if (!map) { + return {}; } + const obj: { [key: string]: any } = {}; + map.forEach((value: any, key: string) => { + obj[key] = value; + }); + return obj; + } + + /** + * send a message to a session/room + * @date 2021-11-03 + * @param {any} sid:string + * @param {any} from:string + * @param {any} to:string + * @param {any} mineType:string + * @param {any} data:Map + * @returns + */ + async sendMessage(sid: string, from: string, to: string, mineType: string, data: Map) { + const request = new room.Request(); + const sendMessage = new room.SendMessageRequest(); + const message = new room.Message(); + message.setFrom(from); + message.setTo(to); + const obj = this.mapToObj(data); + const buffer = Uint8Array.from(JSON.stringify(obj), (c) => c.charCodeAt(0)); + message.setType(mineType); + message.setPayload(buffer); + sendMessage.setSid(sid); + sendMessage.setMessage(message); + request.setSendmessage(sendMessage); + this._client.send(request); + } + + /** + * close client + * @date 2021-11-03 + * @returns + */ + close() { + this._client.finishSend(); + } } diff --git a/src/connector/rtc.ts b/src/connector/rtc.ts index d7b2e6be..52b79b4c 100644 --- a/src/connector/rtc.ts +++ b/src/connector/rtc.ts @@ -11,482 +11,482 @@ import { LocalStream, RemoteStream } from '../stream'; * TrackState: track state */ export enum TrackState { - ADD = 0, - UPDATE, - REMOVE, + ADD = 0, + UPDATE, + REMOVE, } /** * TrackEvent: track event */ export interface TrackEvent { - state: TrackState; - uid: string; - tracks: TrackInfo[]; + state: TrackState; + uid: string; + tracks: TrackInfo[]; } /** * MediaType: media type */ export enum MediaType { - MEDIAUNKNOWN = 0, - USERMEDIA = 1, - SCREENCAPTURE = 2, - CAVANS = 3, - STREAMING = 4, - VOIP = 5, -}; + MEDIAUNKNOWN = 0, + USERMEDIA = 1, + SCREENCAPTURE = 2, + CAVANS = 3, + STREAMING = 4, + VOIP = 5, +} /** * TrackInfo: track info */ export interface TrackInfo { - id: string; - kind: string; - muted: boolean; - type: MediaType; - stream_id: string; - label: string; - layer: string, - width: number, - height: number, - frame_rate: number, + id: string; + kind: string; + muted: boolean; + type: MediaType; + stream_id: string; + label: string; + layer: string; + width: number; + height: number; + frame_rate: number; } /** * Subscription: subscription */ export interface Subscription { - track_id: string; - muted: boolean; - subscribe: boolean; - layer: string; + track_id: string; + muted: boolean; + subscribe: boolean; + layer: string; } /** * JoinConfig: join config */ export interface JoinConfig { - no_publish: boolean; - no_subscribe: boolean; - no_auto_subscribe: boolean; + no_publish: boolean; + no_subscribe: boolean; + no_auto_subscribe: boolean; } /** * Error: error interface */ export interface Error { - code: number; - reason: string; + code: number; + reason: string; } /** * Result: result interface */ export interface Result { - success: boolean; - error: Error | undefined; + success: boolean; + error: Error | undefined; } /** * RTC: rtc class */ export class RTC implements Service { - name: string; - connector: Connector; - connected: boolean; - config?: Configuration; - protected _rpc?: grpc.Client; - private _rtc?: Client; - private _sig?: RTCGRPCSignal; - ontrack?: (track: MediaStreamTrack, stream: RemoteStream) => void; - ondatachannel?: (ev: RTCDataChannelEvent) => void; - onspeaker?: (ev: string[]) => void; - ontrackevent?: (ev: TrackEvent) => void; + name: string; + connector: Connector; + connected: boolean; + config?: Configuration; + protected _rpc?: grpc.Client; + private _rtc?: Client; + private _sig?: RTCGRPCSignal; + ontrack?: (track: MediaStreamTrack, stream: RemoteStream) => void; + ondatachannel?: (ev: RTCDataChannelEvent) => void; + onspeaker?: (ev: string[]) => void; + ontrackevent?: (ev: TrackEvent) => void; - /** - * constructor - * @date 2021-11-03 - * @param {any} connector:Connector - * @param {any} config?:Configuration - * @returns - */ - constructor(connector: Connector, config?: Configuration) { - this.name = "rtc"; - this.config = config; - this.connected = false; - this.connector = connector; - this.connector.registerService(this); - this.connect(); - } + /** + * constructor + * @date 2021-11-03 + * @param {any} connector:Connector + * @param {any} config?:Configuration + * @returns + */ + constructor(connector: Connector, config?: Configuration) { + this.name = 'rtc'; + this.config = config; + this.connected = false; + this.connector = connector; + this.connector.registerService(this); + this.connect(); + } - - /** - * join rtc session - * @date 2021-11-03 - * @param {any} sid:string - * @param {any} uid:string - * @param {any} config:JoinConfig|undefined - * @returns - */ - async join(sid: string, uid: string, config: JoinConfig | undefined) { - this._sig!.config = config; - return this._rtc?.join(sid, uid); - } + /** + * join rtc session + * @date 2021-11-03 + * @param {any} sid:string + * @param {any} uid:string + * @param {any} config:JoinConfig|undefined + * @returns + */ + async join(sid: string, uid: string, config: JoinConfig | undefined) { + this._sig!.config = config; + return this._rtc?.join(sid, uid); + } - /** - * leave session - * @date 2021-11-03 - * @returns - */ - leave() { - return this._rtc?.leave(); - } + /** + * leave session + * @date 2021-11-03 + * @returns + */ + leave() { + return this._rtc?.leave(); + } - /** - * get pub stats - * @date 2021-11-03 - * @param {any} selector?:MediaStreamTrack - * @returns {any} - */ - getPubStats(selector?: MediaStreamTrack) { - return this._rtc?.getPubStats(selector); - } + /** + * get pub stats + * @date 2021-11-03 + * @param {any} selector?:MediaStreamTrack + * @returns {any} + */ + getPubStats(selector?: MediaStreamTrack) { + return this._rtc?.getPubStats(selector); + } - /** - * get sub stats - * @date 2021-11-03 - * @param {any} selector?:MediaStreamTrack - * @returns {any} - */ - getSubStats(selector?: MediaStreamTrack) { - return this._rtc?.getSubStats(selector); - } + /** + * get sub stats + * @date 2021-11-03 + * @param {any} selector?:MediaStreamTrack + * @returns {any} + */ + getSubStats(selector?: MediaStreamTrack) { + return this._rtc?.getSubStats(selector); + } - /** - * publish local stream - * @date 2021-11-03 - * @param {any} stream:LocalStream - * @returns {any} - */ - publish(stream: LocalStream) { - this._sig!.buildTrackInfos(stream); - this._rtc?.publish(stream); - } + /** + * publish local stream + * @date 2021-11-03 + * @param {any} stream:LocalStream + * @returns {any} + */ + publish(stream: LocalStream) { + this._sig!.buildTrackInfos(stream); + this._rtc?.publish(stream); + } - /** - * subscribe - * @date 2021-11-03 - * @param {any} trackInfos:Subscription[] - * @returns {any} - */ - subscribe(trackInfos: Subscription[]): Promise | undefined { - return this._sig?.subscribe(trackInfos); - } + /** + * subscribe + * @date 2021-11-03 + * @param {any} trackInfos:Subscription[] + * @returns {any} + */ + subscribe(trackInfos: Subscription[]): Promise | undefined { + return this._sig?.subscribe(trackInfos); + } + /** + * createDataChannel + * @date 2021-11-03 + * @param {any} label:string + * @returns {any} + */ + createDataChannel(label: string) { + return this._rtc?.createDataChannel(label); + } - /** - * createDataChannel - * @date 2021-11-03 - * @param {any} label:string - * @returns {any} - */ - createDataChannel(label: string) { - return this._rtc?.createDataChannel(label); + /** + * connect to signal + * @date 2021-11-03 + * @returns {any} + */ + connect(): void { + if (!this._sig) { + this._sig = new RTCGRPCSignal(this, this.connector); } - - /** - * connect to signal - * @date 2021-11-03 - * @returns {any} - */ - connect(): void { - if (!this._sig) { - this._sig = new RTCGRPCSignal(this, this.connector); - } - if (!this._rtc) { - this._rtc = new Client(this._sig, this?.config); - this._rtc.ontrack = (track: MediaStreamTrack, stream: RemoteStream) => { - // TODO: Attach track info to RemoteStream. - this.ontrack?.call(this, track, stream); - } - this._rtc.ondatachannel = (ev: RTCDataChannelEvent) => - this.ondatachannel?.call(this, ev); - this._rtc.onspeaker = (ev: string[]) => this.onspeaker?.call(this, ev); - this._sig.ontrackevent = (ev: TrackEvent) => { - // TODO: Attach RemoteStream info to track event. - this.ontrackevent?.call(this, ev); - }; - } + if (!this._rtc) { + this._rtc = new Client(this._sig, this?.config); + this._rtc.ontrack = (track: MediaStreamTrack, stream: RemoteStream) => { + // TODO: Attach track info to RemoteStream. + this.ontrack?.call(this, track, stream); + }; + this._rtc.ondatachannel = (ev: RTCDataChannelEvent) => this.ondatachannel?.call(this, ev); + this._rtc.onspeaker = (ev: string[]) => this.onspeaker?.call(this, ev); + this._sig.ontrackevent = (ev: TrackEvent) => { + // TODO: Attach RemoteStream info to track event. + this.ontrackevent?.call(this, ev); + }; } + } - /** - * close rtc - * @date 2021-11-03 - * @returns {any} - */ - close(): void { - if (this._rtc) { - this._rtc.close(); - } + /** + * close rtc + * @date 2021-11-03 + * @returns {any} + */ + close(): void { + if (this._rtc) { + this._rtc.close(); } + } } /** * RTCGRPCSignal: rtc grpc signal */ class RTCGRPCSignal implements Signal { - connector: Connector; - protected _client: grpc.Client; - private _event: EventEmitter = new EventEmitter(); - private _tracksInfos?: pb.TrackInfo[]; - onnegotiate?: ((jsep: RTCSessionDescriptionInit) => void) | undefined; - ontrickle?: ((trickle: Trickle) => void) | undefined; - ontrackevent?: (ev: TrackEvent) => void; - private _config?: JoinConfig; - set config(config: JoinConfig | undefined) { - this._config = config; - } - constructor(service: Service, connector: Connector) { - this.connector = connector; - const client = grpc.client(sfu_rpc.RTC.Signal, this.connector.grpcClientRpcOptions()) as grpc.Client; - client.onEnd((status: grpc.Code, statusMessage: string, trailers: grpc.Metadata) => - connector.onEnd(service, status, statusMessage, trailers)); - client.onHeaders((headers: grpc.Metadata) => connector.onHeaders(service, headers)); - client.onMessage((reply: pb.Reply) => { - switch (reply.getPayloadCase()) { - case pb.Reply.PayloadCase.JOIN: - const result = reply.getJoin(); - this._event.emit('join-reply', result); - break; - case pb.Reply.PayloadCase.DESCRIPTION: - const desc = reply.getDescription(); - if (desc?.getType() === 'offer') { - if (this.onnegotiate) this.onnegotiate({ sdp: desc.getSdp(), type: 'offer' }); - } else if (desc?.getType() === 'answer') { - this._event.emit('description', { sdp: desc.getSdp(), type: 'answer' }); - } - if (desc?.getTrackinfosList() && desc?.getTrackinfosList().length > 0) { - // TODO: process metadata. - } - break; - case pb.Reply.PayloadCase.TRICKLE: - const pbTrickle = reply.getTrickle(); - if (pbTrickle?.getInit() !== undefined) { - const candidate = JSON.parse(pbTrickle.getInit() as string); - const trickle = { target: pbTrickle.getTarget(), candidate }; - if (this.ontrickle) this.ontrickle(trickle); - } - break; - case pb.Reply.PayloadCase.TRACKEVENT: - { - const evt = reply.getTrackevent(); - let state = TrackState.ADD; - switch (evt?.getState()) { - case pb.TrackEvent.State.ADD: - state = TrackState.ADD; - break; - case pb.TrackEvent.State.UPDATE: - state = TrackState.UPDATE; - break; - case pb.TrackEvent.State.REMOVE: - state = TrackState.REMOVE; - break; - }; - const tracks = Array(); - const uid = evt?.getUid() || ''; - evt?.getTracksList().forEach((rtcTrack: pb.TrackInfo) => { - tracks.push({ - id: rtcTrack.getId(), - kind: rtcTrack.getKind(), - label: rtcTrack.getLabel(), - stream_id: rtcTrack.getStreamid(), - muted: rtcTrack.getMuted(), - type: rtcTrack.getType() || MediaType.MEDIAUNKNOWN, - layer:rtcTrack.getLayer(), - width:rtcTrack.getWidth()|| 0, - height:rtcTrack.getHeight()|| 0, - frame_rate:rtcTrack.getFramerate()|| 0 - }); - }); - this.ontrackevent?.call(this, { state, tracks, uid }); - } - break; - case pb.Reply.PayloadCase.SUBSCRIPTION: - const subscription = reply.getSubscription(); - this._event.emit('subscription', { - success: subscription?.getSuccess() || false, - error: subscription?.getError(), - }); - case pb.Reply.PayloadCase.ERROR: - break; + connector: Connector; + protected _client: grpc.Client; + private _event: EventEmitter = new EventEmitter(); + private _tracksInfos?: pb.TrackInfo[]; + onnegotiate?: ((jsep: RTCSessionDescriptionInit) => void) | undefined; + ontrickle?: ((trickle: Trickle) => void) | undefined; + ontrackevent?: (ev: TrackEvent) => void; + private _config?: JoinConfig; + set config(config: JoinConfig | undefined) { + this._config = config; + } + constructor(service: Service, connector: Connector) { + this.connector = connector; + const client = grpc.client(sfu_rpc.RTC.Signal, this.connector.grpcClientRpcOptions()) as grpc.Client< + pb.Request, + pb.Reply + >; + client.onEnd((status: grpc.Code, statusMessage: string, trailers: grpc.Metadata) => + connector.onEnd(service, status, statusMessage, trailers), + ); + client.onHeaders((headers: grpc.Metadata) => connector.onHeaders(service, headers)); + client.onMessage((reply: pb.Reply) => { + switch (reply.getPayloadCase()) { + case pb.Reply.PayloadCase.JOIN: + const result = reply.getJoin(); + this._event.emit('join-reply', result); + break; + case pb.Reply.PayloadCase.DESCRIPTION: + const desc = reply.getDescription(); + if (desc?.getType() === 'offer') { + if (this.onnegotiate) this.onnegotiate({ sdp: desc.getSdp(), type: 'offer' }); + } else if (desc?.getType() === 'answer') { + this._event.emit('description', { sdp: desc.getSdp(), type: 'answer' }); + } + if (desc?.getTrackinfosList() && desc?.getTrackinfosList().length > 0) { + // TODO: process metadata. + } + break; + case pb.Reply.PayloadCase.TRICKLE: + const pbTrickle = reply.getTrickle(); + if (pbTrickle?.getInit() !== undefined) { + const candidate = JSON.parse(pbTrickle.getInit() as string); + const trickle = { target: pbTrickle.getTarget(), candidate }; + if (this.ontrickle) this.ontrickle(trickle); + } + break; + case pb.Reply.PayloadCase.TRACKEVENT: + { + const evt = reply.getTrackevent(); + let state = TrackState.ADD; + switch (evt?.getState()) { + case pb.TrackEvent.State.ADD: + state = TrackState.ADD; + break; + case pb.TrackEvent.State.UPDATE: + state = TrackState.UPDATE; + break; + case pb.TrackEvent.State.REMOVE: + state = TrackState.REMOVE; + break; } - }); - this._client = client; - this._client.start(this.connector.metadata); - } + const tracks = Array(); + const uid = evt?.getUid() || ''; + evt?.getTracksList().forEach((rtcTrack: pb.TrackInfo) => { + tracks.push({ + id: rtcTrack.getId(), + kind: rtcTrack.getKind(), + label: rtcTrack.getLabel(), + stream_id: rtcTrack.getStreamid(), + muted: rtcTrack.getMuted(), + type: rtcTrack.getType() || MediaType.MEDIAUNKNOWN, + layer: rtcTrack.getLayer(), + width: rtcTrack.getWidth() || 0, + height: rtcTrack.getHeight() || 0, + frame_rate: rtcTrack.getFramerate() || 0, + }); + }); + this.ontrackevent?.call(this, { state, tracks, uid }); + } + break; + case pb.Reply.PayloadCase.SUBSCRIPTION: + const subscription = reply.getSubscription(); + this._event.emit('subscription', { + success: subscription?.getSuccess() || false, + error: subscription?.getError(), + }); + case pb.Reply.PayloadCase.ERROR: + break; + } + }); + this._client = client; + this._client.start(this.connector.metadata); + } - /** - * join a session - * @date 2021-11-03 - * @param {any} sid:string - * @param {any} uid:null|string - * @param {any} offer:RTCSessionDescriptionInit - * @returns {any} - */ - join(sid: string, uid: null | string, offer: RTCSessionDescriptionInit): Promise { - const request = new pb.Request(); - const join = new pb.JoinRequest(); - join.setSid(sid); - join.setUid(uid || ''); - if (this._config) { - join.getConfigMap().set('NoPublish', this._config?.no_publish ? 'true' : 'false'); - join.getConfigMap().set('NoSubscribe', this._config?.no_subscribe ? 'true' : 'false'); - join.getConfigMap().set('NoAutoSubscribe', this._config?.no_auto_subscribe ? 'true' : 'false'); - } - const dest = new pb.SessionDescription(); - dest.setSdp(offer.sdp || ''); - dest.setType(offer.type || ''); - dest.setTarget(pb.Target.PUBLISHER); - if (this._tracksInfos) { - dest.setTrackinfosList(this._tracksInfos); - } - join.setDescription(dest); - request.setJoin(join); - this._client.send(request); - return new Promise((resolve, reject) => { - const handler = (result: pb.JoinReply) => { - if (result.getSuccess()) { - resolve({ - sdp: result.getDescription()!.getSdp(), - type: result.getDescription()!.getType() - }); - } else { - reject(result.getError()?.toObject()); - } - this._event.removeListener('join-reply', handler); - }; - this._event.addListener('join-reply', handler); - }); + /** + * join a session + * @date 2021-11-03 + * @param {any} sid:string + * @param {any} uid:null|string + * @param {any} offer:RTCSessionDescriptionInit + * @returns {any} + */ + join(sid: string, uid: null | string, offer: RTCSessionDescriptionInit): Promise { + const request = new pb.Request(); + const join = new pb.JoinRequest(); + join.setSid(sid); + join.setUid(uid || ''); + if (this._config) { + join.getConfigMap().set('NoPublish', this._config?.no_publish ? 'true' : 'false'); + join.getConfigMap().set('NoSubscribe', this._config?.no_subscribe ? 'true' : 'false'); + join.getConfigMap().set('NoAutoSubscribe', this._config?.no_auto_subscribe ? 'true' : 'false'); } - - /** - * send trickle - * @date 2021-11-03 - * @param {any} trickle:Trickle - * @returns {any} - */ - trickle(trickle: Trickle) { - const request = new pb.Request(); - const pbTrickle = new pb.Trickle(); - pbTrickle.setInit(JSON.stringify(trickle.candidate)); - request.setTrickle(pbTrickle); - this._client.send(request); + const dest = new pb.SessionDescription(); + dest.setSdp(offer.sdp || ''); + dest.setType(offer.type || ''); + dest.setTarget(pb.Target.PUBLISHER); + if (this._tracksInfos) { + dest.setTrackinfosList(this._tracksInfos); } - - /** - * send offer request - * @date 2021-11-03 - * @param {any} offer:RTCSessionDescriptionInit - * @returns {any} - */ - offer(offer: RTCSessionDescriptionInit) { - const request = new pb.Request(); - const dest = new pb.SessionDescription(); - dest.setSdp(offer.sdp || ''); - dest.setType(offer.type || ''); - dest.setTarget(pb.Target.PUBLISHER); - if (this._tracksInfos) { - dest.setTrackinfosList(this._tracksInfos); + join.setDescription(dest); + request.setJoin(join); + this._client.send(request); + return new Promise((resolve, reject) => { + const handler = (result: pb.JoinReply) => { + if (result.getSuccess()) { + resolve({ + sdp: result.getDescription()!.getSdp(), + type: result.getDescription()!.getType(), + }); + } else { + reject(result.getError()?.toObject()); } - request.setDescription(dest); - this._client.send(request); - return new Promise((resolve, reject) => { - const handler = (desc: RTCSessionDescriptionInit) => { - resolve(desc); - this._event.removeListener('description', handler); - }; - this._event.addListener('description', handler); - }); - } + this._event.removeListener('join-reply', handler); + }; + this._event.addListener('join-reply', handler); + }); + } - /** - * send answer request - * @date 2021-11-03 - * @param {any} answer:RTCSessionDescriptionInit - * @returns {any} - */ - answer(answer: RTCSessionDescriptionInit) { - const request = new pb.Request(); - const desc = new pb.SessionDescription(); - desc.setSdp(answer.sdp || ''); - desc.setType(answer.type || ''); - desc.setTarget(pb.Target.SUBSCRIBER); - request.setDescription(desc); - this._client.send(request); - } + /** + * send trickle + * @date 2021-11-03 + * @param {any} trickle:Trickle + * @returns {any} + */ + trickle(trickle: Trickle) { + const request = new pb.Request(); + const pbTrickle = new pb.Trickle(); + pbTrickle.setInit(JSON.stringify(trickle.candidate)); + request.setTrickle(pbTrickle); + this._client.send(request); + } - /** - * close client - * @date 2021-11-03 - * @returns {any} - */ - close(): void { - this._client?.close(); + /** + * send offer request + * @date 2021-11-03 + * @param {any} offer:RTCSessionDescriptionInit + * @returns {any} + */ + offer(offer: RTCSessionDescriptionInit) { + const request = new pb.Request(); + const dest = new pb.SessionDescription(); + dest.setSdp(offer.sdp || ''); + dest.setType(offer.type || ''); + dest.setTarget(pb.Target.PUBLISHER); + if (this._tracksInfos) { + dest.setTrackinfosList(this._tracksInfos); } + request.setDescription(dest); + this._client.send(request); + return new Promise((resolve, reject) => { + const handler = (desc: RTCSessionDescriptionInit) => { + resolve(desc); + this._event.removeListener('description', handler); + }; + this._event.addListener('description', handler); + }); + } - /** - * subscribe - * @date 2021-11-03 - * @param {any} infos:Subscription[] - * @returns {any} - */ - subscribe(infos: Subscription[]): Promise { - const request = new pb.Request(); - const subscription = new pb.SubscriptionRequest(); - const tracksInfos = Array(); - - infos.forEach((t: Subscription) => { - const trackInfo = new pb.Subscription(); - trackInfo.setTrackid(t.track_id); - trackInfo.setMute(t.muted); - trackInfo.setLayer(t.layer); - trackInfo.setSubscribe(t.subscribe); - tracksInfos.push(trackInfo); - }); - subscription.setSubscriptionsList(tracksInfos); - request.setSubscription(subscription); - this._client.send(request); + /** + * send answer request + * @date 2021-11-03 + * @param {any} answer:RTCSessionDescriptionInit + * @returns {any} + */ + answer(answer: RTCSessionDescriptionInit) { + const request = new pb.Request(); + const desc = new pb.SessionDescription(); + desc.setSdp(answer.sdp || ''); + desc.setType(answer.type || ''); + desc.setTarget(pb.Target.SUBSCRIBER); + request.setDescription(desc); + this._client.send(request); + } - return new Promise((resolve, reject) => { - const handler = (res: Result) => { - resolve(res); - this._event.removeListener('subscription', handler); - }; - this._event.addListener('subscription', handler); - }); - } + /** + * close client + * @date 2021-11-03 + * @returns {any} + */ + close(): void { + this._client?.close(); + } + /** + * subscribe + * @date 2021-11-03 + * @param {any} infos:Subscription[] + * @returns {any} + */ + subscribe(infos: Subscription[]): Promise { + const request = new pb.Request(); + const subscription = new pb.SubscriptionRequest(); + const tracksInfos = Array(); - /** - * build TrackInfos - * @date 2021-11-03 - * @param {any} stream:LocalStream - * @returns {any} - */ - buildTrackInfos(stream: LocalStream): void { - const tracks = stream.getTracks(); - const trackInfos = new Array(); - for (const track of tracks) { - const trackInfo = new pb.TrackInfo; - trackInfo.setId(track.id); - trackInfo.setKind(track.kind); - trackInfo.setLabel(track.label); - trackInfo.setStreamid(stream.id); - trackInfo.setMuted(!track.enabled); - trackInfo.setType(MediaType.USERMEDIA); - trackInfos.push(trackInfo); - } - this._tracksInfos = trackInfos; + infos.forEach((t: Subscription) => { + const trackInfo = new pb.Subscription(); + trackInfo.setTrackid(t.track_id); + trackInfo.setMute(t.muted); + trackInfo.setLayer(t.layer); + trackInfo.setSubscribe(t.subscribe); + tracksInfos.push(trackInfo); + }); + subscription.setSubscriptionsList(tracksInfos); + request.setSubscription(subscription); + this._client.send(request); + + return new Promise((resolve, reject) => { + const handler = (res: Result) => { + resolve(res); + this._event.removeListener('subscription', handler); + }; + this._event.addListener('subscription', handler); + }); + } + + /** + * build TrackInfos + * @date 2021-11-03 + * @param {any} stream:LocalStream + * @returns {any} + */ + buildTrackInfos(stream: LocalStream): void { + const tracks = stream.getTracks(); + const trackInfos = new Array(); + for (const track of tracks) { + const trackInfo = new pb.TrackInfo(); + trackInfo.setId(track.id); + trackInfo.setKind(track.kind); + trackInfo.setLabel(track.label); + trackInfo.setStreamid(stream.id); + trackInfo.setMuted(!track.enabled); + trackInfo.setType(MediaType.USERMEDIA); + trackInfos.push(trackInfo); } + this._tracksInfos = trackInfos; + } } diff --git a/src/signal/grpc-web-impl.ts b/src/signal/grpc-web-impl.ts index 9507b63d..58d6e543 100644 --- a/src/signal/grpc-web-impl.ts +++ b/src/signal/grpc-web-impl.ts @@ -24,7 +24,7 @@ class IonSFUGRPCWebSignal implements Signal { }) as grpc.Client; client.onEnd((status: grpc.Code, statusMessage: string, trailers: grpc.Metadata) => { - this._onclose?.call(this, new CustomEvent("sfu",{ "detail": {status, statusMessage}})); + this._onclose?.call(this, new CustomEvent('sfu', { detail: { status, statusMessage } })); }); client.onMessage((reply: pb.SignalReply) => { @@ -60,7 +60,6 @@ class IonSFUGRPCWebSignal implements Signal { } join(sid: string, uid: string, offer: RTCSessionDescriptionInit) { - const request = new pb.SignalRequest(); const join = new pb.JoinRequest(); join.setSid(sid); diff --git a/src/stream.ts b/src/stream.ts index 4b2bb131..95508e45 100644 --- a/src/stream.ts +++ b/src/stream.ts @@ -354,7 +354,7 @@ export class LocalStream extends MediaStream { const prev = this.getTrack(kind); // Firefox/Safari have issues when multiple input devices are used by same origin. We need to stop previous track before creating new one. - if (prev) prev.stop() + if (prev) prev.stop(); const next = await this.getNewTrack(kind); this.updateTrack(next, prev);