Full Bonjour support for iOS - Zero Configuration connections for your users!
Are you making a game with local multiplayer? An app which requires connecting to or hosting a local area network service? Very simple to implement, this plugin will ensure you never have to ask your users to type in an IP address or a port number.
-Very easy to use, integrate to your project with a few lines of code
-Fully accessible and commented code(no dll)
-ExampleBrowser prefab included to get you going
-Works with iOS Basic license
-Supports C# and JS
Unity does a great job making networking accessible. But how will your users connect to one another?
Bonjour is Apple’s implementation of Zero Configuration Networking (Zeroconf), and allows browsing, connecting to and advertising a LAN service.
That means ftp servers, iTunes sharing, printers or custom services can be browsed and connected to without any kind of IP or port input from the end user.
Workflow
The setup process takes place mostly in the inspector, setting the attributes of the BonjourManager prefab. Below is an example of the minimum setup required:
-Set Service Type to “_MyApp._tcp” in both BonjourBrowser and BonjourPublisher components
-Set ServiceName to “MyApp Server” in BonjourPublisher component
-Set Object To Notify to the object you want to be notified
Your notified object now receives Bonjour messages. The following function will connect to the first found service of Service Type :
To those of you who already bought the plugin - I hope you’re satisfied!
Feel free to suggest features. In its current state, the plugin does what I need it to do, but I will certainly consider your suggestions and update accordingly.
If you have time, a brief review would be very much appreciated : just letting other potential users know that the product works as advertised would be nice!
I have not received any questions so far, so I guess the docs are clear enough. If you think otherwise, do let me know…
Bonjour is only a service discovery / advertising protocol. It will not improve or worsen latency. It only simplifies connecting devices, removing the need to input IP and port.
You should buy the plugin if you already have local multiplayer features in your game and are looking for a solution to allow users to connect to one another easily.
It is a must in local multiplayer iOS apps, as you cannot expect users to input addresses such as 156.145.1.58 : 8081 every time they want to play together.
Bonjour is a final level of polish, not a multiplayer solution!
If you do have a local mp game, then go for it. I’ll support the plugin thoroughly, and take suggestions into account in future updates.
You say this plugin works with iOS Basic, but from what I’ve been reading I thought iOS Basic did not support local network play because it does not support Mono .NET sockets. So I’m a little confused.
So is what this does find another instance of the game hosted on your local wireless network, and then let you connect to it as it were any other IP internet game?
I’m using Master Server (I’d use Game Center, if any documentation of its matchmaking capabilites were available) and connecting players invisibly and painlessly is a high priority. I was going to just have it preferentially connect to hosted games from the same IP and then pick one from the rest of the Internet if none match, but Bonjour is probably a better solution and worth the $5 if it just does what I think it does.
Unfortunately, plugins for standalone require unity pro and I only own the iOS basic license.
Which means that no, the plugin will not work when not running on the device.
You can still browse and connect to services advertised by desktop machines, but cannot use this plugin to advertise a service from anything else than an iOS device.
Setup: 2 iPads. Prefabs in scene. All checkboxes checked. Both iPads show “Browsing”. When calling “BonjourManager.PublishService();”, error appears: Error: “Cannot publish a service before the server has been initialized!”. The instructions say to initialize server from one device. How is that done?
Note: I also bought the “uPhase+” App, installed on both iPads. That one works. And it has a “Start Server” button. So, there must be a function call when pressing that button. What is it?
Where connections is the max number of connections to the server, listenPort a port of you’re choosing (25000, 8080, whatever) and useNat a bool for nat punch through, not needed for wifi local connections so false.
Example :
Network.InitializeServer(16, 25001, false);
If you have little experience in networking, you should do Unity’s tutorial (demo project), it’s quite good. In uPhase, everything is done with RPC’s, so the network code is actually quite simple.
thanks for the quick response. After dropping in the line “Network.InitializeServer(16, 25001, false);”, I get 2 connect buttons popping up on both iPads. I really need to check a tutorial project to get this up and running with clean connect/disconnect and transfer of numbers and texts between iPads. Currently I have no clue what I am doing. Do you recommend a specific Unity tutorial project? What’s the name?
I suggest for your consideration, that you create a demo project, and include it in your Asset Store download. This demo project should include JS examples that work immediately, without the need for someone not familiar with networking to learn it all from scratch. You could increase the price if you include this. The basic idea from my point of view is this. I have a game, I coded it in JS, and all works smoothly. Now I want to make this a multiplayer two iOS devices game. I already tried the Prime31 GameKit, which unfortunately is very unreliable. Prime31 says, this is Apple’s fault, since he only calls Apple’s functions. So, I tried your Bonjour Plugin to see if that works better. Judging from your uPhase+ App, it seems to at least connect smoothly (where Prime31’s plugin has huge reliability issues in my tests), even though I could not figure out what else to do with the uPhase+ App. It shows a keyboard on one iPad, and a flat oscilloscope line on the other. Could not figure out what else to do with it, but at least it shows that it connects 2 iPads quickly. So, back to my project. Using your Bonjour Plugin I was hoping that all I need to do is call a function to get it started, and call other functions to transfer data between two iOS devices. I could of cause buy paid help on eLance, but before I do that, I rather ask the developer himself. Since you created uPhase+, wouldn’t it be easy for you to provide some fully out of the box working example with the plugin? This would be very helpful for me, and I assume for many other’s.
I strongly suggest you go through at least Unity’s networking tutorial, which you can find here : Unity Network Tutorial
My plugin is not a multiplayer solution, hence the low price. As I wrote in other posts in this thread, it’s only function is to provide painless connection : no IP or port input from the players, automatic service discovery and connection.
Once you are connected, RPC’s are the simplest way of communicating between connected devices. You should still read about Network Views etc… in the tutorial. It’s not difficult, good exmples are given!
Do ask : if I can provide help with specific questions, I gladly will! But some network code, you will need to write…
I hope you’re not too disappointed.
P.S.: uPhase has lots of tutorials available. Click on Online Help, in the main menu. It is a musician’s app, though…
thanks for the link to the tutorial. That got my @RPC functionality started.
Still a question: How do I cleanly start a connection between 2 iOS devices? If the game has a button “Start Server”, just like your uPhase+ App, and I press it on one iPad, a button pops up on the other, that shows the request to connect. I press that one, and the connection works. However, if I press both “Start Server” buttons, both iPads show 2 requests to connect. I tried it with your uPhase+, and pressing both buttons simultaneously simply seems to connect both iPads. How did you solve this?
As I’m sure you’re aware, you only need one server. Once you start a server, Bonjour allows it to be discovered by another device looking for services. It makes no sense to start 2 servers simultaneously : they won’t be connected. If you do that with uPhase, you’ll simply start two, NOT connected, servers. The proper way is to start a server on one device, and then connect to it through another.
is the only way to achieve this, to ask the user with a popup window “Please press connect only on one iPad and wait for the other iPad to show the available connection”, or something like that? There seems to be no automatic way to prevent users from starting 2 servers simultaneously.