From c796a9e530f8e7ab67df683df3fda9789254ae5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sat, 26 Dec 2020 23:21:49 +0100 Subject: [PATCH] export API. --- src/component/internal/api.ts | 15 +++++------ src/component/main.vue | 50 +++++++++-------------------------- 2 files changed, 19 insertions(+), 46 deletions(-) diff --git a/src/component/internal/api.ts b/src/component/internal/api.ts index 159058a8..2d5f0991 100644 --- a/src/component/internal/api.ts +++ b/src/component/internal/api.ts @@ -16,15 +16,14 @@ export class NekoApi { this.api_configuration = new Api.Configuration() } - get admin(): Api.AdminsApi { - return new Api.AdminsApi(this.api_configuration) + get room(): RoomApi { + return new Api.RoomApi(this.api_configuration) } - get user(): Api.UsersApi { - return new Api.UsersApi(this.api_configuration) - } - - get host(): Api.HostsApi { - return new Api.HostsApi(this.api_configuration) + get members(): MembersApi { + return new Api.MembersApi(this.api_configuration) } } + +export type RoomApi = Api.RoomApi +export type MembersApi = Api.MembersApi diff --git a/src/component/main.vue b/src/component/main.vue index 82a273e4..b8ba7853 100644 --- a/src/component/main.vue +++ b/src/component/main.vue @@ -47,7 +47,7 @@ import ResizeObserver from 'resize-observer-polyfill' import EventEmitter from 'eventemitter3' - import { NekoApi } from './internal/api' + import { NekoApi, MembersApi, RoomApi } from './internal/api' import { NekoWebSocket } from './internal/websocket' import { NekoWebRTC } from './internal/webrtc' import { NekoMessages } from './internal/messages' @@ -223,67 +223,41 @@ public setClipboardData(text: string) { const clipboardPayload = { text } - this.api.host.clipboardWrite({ clipboardPayload }) + this.api.room.clipboardWrite({ clipboardPayload }) } public requestControl() { - this.api.user.controlRequest() + this.api.room.controlRequest() } public releaseControl() { - this.api.user.controlRelease() + this.api.room.controlRelease() } public takeControl() { - this.api.admin.controlTake() + this.api.room.controlTake() } public giveControl(id: string) { const controlTargetPayload = { id } - this.api.admin.controlGive({ controlTargetPayload }) + this.api.room.controlGive({ controlTargetPayload }) } public resetControl() { - this.api.admin.controlReset() + this.api.room.controlReset() } public setScreenSize(width: number, height: number, rate: number) { - //this.api.admin.screenConfigurationChange({ screenConfigurationPayload: { width, height, rate } }) + //this.api.room.screenConfigurationChange({ screenConfigurationPayload: { width, height, rate } }) this.websocket.send('screen/set', { width, height, rate }) } - public memberCreate(memberDataPayload: { - id: string - secret: string - name: string - isAdmin: boolean - canLogin: boolean - canConnect: boolean - canWatch: boolean - canHost: boolean - canAccessClipboard: boolean - }) { - this.api.admin.membersCreate({ memberDataPayload }) + public get room(): RoomApi { + return this.api.room } - public memberUpdate( - memberId: string, - memberProfile: { - secret: string - name: string - isAdmin: boolean - canLogin: boolean - canConnect: boolean - canWatch: boolean - canHost: boolean - canAccessClipboard: boolean - }, - ) { - this.api.admin.membersUpdate({ memberId, memberProfile }) - } - - public memberDelete(memberId: string) { - this.api.admin.membersDelete({ memberId }) + public get members(): MembersApi { + return this.api.members } // TODO: Refactor.