I’m building a website which offers 1 on 1 coaching on various topics. The coaching is done over the web ( video call, document upload, stuff like this ), and one of the most important things is that the client pays by the minute. My problem is the following: how will I know when a coaching session ends ( so that I can correctly bill the customer )?
I’m planning to store the coaching session in the db roughly like this:
coach_id:integer
client_id:integer
created_at:datetime
updated_at:datetime
in_progress:boolean
At the session’s end I will do a difference between updated_at and created_at, and get the length of the session.
Here are the potential problems I see:
-
coach loses internet access => in this case, the client will press a button on the website which will notify us that the session had a problem, and the session’s
updated_atwill be updated, andin_progresswill be set tofalse -
client loses internet access => same workflow as if coach loses internet access
-
both lose internet access => this is the trickiest case. I am not sure how to notify the server that the session should be considered as finished. I am thinking of doing it via push, and have both the client’s browser, and the coach’s browser update the server every minute. Worst case scenario, the error would cause a difference of 1 minute to the bill, which is acceptable. The downside is that I think this could load the server a lot, and I don’t know if this would still be a viable solution once we will have many users.
What do you think of this approach? In case it matters, the application will be built on Rails 3.2.
Why dont you look into HTML5
EventSourceorWebSocketsas possible means of detecting connectivity/loss of connection?At least in .NET (and I would guess in all server environments) it is possible to see if the client is still connected (tcp wise). EventSource/WebSockets helps you to establish an always open connection (as opposed to request/response connection with a short period of being connected) that you can monitor if its still operational/open.
So essentialy the solution needs to be implemented at the websocket server.