triniwiz / nativescript-socketio

Socket.IO for nativescript
Apache License 2.0
71 stars 31 forks source link

IOS receiving json with parentheses !!! #61

Closed kefahB closed 6 years ago

kefahB commented 6 years ago

Did you verify this is a real problem by searching the NativeScript Forum and the other open issues in this repo?

YES

Tell us about the problem

Please, ensure your title is less than 63 characters long and starts with a capital letter.

I use socio.io Server and when i emit event from server i recive :

(
{
"auth_id" = 687019;
}
)

no problem with android i receive :

{
"auth_id" = 687019;
}

Which platform(s) does your issue occur on?

iOS

Please provide the following version numbers that your issue occurs with:

//server.js
const http = require("http");
const server = http.createServer();
const io = require("socket.io")(server);

io.on("connect", (socket) => {
socket.emit("auth_id", {auth_id: 123});
});

//IOS
socketIO.on("auth_id", (data) => {
        console.log("AUTHORISATION ID :");
        console.log(data);
        //output
(
{
"auth_id" = 123;
}
)

Thnk you :)

kefahB commented 6 years ago

@jogboms Have you idea about this ? @triniwiz is not active

kefahB commented 6 years ago

I add deserialize(), is not a solution but I need to continu to work until we have a real soulution

// nodes-modules/nativescript-socketio/socketio.ios.d.js
SocketIO.prototype.on = function (event, callback) {
        this.socket.onCallback(event, function (data, ack) {
            data = deserialize(data); // HERE I RECEIVE [{msg: "HELLOE}] and I can use it
            if (ack) {
                callback(data[0], ack);
            }
            else {
                callback(data[0]);
            }
        });
    };
jogboms commented 6 years ago

Sorry @kefahB, i'm a bit swamped with office work lately.