Socket.io with ionic


#1

Hi guys,

I have just started with ionic framework, and I was wondering if anyone here has installed socket.io on this framework. I am having trouble installing it, as I am not exactly sure whether I should npm install which will store it in the node_modules folder. Or should I use bower , which I am not sure how to do with socket.io and calling this library in /www/ folder. If anyone has installed socket.io on this framework and got it working to a backend server, any tip would be really appreciated? Thanks


#2

Check this angular module:

If you want to change default bower directory (bower_components), you have to create .bowerrc file with:

{
“directory”: “www”
}


#3

To elaborate on evenemento’s comment, socket.io is really a client and a server project. The angular-socket-io project is just the client portion which is baked as an angular module.

Assuming you have a socket.io server running, you can load the standard socket.io-client from here https://github.com/Automattic/socket.io-client. Socket.io just released v1 this past week, just in case you need to verify versions. Once you’ve loaded socket.io and included it in your index.html file, you can use socket.io in Ionic like you would anywhere else (or use the angular module above for a more “angular way”).


#4

@gnomeontherun should we have to include socket.io from https://github.com/Automattic/socket.io-clientm manually or should we serve it from server as we do it in SPA’s . i think we should have to include it manually i just need you to confirm i m doing it right .


#5

Loading external js assets at runtime is likely to prevent you from getting accepted into the AppStore, so yes you probably have to add it into the www codebase. It would be important to ensure the versions are the same between the server and client.