btford / angular-socket-io-im Goto Github PK
View Code? Open in Web Editor NEWSimple Instant Messaging app using AngularJS + Socket.IO
Simple Instant Messaging app using AngularJS + Socket.IO
when I run 'node app.js' in console there is an error as below
console.log("Express server listening on port %d in %s mode", app.address().
^
TypeError: Object function app(req, res, next){ app.handle(req, res, next); } has no method 'address'
On the blog post Writing an AngularJS App with Socket.IO the "Open Demo" button leads to a nodejitsu 404 page.
Hi!
I have an issue with socket.io-service. When it is minificated, it does not work. i'm using SailsJS top of node.
And can you declare where the arguments -variable comes from?
{
"name": "angular-socket-io-im",
"version": "0.0.1",
"private": true,
"dependencies": {
"asap": "^2.0.4",
"css-stringify": "^2.0.0",
"express": "2.5.10",
"indexof": "0.0.1",
"jade": ">= 0.26.1",
"socket.io": ">= 0.9.6",
"after": ">= 0.8.1",
"asap": ">=2.0.4",
"backo2": ">=1.0.2",
"component-bind": ">= 1.0.0",
"component-emitter": ">=1.2.1",
"css-parse": ">=2.0.0",
"engine.io-client": ">=1.6.11",
"formidable": ">=1.0.17",
"mime-types":">=2.1.11",
"negotiator": ">=0.6.1",
"options": ">= 0.0.6",
"parseuri": ">=0.0.4",
"to-array": ">=0.1.4",
"ultron": ">=1.0.2",
"utf8": ">=2.1.1"
}
}
Hello Bran,
I am trying to integrate your solution here to the Rails integrated realtime-rails solution from Mike Atlas
http://mikeatlas.github.io/realtime-rails/
the challenge i am running into is that the socket interface is already being created outside of the angular code:
<script type='text/javascript'>
window.realtime = {};
window.realtime.messageQueue = [];
window.realtime.enabled = false;
I have tried to point. the socket in your service declaration to window.realtime.socketIo (my appis called headcount)
https://github.com/dreadstar/headcount_app5/blob/master/app/assets/javascripts/angular/services.js.coffee (although this is a coffescript file i am actually forcing javascript)
headcount.factory('socket', function ($rootScope) {
// var socket = io.connect();
// var socket = io.connect("http://localhost:5001");
var socket = window.realtime.socketIo;
return {
on: function (eventName, callback) {
socket.on(eventName, function () {
var args = arguments;
$rootScope.$apply(function () {
callback.apply(socket, args);
});
});
},
emit: function (eventName, data, callback) {
socket.emit(eventName, data, function () {
var args = arguments;
$rootScope.$apply(function () {
if (callback) {
callback.apply(socket, args);
}
});
})
}
};
});
My controller has the following additions to replicate your your example. it is written in coffescript:
https://github.com/dreadstar/headcount_app5/blob/master/app/assets/javascripts/angular/controllers/LocationIndexCtrl.js.coffee
@headcount.controller 'LocationIndexCtrl', ['$scope', '$location', '$http','socket', ($scope, $location, $http, socket) ->
$scope.locs[data.msg.obj.id].current_state= data.msg.obj.current_state
$scope.locs[data.msg.obj.id].fanscnt= data.msg.obj.fanscnt
console.log data
When i switch the EventName to 'realtime_msg' on the server, i can see that my messages are getting to the browser.
you can see the latest version of my code
https://github.com/dreadstar/headcount_app5
Any help would be appreciated.
Thanks,
Tyrone
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.