Skip to content

Commit

Permalink
Api calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Casmo committed Mar 9, 2017
1 parent 9a11fd6 commit 2e058e1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 3 additions & 1 deletion build/couchfriends.api-latest.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/couchfriends.api-latest.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module.exports = function(grunt) {
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
sourceMap: true,
sourceMapIncludeSources: true,
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
Expand Down
13 changes: 11 additions & 2 deletions src/couchfriends.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,15 @@ COUCHFRIENDS.connect = function () {
* @param data Object object with data to send. See Api references for all available options.
*/
COUCHFRIENDS.send = function (data) {
COUCHFRIENDS._socket.send(data);
if (data.id == null) {
console.warn(data);
}
for (var i = 0; i < this.players.length; i++) {
if (data.id == this.players[i].id) {
this.players[i].conn.send(data);
break;
}
}
};

Emitter(COUCHFRIENDS);
Expand Down Expand Up @@ -363,7 +371,8 @@ COUCHFRIENDS.on('player.join', function (conn) {
data: {
color: this.player.color
}
})
});
COUCHFRIENDS.emit('player.identify', {color: this.player.color, player: {id: this.player.id}});
});
conn.on('close', function () {
COUCHFRIENDS.emit('player.left', {
Expand Down

0 comments on commit 2e058e1

Please sign in to comment.