update merge
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

pull/5/head
Bastien OLLIER 11 months ago committed by clfreville2
parent 150376a2da
commit fc268e93e7

@ -14,16 +14,14 @@ await sender.bind(`tcp://127.0.0.1:5557`);
const receiver = new Pull();
await receiver.bind(`tcp://127.0.0.1:5558`);
const clients: Record<string, FastifyReply> = {};
const generateId = () => nanoid(32);
type Room = {
sockets: WebSocket[];
updates: Update[];
doc: Text;
}
};
const rooms: Record<string, Room> = {};
@ -44,7 +42,6 @@ await fastify.register(cors, {
});
fastify.register(websocket);
fastify.register(async function(fastify: Fastify) {
fastify.get(
"/live/:roomId",
@ -52,9 +49,9 @@ fastify.register(async function (fastify: Fastify) {
schema: {
params: Type.Object({
roomId: Type.String(),
})
}),
},
websocket: true
websocket: true,
},
(socket, request) => {
const { roomId } = request.params;
@ -63,7 +60,7 @@ fastify.register(async function (fastify: Fastify) {
room = {
sockets: [],
updates: [],
doc: Text.of([''])
doc: Text.of([""]),
};
rooms[roomId] = room;
}
@ -100,8 +97,9 @@ fastify.register(async function (fastify: Fastify) {
send(socket, requestId, { version: room.updates.length, doc: room.doc.toString() });
}
});
},
);
});
})
/* Route pour créer une room */
fastify.post("/live", {
@ -121,12 +119,11 @@ fastify.post("/live", {
room = {
sockets: [],
updates: [],
doc: Text.of([code])
doc: Text.of([code]),
};
rooms[roomId] = room;
return roomId;
},
);
});
fastify.post("/run", {
schema: {

Loading…
Cancel
Save