triniwiz / nativescript-socketio

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

IOS: emit JSON object #42

Closed budilovskiy closed 6 years ago

budilovskiy commented 7 years ago

Hi. I've got an error when trying to run demo app on iOS. After emitting 'add user' with JSON object

socketIO.emit('add user', { username:  pageData.get('username') });

demo-server throws an error:

.../socketio/demo/demo-server/app.js:20
        socket.username = data.username;
                              ^

TypeError: Cannot read property 'username' of undefined
    at Socket.<anonymous> (.../socketio/demo/demo-server/app.js:20:25)
    at emitNone (events.js:86:13)
    at Socket.emit (events.js:185:7)
    at .../socketio/demo/demo-server/node_modules/socket.io/lib/socket.js:503:12
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)

at this lines of code:

socket.on('add user', function (data) {
        ...
        socket.username = data.username;
        ...
    })

Looks like JSON data is not transmitted through socket.

juanitozambada commented 7 years ago

Same problems with emit on IOS