Couchbase lite - set up REST listener on Unity

.net

#1

I’m really close to rocking-n-rolling with my Couchbase Lite + Unity app. I want to go the REST API route (rather than Native API) and what I cannot find documentation on is how to include the new Listener in my Unity project, and turn it on so that I can start sending REST requests to it.

a) Couchbase.Lite.Listener.1.1.0\lib has 3 options {MonoAndroid} {net45} and {xamarinios10}… which of these do I use?
b) Do I need to use Bonjour?

Thanks in advance.

Kind regards,
David


#2

Regarding a:
We don’t package Unity in the nuget yet, since it’s not yet GA. You can download the latest beta zip at https://github.com/couchbase/couchbase-lite-net/releases/tag/unity_v1.0-beta2. I notice it doesn’t yet include the listener or Bonjour, so I’ll let @borrrden know so we can get that added to the release ASAP. If you don’t want to wait, you can build from source.

Regarding b:
Bonjour is used for p2p discovery, but there are lots of ways to do peer discovery. Bonjour (aka dns-sd) is perhaps the most popular. You can always use the listener without using Bonjour. In fact, that’s why we packaged it like that. Adding just the Bonjour package, you’ll get the Listener and Lite packages automatically as dependencies. If you add just Listener, then you just get just Lite as a dependency.


#3

Great. I’ll look for the new Unity zip with the Listener included, then.


#4

Just to make sure I understand this, Bonjour P2P would be used in a situation where I wanted “My App” to detect other copies of “My App” on other devices on the same LAN, right?

But I just want my Unity app on, say, my Android device to be able to send REST requests to the couchbase lite database that’s on the same device. That, and it needs to sync with the cb gateway on my Google Cloud Platform server. I don’t need Bonjour for either of those, correct? Which means I would be working with the “Listener” CBLite package, not the other ones.

Thanks for all your help.

Kind regards,
David


#5

That’s right, Bonjour is only for dynamically discovering other services on the LAN. However, in the case you describe you need to take care that your app is not shut down when it is backgrounded. I’m not terribly familiar with Android development, but I think this means creating a “service” instead of a regular app. That stuff should be more or less ready (Unity has a way of destroying everything I create mercilessly) but as for Bonjour things have broken again with the Unity version I am on so I am dealing with that.


My Unity game - Couchbase Lite roadmap & gotchas
#6

Thanks Jim. That makes sense.