netbeast/react-native-ssdp

getting NetworkInfo.getIPAddress is not a function

SirNeuman opened this issue · 5 comments

So I tried adding this package to a brand new React-Native Project and I got the error NetworkInfo.getIPAddress is not a function in SsdpClient.SSDP index.js:91.

"react": "16.0.0-alpha.6",
"react-native": "0.44.0",
"react-native-network-info": "2.2.0"
"react-native-udp":"2.0.0"

I fixed this by changing the import statement in line 14 in index.js from:
var NetworkInfo = require('react-native-network-info')
to ES6 style:
import { NetworkInfo } from 'react-native-network-info'
even though it's not consistent with the other import statements in this project it seems to at least get around that error when instantiating a new Client object.

Also just a note where you mention adding buffer to Sockets.js in react-native-udp, I believe you also have to npm install buffer (at least according to the react-native-udp docs). That was getting me stuck for a bit with setting this up for anyone else who happens to run across this. Also one note is you mention npm install react-native-udp but not npm install react-native-network-info in the documentation, which also gave me hiccup when trying to set up my project.

You are absolutely right, that is because we recently moved all those packages as peerDependencies rather dependencies https://github.com/netbeast/react-native-ssdp/blob/master/package.json#L16

Why is that?

In node.js network-info is a native library and so dgram (our react-native-udp) is. You don't need to keep control of those deps because they come with the system. In react-native you do have to, and you'll probably share those dependencies with other parts of your apps (as in 99% of times is our case). So for all your deps to share the same core-deps (sort of saying) we had to make this move.

The README.md, lacks this info, as is brand new. If you want and can we would really appreciate a PR improving the docs.

Thanks for opening the issue!

Ok sounds good. I'll look into updating the docs once I have time and have played around with the library a bit more.

This is also sort of unrelated but is it possible to use this library to use SSDP M-SEARCH over Android's Wi-Fi Direct? I was trying to figure out if there's something I could set in the options when instantiating the SSDP object. Perhaps I need to create my own socket and pass that in? I'm unsure as I'm sort of new to these concepts (SSDP and Wi-Fi Direct... and Java). When connected to a device over wi-fi direct using SSDP returns nothing by default, but I am able to find that device when connected to it's access point (yes, the device has it's own wi-fi access point).

Nevermind. I found out a way to do it but it's sort of a hack and requires me to change the source code for React-Native-UDP. It doesn't look like there's any other way though...

SSDP works on a multicast ip message that runs on a multicast ethernet address at the same time. i ignore at this point if such thing exists on Android WiFi direct

I believe we can close this issue as we changed the NetworkInfo library