react-native-ssdp icon indicating copy to clipboard operation
react-native-ssdp copied to clipboard

A better example on how to use this

Open Nathan-ma opened this issue 5 years ago • 5 comments

Hello, fairly new on the react-native scenario.

I need a few informations on how to use this lib properly, excuse me for my lack of experience on this framework.

Ok, I made a componente to use this lib, I need my device to get SSDP information from another device. So I believe I suppose to use this as a client.

I also understand the better usage would be on componentDidMount() so it can find the device I want when it loads.

My supper newbie questions are:

What do I have to import in order to make this work? On the client example you can find on this github, what I can declare globaly like a variable and what I should put inside of componentDidMount to trigger the search?


the way I understood, the functions below are all based on client.search to search for all devices once every 5 seconds for 10 seconds

client.search('urn:schemas-upnp-org:service:ContentDirectory:1')

// Or maybe if you want to scour for everything after 5 seconds
setTimeout(function() {
  client.search('ssdp:all')
}, 5000)

// And after 10 seconds, you want to stop
setTimeout(function () {
  client.stop()
}, 10000)

and those are declarations I should make globally outside of classes and functions.

var ssdp = require('../index').Client
  , client = new ssdp({
//    unicastHost: '192.168.11.63'
  })

client.on('notify', function () {
  //console.log('Got a notification.')
})

client.on('response', function inResponse(headers, code, rinfo) {
  console.log('Got a response to an m-search:\n%d\n%s\n%s', code, JSON.stringify(headers, null, '  '), JSON.stringify(rinfo, null, '  '))
})

Nathan-ma avatar Jul 19 '19 17:07 Nathan-ma

I'm also facing this little issue:

Could not find method compile() for arguments [project ':react-native-udp']

on the build.gradle

Nathan-ma avatar Jul 19 '19 20:07 Nathan-ma

Hi, I am also new at this, were you able to find all the devices in the end ?

jasenkabalac avatar Feb 07 '20 10:02 jasenkabalac

Same, were you able to find any solutions? The docs seem to be a little confusing

SethuSenthil avatar Jun 05 '20 23:06 SethuSenthil

@jsdario, @luisfpinto, @franrios, @pablopi

Can you guys please help us?

DeepakM02 avatar Sep 29 '21 14:09 DeepakM02

Hello, can help me, im need call an action from service. Please, can show me some example to make it.

tanks

sebasariz avatar Feb 08 '23 23:02 sebasariz