Skip to content
Browse files

app.js now leaves and joins rooms, when sessions starts and ends.

  • Loading branch information...
1 parent d72a583 commit 75d3e1a2dab40928a9092f737a632e2e9afa1933 @petterik petterik committed Feb 12, 2012
View
1 frontend/Spotify/artistcam/index.html
@@ -30,3 +30,4 @@
<script src="sp://artistcam/js/servicebase.js"></script>
<script src="sp://artistcam/js/sessionservice.js"></script>
<script src="sp://artistcam/js/trackservice.js"></script>
+<script src="sp://artistcam/js/users.js"></script>
View
9 frontend/Spotify/artistcam/js/app.js
@@ -69,6 +69,11 @@ function joinANewRoom(sessionID, token) {
function didJoinANewRoom(session) {
startChat(session.sessionId,'Haxor');
+ startTrackingTracks(session.sessionId, session.connection.connectionId);
+}
+
+function didLeaveRoom(session) {
+ endTrackingTracks(session.sessionId, session.connection.connectionId);
}
function TrackServiceHandler() {
@@ -85,4 +90,8 @@ function SessionEventListener() {
this.didStartSession = function (session) {
didJoinANewRoom(session);
}
+
+ this.didEndSession = function (session) {
+ didLeaveRoom(session);
+ }
}
View
5 frontend/Spotify/artistcam/js/tb.js
@@ -49,6 +49,10 @@ function disconnectCurrentSession() {
function sessionDisconnectedHandler (event) {
isDisconnecting = false;
removeEverythingInContentDivAfterDisconnect();
+ var _session = event.target;
+ console.log("ended session");
+ console.log(_session);
+ sessionEventListener.didEndSession(_session);
if (isWaitingToConnect) {
debug("was waiting to connect. Connecting after a disconnect with sessionID: " + currentSessionID);
connectWithSessionAndToken(currentSessionID, currentToken);
@@ -76,6 +80,7 @@ function sessionConnectedHandler(event) {
// Subscribe to streams that were in the session when we connected
subscribeToStreams(event.streams);
var _session = event.target;
+ console.log("Started session");
console.log(_session);
if (sessionEventListener === null)
console.log("Warning: sessionEventListener is null. Use setSessionEventListener and listen!");

0 comments on commit 75d3e1a

Please sign in to comment.
Something went wrong with that request. Please try again.