Skip to content

Instantly share code, notes, and snippets.

@skyserpent
Created September 7, 2014 15:49
Show Gist options
  • Save skyserpent/832f980ca9ed9ed30e4b to your computer and use it in GitHub Desktop.
Save skyserpent/832f980ca9ed9ed30e4b to your computer and use it in GitHub Desktop.
'use strict';
angular.module('core').
factory('mySocket', function (socketFactory) {
var myIoSocket = io.connect('http://localhost');
mySocket = socketFactory({
ioSocket: myIoSocket
});
return mySocket;
// return socketFactory();
}).
controller('HomeController', ['$scope', 'Authentication', 'mySocket',
function($scope, Authentication, mySocket) {
// This provides Authentication context.
$scope.authentication = Authentication;
mySocket.emit('message', 'Hello World !');
mySocket.on('news', function(data) {
console.log(data);
mySocket.emit('my other event', { my: 'data' });
});
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment