Created
April 9, 2015 05:31
-
-
Save brlafreniere/fdcc66f3b23426e18704 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Meteor.isClient) { | |
function joinRoom (roomName) { | |
// Update joinedRooms on successful subscription. | |
var publishCallbacks = { | |
onReady: function () { | |
Meteor.call("updateRoomsJoined", roomName); | |
Session.set('currentRoom', roomName); | |
$('#joined-rooms').val(roomName); | |
}, | |
onError: function () { | |
} | |
} | |
// Check if room exists, create one if not, otherwise subscribe. | |
if (Rooms.find({name: roomName}).count() === 0) { | |
Meteor.call('createAndPublishRoom', roomName, function (error, result) { | |
if (!error) { | |
Meteor.subscribe(roomName, publishCallbacks); | |
} | |
}); | |
} else { | |
Meteor.subscribe(roomName, publishCallbacks); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment