* VRFS-821; sending loggedin/loggedout events to backend from frontend

This commit is contained in:
Seth Call 2013-12-18 17:18:23 +00:00
parent 8bd715c7ea
commit de4a2c8321
3 changed files with 20 additions and 0 deletions

View File

@ -124,6 +124,7 @@ message LoginAck {
optional int32 heartbeat_interval = 4; // set your heartbeat interval to this value
optional string music_session_id = 5; // the music session that the user was in very recently (likely due to dropped connection)
optional bool reconnected = 6; // if reconnect_music_session_id is specified, and the server could log the user into that session, then true is returned.
optional string user_id = 7; // the database user id
}
// route_to: server

View File

@ -534,6 +534,14 @@
fakeJamClientRecordings = fakeRecordingsImpl;
}
function OnLoggedIn(userId, sessionToken) {
}
function OnLoggedOut() {
}
// Javascript Bridge seems to camel-case
// Set the instance functions:
@ -651,6 +659,10 @@
this.OpenSystemBrowser = OpenSystemBrowser;
// Websocket/Auth sessions
this.OnLoggedIn = OnLoggedIn;
this.OnLoggedOut = OnLoggedOut;
// fake calls; not a part of the actual jam client
this.RegisterP2PMessageCallbacks = RegisterP2PMessageCallbacks;
this.SetFakeRecordingImpl = SetFakeRecordingImpl;

View File

@ -91,6 +91,10 @@
function loggedIn(header, payload) {
app.clientId = payload.client_id;
// tell the backend that we have logged in
context.jamClient.OnLoggedIn(payload.user_id, payload.token);
$.cookie('client_id', payload.client_id);
heartbeatMS = payload.heartbeat_interval * 1000;
@ -132,6 +136,9 @@
*/
function socketClosed(in_error) {
// tell the backend that we have logged out
context.jamClient.OnLoggedOut();
// stop future heartbeats
if(heartbeatInterval != null) {
clearInterval(heartbeatInterval);