My next project was making an app using Corticon, a decision making tool by Progress. For the project, I started by using the tools I was familiar with NodeJS for the server and AngularJS with Jade for the frontend. To work with Corticon, I needed to communicate using JSON, which was relatively straightforward once I learned the format used by Corticon. For the first version of the app, I simulated the Corticon server with a NodeJS server. My server had a simple rule where given a number, it returned its negative. I soon had a working app that had a counter, which a user could reset. To make the app slightly more interesting, I wrote the app so that when reset, the counter would decrease till it reached zero, then increase again. In addition, I had the client display the counter squared in changing colors. However, this app allowed the server to send information to the client only when the client requested it (shown below).
To allow the server to send information to the client, without it being requested, I turned to Socket.io. This allows bidirectional communication between the client and server. A common example of an app that can be made using Socket.io is a chat client. For my project, however, I decided that I would continue building something similar to my previous app. To allow Socket.io to work easily with Angular, I decided to use the Angular Socket.io Seed as a starting point for my app. One thing to note about using this as a starting point is that it does not use the most up to date versions of Socket and Express. (Also, when building of the seed, instead of having a separate socket.js file, I moved my Socket.io code to the app.js file with the rest of the server code.)
Using Socket.io, I was able to send messages between the server and client, and using JSON requests, I was able to communicate with my simulated Corticon server. I now had an app where information could be passed both ways. However, my app continued to only have the server communicate with one client at a time. If I reset the count from one instance, it would not affect the rest. To address this issue, I changed my code slightly so that whenever a reset message was received by the server, it would broadcast the response to all clients. This allowed one client to easily change the rest, something that would have been much more difficult without Socket.io. I thus had a bidirectional app using Corticon calls for making decisions (design shown below).