|
|
@ -18,8 +18,6 @@ await receiver.bind(`tcp://127.0.0.1:5558`);
|
|
|
|
const clients: Record<string, FastifyReply> = {};
|
|
|
|
const clients: Record<string, FastifyReply> = {};
|
|
|
|
const generateId = () => nanoid(32);
|
|
|
|
const generateId = () => nanoid(32);
|
|
|
|
|
|
|
|
|
|
|
|
//let updates: Update[] = [];
|
|
|
|
|
|
|
|
//let doc = Text.of(["foo"]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type Room = {
|
|
|
|
type Room = {
|
|
|
|
sockets: WebSocket[];
|
|
|
|
sockets: WebSocket[];
|
|
|
@ -116,15 +114,12 @@ fastify.post("/live", {
|
|
|
|
const { code } = request.body;
|
|
|
|
const { code } = request.body;
|
|
|
|
let roomId = generateId();
|
|
|
|
let roomId = generateId();
|
|
|
|
let room = rooms[roomId];
|
|
|
|
let room = rooms[roomId];
|
|
|
|
|
|
|
|
|
|
|
|
if(!room){
|
|
|
|
|
|
|
|
room = {
|
|
|
|
room = {
|
|
|
|
sockets: [],
|
|
|
|
sockets: [],
|
|
|
|
updates: [],
|
|
|
|
updates: [],
|
|
|
|
doc: Text.of([code])
|
|
|
|
doc: Text.of([code])
|
|
|
|
};
|
|
|
|
};
|
|
|
|
rooms[roomId] = room;
|
|
|
|
rooms[roomId] = room;
|
|
|
|
}
|
|
|
|
|
|
|
|
return roomId;
|
|
|
|
return roomId;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|