Fixing disconnect call

This commit is contained in:
David Négrier 2020-09-29 09:45:47 +02:00
parent 6a4c0c8678
commit 2cea0e490b
2 changed files with 12 additions and 10 deletions

View File

@ -66,13 +66,14 @@ enum SocketIoEvent {
}
function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void {
if (socket.disconnecting) {
return;
}
socket.batchedMessages.addPayload(payload);
if (socket.batchTimeout === null) {
socket.batchTimeout = setTimeout(() => {
if (socket.disconnecting) {
return;
}
const serverToClientMessage = new ServerToClientMessage();
serverToClientMessage.setBatchmessage(socket.batchedMessages);
@ -688,13 +689,13 @@ export class IoSocketController {
// TODO: REBUILD THIS
return;
if (socket.webRtcRoomId === roomId) {
/* if (socket.webRtcRoomId === roomId) {
return;
}
socket.join(roomId);
socket.webRtcRoomId = roomId;
//if two persons in room share
if (this.Io.sockets.adapter.rooms[roomId].length < 2 /*|| this.Io.sockets.adapter.rooms[roomId].length >= 4*/) {
if (this.Io.sockets.adapter.rooms[roomId].length < 2) {
return;
}
@ -718,7 +719,7 @@ export class IoSocketController {
}, []);
client.emit(SocketIoEvent.WEBRTC_START, {clients: peerClients, roomId: roomId});
});
});*/
}
/** permit to share user position

View File

@ -1,10 +1,11 @@
import {Application, Request, Response} from "express";
import {App} from "../Server/sifrr.server";
import {IoSocketController} from "_Controller/IoSocketController";
import {HttpRequest, HttpResponse} from "uWebSockets.js";
const register = require('prom-client').register;
const collectDefaultMetrics = require('prom-client').collectDefaultMetrics;
export class PrometheusController {
constructor(private App: Application, private ioSocketController: IoSocketController) {
constructor(private App: App, private ioSocketController: IoSocketController) {
collectDefaultMetrics({
timeout: 10000,
gcDurationBuckets: [0.001, 0.01, 0.1, 1, 2, 5], // These are the default buckets.
@ -13,8 +14,8 @@ export class PrometheusController {
this.App.get("/metrics", this.metrics.bind(this));
}
private metrics(req: Request, res: Response): void {
res.set('Content-Type', register.contentType);
private metrics(res: HttpResponse, req: HttpRequest): void {
res.writeHeader('Content-Type', register.contentType);
res.end(register.metrics());
}
}