Skip to content

Commit aa87841

Browse files
committed
handling JSON objects
1 parent 105e685 commit aa87841

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

www/socket.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Socket.prototype.disconnectAll = function (successCallback, errorCallback) {
3030
//
3131
Socket.prototype.send = function (successCallback, errorCallback, host, port, data) {
3232
'use strict';
33-
exec(successCallback, errorCallback, this.pluginRef, 'send', [host, port, data]);
33+
exec(successCallback, errorCallback, this.pluginRef, 'send', [host, port, typeof data == 'string' ? data : JSON.stringify(data)]);
3434
};
3535

3636
//
@@ -43,7 +43,7 @@ Socket.prototype.receive = function (host, port, chunk) {
4343
evReceive.metadata = {
4444
host: host,
4545
port: port,
46-
data: chunk
46+
data: typeof chunk == 'object' ? chunk : JSON.parse(chunk)
4747
};
4848

4949
document.dispatchEvent(evReceive);

0 commit comments

Comments
 (0)