live change resolution (WIP)
This commit is contained in:
@ -36,6 +36,11 @@ export const EVENT = {
|
||||
MESSAGE: 'chat/message',
|
||||
EMOTE: 'chat/emote',
|
||||
},
|
||||
SCREEN: {
|
||||
CONFIGURATIONS: 'screen/configurations',
|
||||
RESOLUTION: 'screen/resolution',
|
||||
SET: 'screen/set',
|
||||
},
|
||||
ADMIN: {
|
||||
BAN: 'admin/ban',
|
||||
KICK: 'admin/kick',
|
||||
@ -58,6 +63,7 @@ export type WebSocketEvents =
|
||||
| MemberEvents
|
||||
| SignalEvents
|
||||
| ChatEvents
|
||||
| ScreenEvents
|
||||
| AdminEvents
|
||||
|
||||
export type ControlEvents =
|
||||
@ -72,6 +78,8 @@ export type IdentityEvents = typeof EVENT.IDENTITY.PROVIDE | typeof EVENT.IDENTI
|
||||
export type MemberEvents = typeof EVENT.MEMBER.LIST | typeof EVENT.MEMBER.CONNECTED | typeof EVENT.MEMBER.DISCONNECTED
|
||||
export type SignalEvents = typeof EVENT.SIGNAL.ANSWER | typeof EVENT.SIGNAL.PROVIDE
|
||||
export type ChatEvents = typeof EVENT.CHAT.MESSAGE | typeof EVENT.CHAT.EMOTE
|
||||
export type ScreenEvents = typeof EVENT.SCREEN.CONFIGURATIONS | typeof EVENT.SCREEN.RESOLUTION | typeof EVENT.SCREEN.SET
|
||||
|
||||
export type AdminEvents =
|
||||
| typeof EVENT.ADMIN.BAN
|
||||
| typeof EVENT.ADMIN.KICK
|
||||
|
@ -15,9 +15,11 @@ import {
|
||||
ControlTargetPayload,
|
||||
ChatPayload,
|
||||
EmotePayload,
|
||||
ControlClipboardPayload,
|
||||
ScreenConfigurationsPayload,
|
||||
ScreenResolutionPayload,
|
||||
AdminPayload,
|
||||
AdminTargetPayload,
|
||||
ControlClipboardPayload,
|
||||
} from './messages'
|
||||
|
||||
interface NekoEvents extends BaseEvents {}
|
||||
@ -285,6 +287,33 @@ export class NekoClient extends BaseClient implements EventEmitter<NekoEvents> {
|
||||
this.$accessor.chat.newEmote({ type: emote })
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// Screen Events
|
||||
/////////////////////////////
|
||||
protected [EVENT.SCREEN.CONFIGURATIONS]({ configurations }: ScreenConfigurationsPayload) {
|
||||
this.$accessor.video.setConfigurations(configurations)
|
||||
}
|
||||
|
||||
protected [EVENT.SCREEN.RESOLUTION]({ id, width, height, rate }: ScreenResolutionPayload) {
|
||||
this.$accessor.video.setResolution({ width, height, rate })
|
||||
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
|
||||
const member = this.member(id)
|
||||
if (!member || member.ignored) {
|
||||
return
|
||||
}
|
||||
|
||||
this.$accessor.chat.newMessage({
|
||||
id,
|
||||
content: `chaned the resolution to ${width}x${height}@${rate}`,
|
||||
type: 'event',
|
||||
created: new Date(),
|
||||
})
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// Admin Events
|
||||
/////////////////////////////
|
||||
|
@ -7,9 +7,10 @@ import {
|
||||
MemberEvents,
|
||||
SignalEvents,
|
||||
ChatEvents,
|
||||
ScreenEvents,
|
||||
AdminEvents,
|
||||
} from './events'
|
||||
import { Member } from './types'
|
||||
import { Member, ScreenConfigurations } from './types'
|
||||
|
||||
export type WebSocketMessages =
|
||||
| WebSocketMessage
|
||||
@ -19,6 +20,8 @@ export type WebSocketMessages =
|
||||
| MembeConnectMessage
|
||||
| MembeDisconnectMessage
|
||||
| ControlMessage
|
||||
| ScreenResolutionMessage
|
||||
| ScreenConfigurationsMessage
|
||||
| ChatMessage
|
||||
|
||||
export type WebSocketPayloads =
|
||||
@ -31,6 +34,8 @@ export type WebSocketPayloads =
|
||||
| ChatPayload
|
||||
| ChatSendPayload
|
||||
| EmojiSendPayload
|
||||
| ScreenResolutionPayload
|
||||
| ScreenConfigurationsPayload
|
||||
| AdminPayload
|
||||
|
||||
export interface WebSocketMessage {
|
||||
@ -145,6 +150,28 @@ export interface EmojiSendPayload {
|
||||
emote: string
|
||||
}
|
||||
|
||||
/*
|
||||
SCREEN PAYLOADS
|
||||
*/
|
||||
export interface ScreenResolutionMessage extends WebSocketMessage, ScreenResolutionPayload {
|
||||
event: ScreenEvents
|
||||
}
|
||||
|
||||
export interface ScreenResolutionPayload {
|
||||
id?: string
|
||||
width: number
|
||||
height: number
|
||||
rate: number
|
||||
}
|
||||
|
||||
export interface ScreenConfigurationsMessage extends WebSocketMessage, ScreenConfigurationsPayload {
|
||||
event: ScreenEvents
|
||||
}
|
||||
|
||||
export interface ScreenConfigurationsPayload {
|
||||
configurations: ScreenConfigurations
|
||||
}
|
||||
|
||||
/*
|
||||
ADMIN PAYLOADS
|
||||
*/
|
||||
|
@ -6,3 +6,13 @@ export interface Member {
|
||||
connected?: boolean
|
||||
ignored?: boolean
|
||||
}
|
||||
|
||||
export interface ScreenConfigurations {
|
||||
[index: number]: ScreenConfiguration
|
||||
}
|
||||
|
||||
export interface ScreenConfiguration {
|
||||
width: string
|
||||
height: string
|
||||
rates: { [index: number]: number }
|
||||
}
|
||||
|
Reference in New Issue
Block a user