Inherits from NSObject
Conforms to DTBonjourDataConnectionDelegate
Declared in DTBonjourServer.h

Overview

This class represents a service that clients can connect to. It owns its inbound connections and thus you should never modify the delegate of the individual data connections.

On iOS the server is automatically stopped if the app enters the background and restarted when the app comes back into the foreground.

Tasks

Creating a Server

Server Lifetime

Sending Objects

Getting Information

Properties

TXTRecord

The TXT Record attached to the Bonjour service.

@property (nonatomic, strong) NSDictionary *TXTRecord

Discussion

Updating this property while the server is running will update the broadcast TXTRecord. The server has its own instance of the TXTRecord so that it can be set even before calling start.

Declared In

DTBonjourServer.h

connections

The currently connected inbound DTBonjourDataConnection instances.

@property (nonatomic, readonly) NSSet *connections

Declared In

DTBonjourServer.h

delegate

The delegate that will be informed about activities happening on the server.

@property (nonatomic, weak) id<DTBonjourServerDelegate> delegate

Declared In

DTBonjourServer.h

port

The actual port bound to, valid after start

@property (nonatomic, assign, readonly) NSUInteger port

Declared In

DTBonjourServer.h

Instance Methods

broadcastObject:

Sends the object to all currently connected clients.

- (void)broadcastObject:(id)object

Parameters

object

The object that will be encoded and sent to all clients

Discussion

Note: any errors will be ignored. If you require finer-grained control then you should iterate over the individual connections.

Declared In

DTBonjourServer.h

initWithBonjourType:

Creates a server instances with the given bonjour type, e.g. “servicename.tcp”

- (id)initWithBonjourType:(NSString *)bonjourType

Parameters

bonjourType

The full service type string

Declared In

DTBonjourServer.h

start

Starts up the server, prepares it to be connected to and publishes the service via Bonjour

- (BOOL)start

Return Value

YES if the startup was successful

Declared In

DTBonjourServer.h

stop

Stops the service

- (void)stop

Declared In

DTBonjourServer.h