Archived
2
0

live change resolution (WIP)

This commit is contained in:
Craig
2020-02-11 05:15:59 +00:00
parent 3d1341cfe1
commit 9e995233af
27 changed files with 747 additions and 127 deletions

View File

@ -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

View File

@ -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
/////////////////////////////

View File

@ -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
*/

View File

@ -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 }
}