How to use Bonjour in Java
The slides show you how to create bonjour based services on server site and use them on client site. All examples are completely written in Java.
4. HomeAutomationModule
Hi,
please choose your Home Automation Server:
ok
HA Server living room (12.0.0.34:9001)
My Server pool house (12.0.0.31:9001)
This is how it goes
Cool,
isn‘t it?
5. ZeroConf
• methodology and set of special technologies
• automatically create a usable computer network
• assign numeric network addresses to devices
• distribution and resolution of hostnames
• location of network services
6. Bonjour
• Based on ZeroConf
• provides a general method to discover services
on a local area network
• Used in many tools & applications
• Open Source
postgreSQL,
Adobe Creative
Suite, Skype
...
7. Airplay
• Default Services based on Bonjour
• Stream Music, Movies & Photos from iOS
to AppleTV
• No configuration needed
Find this icon on
your iDevice
User has
time for
other stuff
8. Defining a Service
• Each service has a type that is defined by a
namespace
• „_servicetype._tcp.local.“
• Each service has a name
• Each service has a host and a port
• Services can have descriptions and other properties
9. • iOS Devices can stream Photos to AppleTV
• Communication is based on Bonjour & REST
• Find AirPlay Server with Bonjour
• Send pictures with REST call
Stream Photos
REST call
10. Stream Music
• iOS Devices can stream Music to AppleTV
• Same Workflow as with pictures
• _airplay._tcp.local.
• Communication is completely based on REST
default service
type for
Airplay
... and
documented in
the web
11. JmDNS
• Java implementation of multi-cast DNS
• fully compatible with Apple's Bonjour
• provide simple ways for services to register
themselves
• discover multicast DNS based services
http://jmdns.sourceforge.net
12. Listen to a Service
JmDNS jmDNS = JmDNS.create();
jmDNS.addServiceListener("name._tcp.local.", new ServiceListener()
{
@Override
! ! ! public void serviceAdded(ServiceEvent event) {...}
! ! ! @Override
! ! ! public void serviceResolved(ServiceEvent event) {...}
! ! ! @Override
! ! ! public void serviceRemoved(ServiceEvent event) {...}
}
);
create Context
listener
concept
lifecylce
wraps all infos