i am trying to use socket.io on cordova with android device,following tutorial. http://socket.io/socket-io-with-apache-cordova/
According tutorial,socket.io is downloaded from external server(cdn).
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"></script>
<script type="text/javascript" src="js/index.js"></script>
As far as I know,Cordova can only read libraries when they put under www folder, so I downloaded socket.io.4.8.1.js from https://cdn.socket.io/4.8.1 and put it in www/lib.
<script src="lib/socket.io.js"></script>
<script src="cordova.js"></script>
<script src="js/index.js"></script>
I also add path io.connect('http://192.168.1.12:3000') to node socket server ;
function onDeviceReady() {
var socket=io.connect('http://192.168.1.12:3000');
socket.on('connect', function() {
socket.on('text', function(text) {
alert(text);
});
});
}
But this didn't work. What's wrong? (by the way, socket server is running on Node properly, I checked by browser) (I have already tried many suggestions on socket.io category,but failed.)
Source: View source