Ayame__
Ayame__

Reputation: 1000

Android phonegap and SockJS

Is there any way to get Android working with SockJs for socket connections in an app packaged in Phonegap? At the moment I have the following code that works on iOS but fails in Android because of the file:/// restriction for socket connections in android.

var sock = MyEnt.connect('servicename', 'http://socket.api.somewhere.be/api', {debug: true});
var entity_plays = sock.subscribe('plays');
entity_plays.on("play", function(data, msg) {
       //Do something with data
       console.log(data,msg)
}, {backlog: 10});

I have changed the service names for client privacy but as the above code works in the iOS PG version (and desktop browsers for that matter), that shouldn't matter. The MyEnt object is a small wrapper containing custom functions in the SockJS class, but again works perfectly on iOS

Any ideas?

Upvotes: 1

Views: 1540

Answers (1)

Marek
Marek

Reputation: 3509

SockJS should work correctly from phonegap. Either via native web sockets or xhr-streaming. Look for file:// in documentation.

Upvotes: 1

Related Questions