boilerplate stuff
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
import { WebSocket } from "@fosscord/gateway";
|
||||
import { Payload } from "./index";
|
||||
|
||||
export async function onConnect(socket: WebSocket, data: Payload) {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { WebSocket } from "@fosscord/gateway";
|
||||
import { Payload } from "./index";
|
||||
import { setHeartbeat } from "./../util";
|
||||
|
||||
export async function onHeartbeat(socket: WebSocket, data: Payload) {
|
||||
await setHeartbeat(socket);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { WebSocket } from "@fosscord/gateway";
|
||||
import { Payload } from "./index"
|
||||
import { VoiceOPCodes } from "@fosscord/util";
|
||||
|
||||
export async function onIdentify(socket: WebSocket, data: Payload) {
|
||||
socket.send(JSON.stringify({
|
||||
op: VoiceOPCodes.READY,
|
||||
d: {
|
||||
ssrc: 1,
|
||||
ip: "127.0.0.1",
|
||||
port: 3005,
|
||||
modes: [
|
||||
"xsalsa20_poly1305",
|
||||
"xsalsa20_poly1305_suffix",
|
||||
"xsalsa20_poly1305_lite",
|
||||
],
|
||||
heartbeat_interval: 1,
|
||||
},
|
||||
}));
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { WebSocket } from "@fosscord/gateway";
|
||||
import { Payload } from "./index";
|
||||
|
||||
export async function onResume(socket: WebSocket, data: Payload) {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { WebSocket } from "@fosscord/gateway";
|
||||
import { Payload } from "./index";
|
||||
import { VoiceOPCodes } from "@fosscord/util";
|
||||
|
||||
export async function onSelectProtocol(socket: WebSocket, data: Payload) {
|
||||
socket.send(JSON.stringify({
|
||||
op: VoiceOPCodes.SESSION_DESCRIPTION,
|
||||
d: {
|
||||
video_codec: "H264",
|
||||
secret_key: new Array(32).fill(null).map(x => Math.random() * 256),
|
||||
mode: "aead_aes256_gcm_rtpsize",
|
||||
media_session_id: "d8eb5c84d987c6642ec4ce72ffa97f00",
|
||||
audio_codec: "opus",
|
||||
}
|
||||
}));
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { WebSocket } from "@fosscord/gateway";
|
||||
import { Payload } from "./index"
|
||||
import { VoiceOPCodes } from "@fosscord/util";
|
||||
|
||||
export async function onSpeaking(socket: WebSocket, data: Payload) {
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { WebSocket } from "@fosscord/gateway";
|
||||
import { VoiceOPCodes } from "@fosscord/util";
|
||||
|
||||
export interface Payload {
|
||||
op: number;
|
||||
d?: any;
|
||||
s?: number;
|
||||
t?: string;
|
||||
}
|
||||
|
||||
import { onIdentify } from "./Identify";
|
||||
import { onSelectProtocol } from "./SelectProtocol";
|
||||
import { onHeartbeat } from "./Heartbeat";
|
||||
import { onSpeaking } from "./Speaking";
|
||||
import { onResume } from "./Resume";
|
||||
import { onConnect } from "./Connect";
|
||||
|
||||
export type OPCodeHandler = (this: WebSocket, data: Payload) => any;
|
||||
|
||||
export default {
|
||||
[VoiceOPCodes.IDENTIFY]: onIdentify, //op 0
|
||||
[VoiceOPCodes.SELECT_PROTOCOL]: onSelectProtocol, //op 1
|
||||
//op 2 voice_ready
|
||||
[VoiceOPCodes.HEARTBEAT]: onHeartbeat, //op 3
|
||||
//op 4 session_description
|
||||
[VoiceOPCodes.SPEAKING]: onSpeaking, //op 5
|
||||
//op 6 heartbeat_ack
|
||||
[VoiceOPCodes.RESUME]: onResume, //op 7
|
||||
//op 8 hello
|
||||
//op 9 resumed
|
||||
//op 10?
|
||||
//op 11?
|
||||
[VoiceOPCodes.CLIENT_CONNECT]: onConnect, //op 12
|
||||
//op 13?
|
||||
};
|
||||
Reference in New Issue
Block a user