Skip to content

Instantly share code, notes, and snippets.

@barmgeat
Created June 28, 2019 11:20
Show Gist options
  • Save barmgeat/3dc09ef34f80010ccf115679c461d6d3 to your computer and use it in GitHub Desktop.
Save barmgeat/3dc09ef34f80010ccf115679c461d6d3 to your computer and use it in GitHub Desktop.
function registerNeuUser(data){
userName = data.userName;
firstName = data.firstName;
lastName = data.lastName;
email = data.email;
password = data.password;
birthDay = data.birthDay;
//log the registered user
console.log('++++++++++ New-User +++++++++++++\n' +
userName + '\n' +
firstName + '\n' +
lastName + '\n' +
email + '\n' +
password + '\n' +
birthDay + '\n++++++++ End-User +++++++++++++'
);
}
function needLogin(data, socket){
// get the session ip to save it inside the active users
address = socket.handshake.address;
userName = data.userName;
password = data.password;
console.log(
'++++++++++ User-login +++++++++++++\n' +
userName + '\n' +
password +
address +
'\n++++++++ End-login +++++++++++++'
);
//handel user requests after success login :
socket.on('set me online', setMeOnline);
socket.on('is my friend online', isMyFriendOnline);
socket.on('need my messages', needMyMessages);
socket.on('im going out', data=>{
logOut(data, socket);
});
}
function setMeOnline(data) {
console.log('++++++++++ User-online +++++++++++++\n' +
data.userName +
'\n++++++++ End-online +++++++++++++'
);
}
function isMyFriendOnline(data){
userId = data.id;
friendId = data.friendId;
// check if the both friends
}
function needMyMessages(data){
userName = data.userName;
id = data.id;
console.log(
'++++++++++ User-need-messages +++++++++++++\n' +
userName + '\n' + id +
'\n++++++++ End-messages +++++++++++++'
);
}
function logOut(data, socket){
socket.removeListener('set me online', setMeOnline);
socket.removeListener('is my friend online', isMyFriendOnline);
socket.removeListener('need my messages', needMyMessages);
console.log(
'++++++++++ User-logout +++++++++++++\n' +
data.userName + '\n' +
'\n++++++++ End-logout +++++++++++++'
);
}
module.exports = {
registerNeuUser: registerNeuUser,
needLogin:needLogin,
logOut: logOut,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment