🌜🌊 Checkpoint
./server.js:530995/754 ./views/room.handlebars:530995/303
This commit is contained in:
parent
1abee4f9d7
commit
cd9cb268ef
17
server.js
17
server.js
@ -37,7 +37,9 @@ app.get("/:roomId/join", (request, response) => {
|
|||||||
response.render('room', {
|
response.render('room', {
|
||||||
layout: false,
|
layout: false,
|
||||||
room: request.params.roomId,
|
room: request.params.roomId,
|
||||||
name: participant.participantName
|
name: participant.participantName,
|
||||||
|
participantName: participant.participantName,
|
||||||
|
participantId: participant.participantId,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
response.render('join', {layout: false, room: request.params.roomId});
|
response.render('join', {layout: false, room: request.params.roomId});
|
||||||
@ -46,11 +48,7 @@ app.get("/:roomId/join", (request, response) => {
|
|||||||
|
|
||||||
app.post("/:roomId/join", (request, response) => {
|
app.post("/:roomId/join", (request, response) => {
|
||||||
rooms.addParticipant(request.params.roomId, request.fingerprint.hash, request.body.name);
|
rooms.addParticipant(request.params.roomId, request.fingerprint.hash, request.body.name);
|
||||||
response.render('room', {
|
response.redirect(`/${request.params.roomId}/join`);
|
||||||
layout: false,
|
|
||||||
room: request.params.roomId,
|
|
||||||
name: request.body.name
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(process.env.PORT, () => {
|
server.listen(process.env.PORT, () => {
|
||||||
@ -59,9 +57,12 @@ server.listen(process.env.PORT, () => {
|
|||||||
|
|
||||||
|
|
||||||
const wss = new WebSocket.Server({ server });
|
const wss = new WebSocket.Server({ server });
|
||||||
wss.on('connection', (ws) => {
|
wss.on('connection', (ws, req) => {
|
||||||
ws.on('message', (message) => {
|
ws.on('message', (message) => {
|
||||||
console.log('received: %s', message);
|
message = JSON.stringify(message);
|
||||||
|
console.log(message)
|
||||||
|
console.log(message.type)
|
||||||
|
console.log(message.data)
|
||||||
});
|
});
|
||||||
|
|
||||||
ws.send('Connected');
|
ws.send('Connected');
|
||||||
|
@ -27,11 +27,17 @@
|
|||||||
let socket = new WebSocket(`wss://${window.location.hostname}`);
|
let socket = new WebSocket(`wss://${window.location.hostname}`);
|
||||||
|
|
||||||
socket.onopen = function(e) {
|
socket.onopen = function(e) {
|
||||||
socket.send("My name is John");
|
socket.send({
|
||||||
|
type: "join",
|
||||||
|
data: {
|
||||||
|
participantId: '{{participantId}}',
|
||||||
|
participantName: '{{participantName}}',
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onmessage = function(event) {
|
socket.onmessage = function(event) {
|
||||||
a
|
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onerror = function(error) {
|
socket.onerror = function(error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user