kirillzyusko / react-native-wifi-p2p

Library that provide access for working with wi-fi direct (p2p) module in android.
164 stars 32 forks source link

How do peers communicate with each other? #3

Closed bharadwajpro closed 5 years ago

bharadwajpro commented 5 years ago

Connecting, Disconnecting, forming a group everything is fine. But how do peers exchange information? sendMessage() api is not available as of now according to README

How do I broadcast available services of a device to its peers? Can I atleast get an IP address so that I can communicate manually with other devices?

kirillzyusko commented 5 years ago

Yes, you're right. I didn't implement sendMessage() method, since examples with sending strings (not files) in official documents merely doesn't exist. But in fact implementation of this method should be not so difficult. Since sendFile works (not perfectly, needed to fix issue with async promise resolving), creating similar method will be easy. Instead of Uri we need to use string and make InputStream from usual String, not Uri. It's all difference of native Java code.Now I have a vacation, and I'm not able to fix it. But after few days I will return and can implement it. Just remind me :) Is it ok?

kirillzyusko commented 5 years ago

@bharadwajpro Could you test last changes from master branch? Just add the following line to your package.json and run npm install:

"react-native-wifi-p2p": "github:kirikzyusko1996/react-native-wifi-p2p#master"

bharadwajpro commented 5 years ago

I was neither able to form a group nor connect to a device. It says Error code 2: Operation failed because the framework is busy and unable to service the request.. So I wasn't able to test your changes. May be there is a problem with devices I am using.

kirillzyusko commented 5 years ago

@bharadwajpro Yes, it's strange. But, just to make sure: do you have enabled wi-fi, when you tried to perform creating group and so on? Also, what is your device? And what version of android/API do you use?

kirillzyusko commented 5 years ago

@bharadwajpro I'll close this issue, since I tested message sending/receiving and it works fine on my devices. If you will provide more information of your problem (devices, your steps for reproducing this problem, were connected these devices to each other via Wi-Fi direct earlier and so on, I'll try to help you. Because BUSY_ERROR - it's not error of my library, it's "native" error (more info you can find here). I just made a bridge between "native" code and js side.