netbeast / react-native-ssdp

SSDP client + server to use in your react-native apps
https://netbeast.co
41 stars 19 forks source link

require('react-native-ssdp').Server returns undefined #18

Closed acb closed 6 years ago

acb commented 6 years ago

I've got this module all installed but for some reason there's no .Server property when you require the module. In your example code you have

var Server = require('react-native-ssdp').Server
      , server = new Server()
    ;

But that's throwing undefined is not a constructor because there's no .Server property on what comes out of require.

The module's definitely installed as the require is fine, and .Client works fine, returning the SsdpClient constructor. I logged out all the props on what's returned from require('react-native-ssdp') and the only two properties are Client and Base. Where's the Server, and how do I access it?

react-native 0.51.0

acb commented 6 years ago

Ah so poking around in the source I see why there's no Server; in your index.js you have

module.exports = {
  Client: require('./lib/client'),
  Base: require('./lib/index')
}

So is Base what Server actually is? It looks like it might be, in which case the docs on here just need to be updated.

acb commented 6 years ago

Well maybe Base isn't quite a Server...it doesn't have a start() function though it does have _start(), not sure if that does the same thing, or even what objects I'm dealing with at this point.

jsdario commented 6 years ago

Hi @acb, thanks for your questions. This is a fork from node-ssdp, so the API and the examples pretend to be the same. However, the SSDP server has not yet been implemented because our main use-cases are as a client.

I can't invest right now time into building the Server API, I however invite you to submit a PR!

acb commented 6 years ago

Ah, that makes sense. The docs confused me. I'll take a look and see if it makes sense to extend this or use something else. Thanks!