export API.

This commit is contained in:
Miroslav Šedivý 2020-12-26 23:21:49 +01:00
parent c7fde94ac4
commit c796a9e530
2 changed files with 19 additions and 46 deletions

View File

@ -16,15 +16,14 @@ export class NekoApi {
this.api_configuration = new Api.Configuration() this.api_configuration = new Api.Configuration()
} }
get admin(): Api.AdminsApi { get room(): RoomApi {
return new Api.AdminsApi(this.api_configuration) return new Api.RoomApi(this.api_configuration)
} }
get user(): Api.UsersApi { get members(): MembersApi {
return new Api.UsersApi(this.api_configuration) return new Api.MembersApi(this.api_configuration)
}
get host(): Api.HostsApi {
return new Api.HostsApi(this.api_configuration)
} }
} }
export type RoomApi = Api.RoomApi
export type MembersApi = Api.MembersApi

View File

@ -47,7 +47,7 @@
import ResizeObserver from 'resize-observer-polyfill' import ResizeObserver from 'resize-observer-polyfill'
import EventEmitter from 'eventemitter3' import EventEmitter from 'eventemitter3'
import { NekoApi } from './internal/api' import { NekoApi, MembersApi, RoomApi } from './internal/api'
import { NekoWebSocket } from './internal/websocket' import { NekoWebSocket } from './internal/websocket'
import { NekoWebRTC } from './internal/webrtc' import { NekoWebRTC } from './internal/webrtc'
import { NekoMessages } from './internal/messages' import { NekoMessages } from './internal/messages'
@ -223,67 +223,41 @@
public setClipboardData(text: string) { public setClipboardData(text: string) {
const clipboardPayload = { text } const clipboardPayload = { text }
this.api.host.clipboardWrite({ clipboardPayload }) this.api.room.clipboardWrite({ clipboardPayload })
} }
public requestControl() { public requestControl() {
this.api.user.controlRequest() this.api.room.controlRequest()
} }
public releaseControl() { public releaseControl() {
this.api.user.controlRelease() this.api.room.controlRelease()
} }
public takeControl() { public takeControl() {
this.api.admin.controlTake() this.api.room.controlTake()
} }
public giveControl(id: string) { public giveControl(id: string) {
const controlTargetPayload = { id } const controlTargetPayload = { id }
this.api.admin.controlGive({ controlTargetPayload }) this.api.room.controlGive({ controlTargetPayload })
} }
public resetControl() { public resetControl() {
this.api.admin.controlReset() this.api.room.controlReset()
} }
public setScreenSize(width: number, height: number, rate: number) { 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 }) this.websocket.send('screen/set', { width, height, rate })
} }
public memberCreate(memberDataPayload: { public get room(): RoomApi {
id: string return this.api.room
secret: string
name: string
isAdmin: boolean
canLogin: boolean
canConnect: boolean
canWatch: boolean
canHost: boolean
canAccessClipboard: boolean
}) {
this.api.admin.membersCreate({ memberDataPayload })
} }
public memberUpdate( public get members(): MembersApi {
memberId: string, return this.api.members
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 })
} }
// TODO: Refactor. // TODO: Refactor.