Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Android PhoneGap
Hi
i am doing socket programming But getting error in response .
i am using this like to do socket programming
http://anismiles.wordpress.com/2011/02/03/websocket-support-in-android%E2%80%99s-phonegap-apps/[^]
 
But when i debug my program i am getting all data in my .java file in that method.
private String buildLoadData(String _event, String _data) {
        String _d =  "javascript:WebSocket.on" + _event + "(" + 
                    "{"
                    + "\"_target\":\"" + webSocketId + "\"," + 
                    "\"_data\":'" + data + "'" + 
                    "}" + 
                ")";
        Logger.log(_d);
        return _d;
    }
 
Here is _d print ..
 
WebSocket.onmessage({"_target":"WEBSOCKET.54","data":'!!20W)0
(Note:  In open court at !#10W*.)0
THE COURT:  !$10W*I\'m !%10W+going !&10W+to !\'10W+re!(10W,serve !)10W,counsel !*10W,'})
---------------------------------
But from Html where i need data to show i call this java method.But i am getting only this result
 
   var socket = new WebSocket('ws://192.168.1.3:8101/');
 
// push a message after the connection is established.
socket.onopen = function() {
 
    socket.send('Hello World')
};
 
// alerts message pushed from server
socket.onmessage = function(msg) {
//alert("TTTTT"+JSON.stringify(msg));
$(".test_h").val(JSON.stringify(msg)).keyup();
    console.log("TTTTT"+JSON.stringify(msg));
};
 
// alert close event
socket.onclose = function() {
    alert('closed');
}; 
In console i am getting this,....
    06-27 11:04:36.156: I/Web Console(924): TTTTT{"_target":"WEBSOCKET.54","data":"!!2"} at file:///android_asset/www/index.html:52
then after i am getting like this
 
     06-27 10:53:25.136: D/CordovaLog(871): Uncaught SyntaxError: Unexpected token ILLEGAL
    Uncaught SyntaxError: Unexpected token ILLEGAL at null:1
    it is printed again and again this message
    Uncaught SyntaxError: Unexpected token ILLEGAL at null:1
    ?How to remove this error.?
Posted 26-Jun-13 21:56pm
Edited 4-Jul-13 17:10pm
(no name)41.5K
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 4 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100