Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
handlePipeMessage: function(message) { //EntitlementModule implements a 3rd party authentication system defined in its own core, serves to other cores plus handles direct requests from other client app if(message instanceof common.ShellMessage) { //message from Shell if(message.body.request.query.authToken) { //if authToken was passed -> MyAgenda (personalized) else General Agenda message.body.sender = modules.AgendaModule.NAME; //set sender as there are other modules listening on stdout of EntitlementModule for authentication response this.getJunction().sendMessage(modules.EntitlementModule.NAME, new common.EntitlementMessage({body:message.body})); //get authenticated, response handled below. } else { //general public agenda/sessions if(message.body.request.route.path == "/sessions/:id") { this.sendNotification(modules.agenda.ApplicationFacade.SESSION, message.body); } else { this.sendNotification(modules.agenda.ApplicationFacade.GENERAL_AGENDA, message.body); } } } else if(message instanceof common.EntitlementMessage && message.body.sender == modules.AgendaModule.NAME) { //reply from EntitlementModule in response to above auth request if(message.body.data) { //if authentication successful this.sendNotification(modules.agenda.ApplicationFacade.MY_AGENDA, message.body); } else { //if authentication failed message.body.info.statusCode = 401; message.body.info.message = "Unauthorized"; this.sendNotification(modules.agenda.ApplicationFacade.AGENDA_FAIL, message.body); } }},
handlePipeMessage: function(message) { if(message instanceof common.ChatMessage) { message.getBody().request = {id:message.getBody().socket.id, query:{authToken:message.getBody().socket.handshake.query.authToken}}; //if authToken was passed switch(message.action) { case "connection": //get authenticated first message.body.sender = modules.ChatModule.NAME //specify sender as this module is listening to stdout this.getJunction().sendMessage(modules.EntitlementModule.NAME, new common.EntitlementMessage({body:message.getBody()})); break; case "chat": //send a message to the other socket this.sendNotification(modules.chat.ApplicationFacade.CHAT, message.getBody()); break; case "disconnect": this.sendNotification(modules.chat.ApplicationFacade.DISCONNECT, message.getBody()); break; } } else if(message instanceof common.EntitlementMessage && message.body.sender == modules.ChatModule.NAME) { //response as a result of above authToken if(message.body.data) { //user is valid, create a connection this.sendNotification(modules.chat.ApplicationFacade.CONNECTION, message.body); } else if(message.body.info) { //authentication failed this.sendNotification(modules.chat.ApplicationFacade.CHAT_FAIL, {info:{statusCode:401, message:{errorCode:message.body.info.errorCode}}, request:message.body.request, response:message.body.response}); } }}