* VRFS-3973 - event into backend on session join/leave events
This commit is contained in:
parent
f6652fa180
commit
8c805f0378
|
|
@ -11,6 +11,8 @@ message ClientMessage {
|
|||
enum Type {
|
||||
LOGIN = 100;
|
||||
LOGIN_ACK = 105;
|
||||
LOGOUT = 106;
|
||||
LOGOUT_ACK = 107;
|
||||
LOGIN_MUSIC_SESSION = 110;
|
||||
LOGIN_MUSIC_SESSION_ACK = 115;
|
||||
LEAVE_MUSIC_SESSION = 120;
|
||||
|
|
@ -126,6 +128,8 @@ message ClientMessage {
|
|||
// Client-Server messages (to/from)
|
||||
optional Login login = 100; // to server
|
||||
optional LoginAck login_ack = 105; // from server
|
||||
optional Logout logout = 106; // to server
|
||||
optional LogoutAck logout_ack = 107; // from server
|
||||
optional LoginMusicSession login_music_session = 110; // to server
|
||||
optional LoginMusicSessionAck login_music_session_ack = 115; // from server
|
||||
optional LeaveMusicSession leave_music_session = 120;
|
||||
|
|
@ -263,6 +267,21 @@ message LoginAck {
|
|||
optional ClientUpdate client_update = 9;
|
||||
}
|
||||
|
||||
|
||||
// route_to: server
|
||||
// a logout ack is always sent
|
||||
message Logout {
|
||||
|
||||
}
|
||||
|
||||
// route_to: client
|
||||
// sent from server to client to let the client know the login was successful,
|
||||
// and to also show the IP address of the client as seen by the server.
|
||||
message LogoutAck {
|
||||
optional bool success = 1;
|
||||
}
|
||||
|
||||
|
||||
// route_to: server
|
||||
// send from client to server to log in to a music session and be 'present'.
|
||||
// if successful, a LoginMusicSessionAck is sent with error = false, and Client-Session messages will be passed
|
||||
|
|
@ -382,6 +401,8 @@ message SessionDepart {
|
|||
optional string msg = 3;
|
||||
optional string recording_id = 4;
|
||||
optional int32 track_changes_counter = 5;
|
||||
optional string client_id = 6;
|
||||
optional string source_user_id = 7;
|
||||
}
|
||||
|
||||
message TracksChanged {
|
||||
|
|
|
|||
|
|
@ -423,18 +423,20 @@ module JamRuby
|
|||
)
|
||||
end
|
||||
|
||||
def session_depart(session_id, photo_url, msg, recording_id, track_changes_counter)
|
||||
def session_depart(session_id, photo_url, msg, recording_id, track_changes_counter, source_client_id, source_user_id, route_to = CLIENT_TARGET)
|
||||
left = Jampb::SessionDepart.new(
|
||||
:session_id => session_id,
|
||||
:photo_url => photo_url,
|
||||
:msg => msg,
|
||||
:recording_id => recording_id,
|
||||
:track_changes_counter => track_changes_counter
|
||||
:track_changes_counter => track_changes_counter,
|
||||
:client_id => source_client_id,
|
||||
:source_user_id => source_user_id
|
||||
)
|
||||
|
||||
Jampb::ClientMessage.new(
|
||||
:type => ClientMessage::Type::SESSION_DEPART,
|
||||
:route_to => CLIENT_TARGET,
|
||||
:route_to => route_to,
|
||||
:session_depart => left
|
||||
)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -578,6 +578,8 @@ module JamRuby
|
|||
user.update_progression_field(:first_music_session_at)
|
||||
MusicSessionUserHistory.save(active_music_session.id, user.id, client_id, tracks)
|
||||
|
||||
Notification.send_session_join(active_music_session, connection, user)
|
||||
|
||||
# only send this notification if it's a band session
|
||||
unless music_session.band.nil?
|
||||
Notification.send_band_session_join(music_session, music_session.band)
|
||||
|
|
|
|||
|
|
@ -562,10 +562,26 @@ module JamRuby
|
|||
user.photo_url,
|
||||
notification_msg,
|
||||
recordingId,
|
||||
active_music_session.track_changes_counter
|
||||
active_music_session.track_changes_counter,
|
||||
client_id,
|
||||
user.id,
|
||||
MessageFactory::CLIENT_TARGET
|
||||
)
|
||||
|
||||
userMsg = @@message_factory.session_depart(
|
||||
active_music_session.id,
|
||||
user.photo_url,
|
||||
notification_msg,
|
||||
recordingId,
|
||||
active_music_session.track_changes_counter,
|
||||
client_id,
|
||||
user.id,
|
||||
MessageFactory::USER_TARGET_PREFIX + user.id
|
||||
)
|
||||
|
||||
@@mq_router.server_publish_to_session(active_music_session, msg, sender = {:client_id => client_id})
|
||||
@@mq_router.publish_to_user(user.id, userMsg, sender = {:client_id => client_id})
|
||||
|
||||
end
|
||||
|
||||
def send_tracks_changed(active_music_session)
|
||||
|
|
|
|||
|
|
@ -165,6 +165,11 @@
|
|||
return client_container(msg.LOGIN, route_to.SERVER, login);
|
||||
};
|
||||
|
||||
factory.logout = function() {
|
||||
var logout = {}
|
||||
return client_container(msg.LOGOUT, route_to.SERVER, logout);
|
||||
}
|
||||
|
||||
// create a login message using only the client_id. only valid for latency_tester
|
||||
factory.login_with_client_id = function(client_id, client_type) {
|
||||
if(client_type != 'latency_tester') {
|
||||
|
|
|
|||
|
|
@ -808,6 +808,18 @@
|
|||
//console.timeEnd('sendP2PMessage');
|
||||
};
|
||||
|
||||
server.sendLogin = function (token) {
|
||||
logger.debug("sending login message on behalf of client")
|
||||
var outgoing_msg = msg_factory.login_with_token(token, null, null);
|
||||
server.send(outgoing_msg);
|
||||
};
|
||||
|
||||
server.sendLogout = function () {
|
||||
logger.debug("sending logout message on behalf of client")
|
||||
var outgoing_msg = msg_factory.logout();
|
||||
server.send(outgoing_msg);
|
||||
};
|
||||
|
||||
server.sendChatMessage = function(channel, message) {
|
||||
|
||||
if (server.connected) {
|
||||
|
|
@ -858,6 +870,11 @@
|
|||
// Callbacks from jamClient
|
||||
if (context.jamClient !== undefined && context.jamClient.IsNativeClient()) {
|
||||
context.jamClient.SendP2PMessage.connect(server.sendP2PMessage);
|
||||
|
||||
if (context.jamClient.SendLogin) {
|
||||
context.jamClient.SendLogin.connect(server.sendLogin);
|
||||
context.jamClient.SendLogin.connect(server.sendLogout);
|
||||
}
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
|
|
|
|||
|
|
@ -259,6 +259,10 @@
|
|||
// tell session store that this happened
|
||||
context.SessionActions.sessionJoinedByOther(payload)
|
||||
}
|
||||
|
||||
if (context.jamClient.ClientJoinedSession) {
|
||||
context.jamClient.ClientJoinedSession(payload["source_user_id"], payload["client_id"], payload["session_id"])
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -266,17 +270,22 @@
|
|||
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.SESSION_DEPART, function(header, payload) {
|
||||
logger.debug("Handling SESSION_DEPART msg " + JSON.stringify(payload));
|
||||
|
||||
var recordingId = payload.recording_id;
|
||||
if (app.clientId != payload.client_id) {
|
||||
var recordingId = payload.recording_id;
|
||||
|
||||
if(recordingId && context.RecordingStore.recordingModel.isRecording(recordingId)) {
|
||||
context.RecordingStore.recordingModel.onServerStopRecording(recordingId);
|
||||
}
|
||||
else {
|
||||
app.notify({
|
||||
"title": "Musician Left Session",
|
||||
"text": payload.msg,
|
||||
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
||||
});
|
||||
if (recordingId && context.RecordingStore.recordingModel.isRecording(recordingId)) {
|
||||
context.RecordingStore.recordingModel.onServerStopRecording(recordingId);
|
||||
}
|
||||
else {
|
||||
app.notify({
|
||||
"title": "Musician Left Session",
|
||||
"text": payload.msg,
|
||||
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
||||
});
|
||||
}
|
||||
}
|
||||
if (context.jamClient.ClientLeftSession) {
|
||||
context.jamClient.ClientLeftSession(payload["source_user_id"], payload["client_id"], payload["session_id"])
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue