I am trying to use socket.io in my phonegap build. I can connect and emit/send events/messages to the socket but the problem I am having is that the .on() events not firering. I have tried to add
But that did not help. What am I doing wrong?
Please help! Your help is appreciated!
<access origin="*" />
<access origin="my.ip.address.here:3000" />
<access origin="http://my.ip.address.here*" />
But that did not help. What am I doing wrong?
Please help! Your help is appreciated!
- 10 Posts
- 0 Reply Likes
Posted 4 years ago
JesseMonroy650 (Volunteer), Champion
- 3325 Posts
- 122 Reply Likes
@TextNinja,
have you tried your code with a webbrowser?
FWIW, you are not giving us enough information. Where is your Javascript in the index.html or in a separate file?
Jesse
have you tried your code with a webbrowser?
FWIW, you are not giving us enough information. Where is your Javascript in the index.html or in a separate file?
Jesse
- 10 Posts
- 0 Reply Likes
I just tried from a browser it doesn't work either. I am emiting from php with elephant.io and my nodejs server gets the messages but not a web browser nor phonegap app but they both can connect and emit. The javascript is inside the index.js inside the deviceready callback.
var socket = io('http://108.179.205.128:3000');
socket.on('connect', function () { alert('connected');
socket.on('myRequest', function (data) {
alert('Request Received: '+data);
});
socket.emit('welcome',{msg:"Just Connected!"});
});
- 10 Posts
- 0 Reply Likes
I found what the issue was. Simply Socket.io is two way communication. It's not a server you emit messages to and everyone connected to it gets them.
JesseMonroy650 (Volunteer), Champion
- 3325 Posts
- 122 Reply Likes
@TextNinja
glad to see you moving forward.
Once, this conversation is complete, please move new conversations to
the new forum at: https://forums.adobe.com/community/phonegap/build
Thanks
Jesse
glad to see you moving forward.
Once, this conversation is complete, please move new conversations to
the new forum at: https://forums.adobe.com/community/phonegap/build
Thanks
Jesse
Related Categories
-
PhoneGap Build
- 15111 Conversations
- 275 Followers

