Fixing disconnect call
This commit is contained in:
parent
6a4c0c8678
commit
2cea0e490b
@ -66,13 +66,14 @@ enum SocketIoEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void {
|
function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void {
|
||||||
if (socket.disconnecting) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
socket.batchedMessages.addPayload(payload);
|
socket.batchedMessages.addPayload(payload);
|
||||||
|
|
||||||
if (socket.batchTimeout === null) {
|
if (socket.batchTimeout === null) {
|
||||||
socket.batchTimeout = setTimeout(() => {
|
socket.batchTimeout = setTimeout(() => {
|
||||||
|
if (socket.disconnecting) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const serverToClientMessage = new ServerToClientMessage();
|
const serverToClientMessage = new ServerToClientMessage();
|
||||||
serverToClientMessage.setBatchmessage(socket.batchedMessages);
|
serverToClientMessage.setBatchmessage(socket.batchedMessages);
|
||||||
|
|
||||||
@ -688,13 +689,13 @@ export class IoSocketController {
|
|||||||
// TODO: REBUILD THIS
|
// TODO: REBUILD THIS
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (socket.webRtcRoomId === roomId) {
|
/* if (socket.webRtcRoomId === roomId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
socket.join(roomId);
|
socket.join(roomId);
|
||||||
socket.webRtcRoomId = roomId;
|
socket.webRtcRoomId = roomId;
|
||||||
//if two persons in room share
|
//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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -718,7 +719,7 @@ export class IoSocketController {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
client.emit(SocketIoEvent.WEBRTC_START, {clients: peerClients, roomId: roomId});
|
client.emit(SocketIoEvent.WEBRTC_START, {clients: peerClients, roomId: roomId});
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/** permit to share user position
|
/** permit to share user position
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import {Application, Request, Response} from "express";
|
import {App} from "../Server/sifrr.server";
|
||||||
import {IoSocketController} from "_Controller/IoSocketController";
|
import {IoSocketController} from "_Controller/IoSocketController";
|
||||||
|
import {HttpRequest, HttpResponse} from "uWebSockets.js";
|
||||||
const register = require('prom-client').register;
|
const register = require('prom-client').register;
|
||||||
const collectDefaultMetrics = require('prom-client').collectDefaultMetrics;
|
const collectDefaultMetrics = require('prom-client').collectDefaultMetrics;
|
||||||
|
|
||||||
export class PrometheusController {
|
export class PrometheusController {
|
||||||
constructor(private App: Application, private ioSocketController: IoSocketController) {
|
constructor(private App: App, private ioSocketController: IoSocketController) {
|
||||||
collectDefaultMetrics({
|
collectDefaultMetrics({
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
gcDurationBuckets: [0.001, 0.01, 0.1, 1, 2, 5], // These are the default buckets.
|
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));
|
this.App.get("/metrics", this.metrics.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private metrics(req: Request, res: Response): void {
|
private metrics(res: HttpResponse, req: HttpRequest): void {
|
||||||
res.set('Content-Type', register.contentType);
|
res.writeHeader('Content-Type', register.contentType);
|
||||||
res.end(register.metrics());
|
res.end(register.metrics());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user