Before Add Audio Service

This commit is contained in:
ADAMJR 2021-10-04 17:39:59 +01:00
parent daf947b598
commit ce60f51034
3 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,22 @@
import { Socket } from 'socket.io';
import Users from '../../data/users';
import { EmailFunctions } from '../../email/email-functions';
import { WS } from '../../types/ws';
import Deps from '../../utils/deps';
import { WSGuard } from '../modules/ws-guard';
import { WebSocket } from '../websocket';
import { WSEvent, } from './ws-event';
export default class implements WSEvent<'VOICE_DATA'> {
on = 'VOICE_DATA' as const;
constructor(
private users = Deps.get<Users>(Users),
private guard = Deps.get<WSGuard>(WSGuard),
private sendEmail = Deps.get<EmailFunctions>(EmailFunctions),
) {}
public async invoke(ws: WebSocket, client: Socket, {}: WS.Params.VoiceData) {
client.emit('VOICE_DATA', {} as WS.Args.VoiceData);
}
}

View File

@ -142,6 +142,9 @@ const WSListener: React.FunctionComponent = () => {
dispatch(auth.updatedUser(args));
dispatch(users.updated(args));
});
ws.on('VOICE_DATA', (args) => {
//
});
ws.on('VOICE_STATE_UPDATE', (args) => {
const data = { userId: args.userId, partialUser: { voice: args.voice } };
dispatch(auth.updatedUser(data));

7
types/ws.d.ts vendored
View File

@ -49,6 +49,8 @@ declare namespace WS {
'USER_DELETE': WS.Params.UserDelete;
/** Update a user with a given token. */
'USER_UPDATE': WS.Params.UserUpdate;
/** Send voice data to the server. */
'VOICE_DATA': WS.Params.VoiceData;
}
export interface On {
@ -104,6 +106,8 @@ declare namespace WS {
'USER_DELETE': {};
/** Called the client user settings are updated. */
'USER_UPDATE': WS.Args.UserUpdate;
/** Receive voice data from the server. */
'VOICE_DATA': WS.Args.VoiceData;
/** Called when a user voice state is updated in the client's voice channel. */
'VOICE_STATE_UPDATE': WS.Args.VoiceStateUpdate;
'error': object;
@ -355,6 +359,9 @@ declare namespace WS {
export interface UserUpdate {
userId: string;
partialUser: Partial<UserTypes.Self>;
}
export interface VoiceData {
}
export interface VoiceStateUpdate {
userId: string;