diff --git a/public/app/SocialCtrl.js b/public/app/SocialCtrl.js index ba61d6b..4918a4a 100644 --- a/public/app/SocialCtrl.js +++ b/public/app/SocialCtrl.js @@ -3,11 +3,13 @@ angular .module('FileSync') .controller('SocialCtrl', ['$scope', 'SocketIOService', function($scope, SocketIOService) { this.viewers = []; + this.message = ""; + this.messages = []; function onViewersUpdated(viewers) { this.viewers = viewers; $scope.$apply(); } - + SocketIOService.onViewersUpdated(onViewersUpdated.bind(this)); }]); diff --git a/public/app/SocketIOService.js b/public/app/SocketIOService.js index a57e256..e7d7a59 100644 --- a/public/app/SocketIOService.js +++ b/public/app/SocketIOService.js @@ -31,6 +31,19 @@ angular.module('FileSync') }); return { + sendMessage: function(message){ + socket.emit('chat:message:new', message); + }, + + onNewChatMessage: function(f){ + socket.on('chat:message:new', function(username, message, createdAt){ + console.log(username, message, createdAt); + $timeout(function() { + f(username, message, createdAt); + }); + }); + }, + onViewersUpdated: function(f) { socket.on('viewers:updated', f); }, diff --git a/public/index.html b/public/index.html index 56523ae..fbcac6d 100644 --- a/public/index.html +++ b/public/index.html @@ -1,3 +1,5 @@ + +
@@ -6,15 +8,55 @@ + -