asd
This commit is contained in:
@@ -27,6 +27,10 @@ const configuration: RTCConfiguration = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type Message = {
|
||||||
|
type: "HeartBeat" | "GameState" | "UpdatePosition";
|
||||||
|
};
|
||||||
|
|
||||||
export async function initWebRTC(peerId?: string) {
|
export async function initWebRTC(peerId?: string) {
|
||||||
const peer = new Peer({
|
const peer = new Peer({
|
||||||
config: configuration,
|
config: configuration,
|
||||||
@@ -36,7 +40,7 @@ export async function initWebRTC(peerId?: string) {
|
|||||||
console.log(`Connection received from: ${conn.peer}`);
|
console.log(`Connection received from: ${conn.peer}`);
|
||||||
|
|
||||||
conn.on("open", () => {
|
conn.on("open", () => {
|
||||||
conn.on("data", (data) => {
|
conn.on("data", (data: Message) => {
|
||||||
console.log(`Data: ${data}`);
|
console.log(`Data: ${data}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -52,7 +56,7 @@ export async function initWebRTC(peerId?: string) {
|
|||||||
const conn = peer.connect(peerId);
|
const conn = peer.connect(peerId);
|
||||||
|
|
||||||
conn.on("open", () => {
|
conn.on("open", () => {
|
||||||
conn.on("data", (data) => {
|
conn.on("data", (data: Message) => {
|
||||||
console.log(`Data: ${data}`);
|
console.log(`Data: ${data}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user