Thursday, 27 February 2014

First PoC of sending TeamMentor's server-side request URLS to Firebase (and seeing it in realtime in an AngularJS page)

After getting my head around how Firebase works (see Using Firebase to sync data with a webpage (via Javascript, REST and Firebase Admin panel) and Trying our Firebase (Beta) hosting solution and good example of Firebase Security rules), I really wanted to see how it could work on a key feature that I've been wanting to add to TeamMentor for ages: Realtime viewing  of traffic and logs

And it worked :)

This is really exciting!!! (can you tell :)  ), specially since I can see so many great uses of this type of technique and technology in TeamMentor (for example it will allow for much better understanding on how the content is used, and for better collaboration between its readers (and authors))

I'm going to write a number of blog posts that explain how this works in detail, but the core of it is the C# code shown below (gist here) which is running on a test TeamMentor instance, and basically hooks into the ASP.net HTTP pipeline in order to send the current URL to Firebase (using Firebase's REST API):

Here is the AngularJS+Firebase Html app that I created in Eclipse which shows the data received from the TeamMentor website (i.e. all requests made by a client visiting its home page):


... here are the logs for a page that doesn't exist: 


... here are the requests for the TeamMentor error page:



Quick look at the C# code executed on the TeamMentor server (gist here):

Here is how the HTTP pipeline is hooked (using the TMEvents helper object from TM)



... the logDebugMsg and logRequestURL lambda functions are used to set the Firebase object to store the received messages:



... the sendData lambda function is used to configure the Firebase target app and authorisation token:


... the sendData_Raw lambda function is the one that sends the REST/POST request to the mapped Firebase app:


Let me know if you have any questions regarding this example.


Firebase recovers connection

In terms of being able to recover from going offline, Firebase seems to do a good job at reconnecting back to the server once the host box is back online (see image below which happened between me leaving my house and connecting into my current WIFI location)

Post a Comment