Giter VIP home page Giter VIP logo

angular-socket-io-im's Introduction

angular-socket-io-im's People

Contributors

btford avatar udyw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-socket-io-im's Issues

Integrating with realtime-rails

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;
</script> <script src="http://192.168.1.2:5001/socket.io/socket.io.js"></script> <script type='text/javascript'> if (typeof io != 'undefined' && io != null) { window.realtime.token = 'e9a34830136837934f11fecddc04066f'; window.realtime.userId = '42'; window.realtime.socketIo = io.connect('http://192.168.1.2:5001/?_rtUserId=42&_rtToken=e9a34830136837934f11fecddc04066f'); } if (window.realtime.socketIo) { window.realtime.enabled = true; window.realtime.socketIo.on('connect', function() { // Give a nice round-trip ACK to our realtime server that we connected. window.realtime.socketIo.emit('realtime_user_id_connected', { userId: window.realtime.userId }); }); // Queue up all incoming realtime messages. window.realtime.socketIo.on('realtime_msg', function(message) { window.realtime.messageQueue.push(message); }); } </script>

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

You need extra dependencies in the package.json

{
"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"
}
}

Error while starting the server

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'

Can't minify socket.io -service in angular

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.