OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Why am I getting a "JSON error" when doing a socket.write(data, Success, Error);

  • Thread starter Thread starter John Wythe
  • Start date Start date
J

John Wythe

Guest
Using sockets for Cordova. Socket opens successfully, and in the Success call back from open, I call the write.

socket.write (data, writesucess, writeerror);

The writeerror call back is triggered and the message passed is simply "JSON Error".

running AndroidStudio on Windows using the cz.blocshop.socketsforcordova 1.1.0 "SocketsForCordova" plugin.

Here is a code snippet.

Code:
    if (socket.state == Socket.State.OPENED)
        {

        var dataString = "???? ???? 21398127389127398712983712897318\n";
        var data = new Uint8Array(dataString.length);
        for (var i = 0; i < data.length; i++)
            {
            data[i] = dataString.charCodeAt(i);
            }
        document.getElementById('msg2').innerHTML = data;
        socket.write(dataString, onWriteSuccess, onWriteError);

        document.getElementById('msg3').innerHTML = 'msg3: 4';
        }

<p>Using sockets for Cordova. Socket opens successfully, and in the Success call back from open, I call the write.</p>
<p>socket.write (data, writesucess, writeerror);</p>
<p>The writeerror call back is triggered and the message passed is simply "JSON Error".</p>
<p>running AndroidStudio on Windows using the cz.blocshop.socketsforcordova 1.1.0 "SocketsForCordova" plugin.</p>
<p>Here is a code snippet.</p>
<pre><code> if (socket.state == Socket.State.OPENED)
{

var dataString = "???? ???? 21398127389127398712983712897318\n";
var data = new Uint8Array(dataString.length);
for (var i = 0; i < data.length; i++)
{
data = dataString.charCodeAt(i);
}
document.getElementById('msg2').innerHTML = data;
socket.write(dataString, onWriteSuccess, onWriteError);

document.getElementById('msg3').innerHTML = 'msg3: 4';
}
</code></pre>
 
Top