Commit 93649a9f authored by Kannan V M's avatar Kannan V M
Browse files

update object names

parent a4f70063
......@@ -23,15 +23,15 @@ io.on('connection', (socket) => {
var id = socket.id;
socketids.push(id);
// when the client emits 'leaf data'
socket.on('leaf data', (data) => {
socket.on('leaf text', (leafdata) => {
if (!socketids.includes(id)) { //checks if socketid is already assigned with leafid
data["leafid"] = leafids[leafno]; //if not assign leafid
leafdata["leafid"] = leafids[leafno]; //if not assign leafid
leafno = leafno+1;
leavesdata[id] = data;
leavesdata[id] = leafdata;
} else {
leavesdata[id]["message"] = data["message"]; //if yes update the message
data = leavesdata[id];
leavesdata[id]["leaftext"] = leafdata["leaftext"]; //if yes update the message
leafdata = leavesdata[id];
};
socket.broadcast.emit('new message', data);
socket.broadcast.emit('leaf data', leafdata);
});
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment