How can I use Socket.io 1.4.5 with {N}


#1

I have installed the library via "npm install socket.io-client"
When I import the library I got some errors about “Failed to find module ‘socket.io-client’”

I tried following both method.

import * as socket from 'socket.io-client'; //can not find module, vscode crying about it

var socket = require('socket.io-client'); //  exception "failed to find module"

I was using this plugin https://www.npmjs.com/package/nativescript-socketio but i need removeListener method and i was not able to achieve via this plugin.
Thanks.


#2

Short answer - you can’t use the npm package, it has desktop implementation, while nativescript-socketio uses the platform-specific implementations and unifies them under a common API, so I’d suggest you make a PR to nativescript-socketio to augment it with whatever additional functionalities you need exported.

Sharing is caring!


#3

Are you sure? What about this ? https://www.nativescript.org/blog/using-npm-modules-and-nativescript-plugins and this http://socket.io/blog/socket-io-1-4-5/


#4

The npm socket.io-client package is sufficient to establish connection between node backends, or a backend and a browser, but it does not have the necessary understanding to issue instructions to the android device to send/listen for messages.

It is also why socket.io-client has a native Android plugin, and a iOS Pod - simple ports of the JavaScript library.

http://socket.io/blog/native-socket-io-and-android/


#5

@samed i will add the removeListener soon feel free to create an issue