MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / addUser

Function addUser

run/websockets/users.js:19–24  ·  view source on GitHub ↗
(id, name, room)

Source from the content-addressed store, hash-verified

17
18// Record socket ID with user's name and chat room
19function addUser(id, name, room) {
20 if (!name && !room) return new Error('Username and room are required');
21 if (!name) return new Error('Username is required');
22 if (!room) return new Error('Room is required');
23 users.set(id, {user: name, room});
24}
25
26// Return user's name and chat room from socket ID
27function getUser(id) {

Callers 1

app.jsFile · 0.85

Calls 1

setMethod · 0.80

Tested by

no test coverage detected