YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
Public Member Functions | List of all members
org.fourthline.cling.transport.Router Interface Reference

Interface of the network transport layer. More...

Inheritance diagram for org.fourthline.cling.transport.Router:
Inheritance graph
Collaboration diagram for org.fourthline.cling.transport.Router:
Collaboration graph

Public Member Functions

UpnpServiceConfiguration getConfiguration ()
 
ProtocolFactory getProtocolFactory ()
 
boolean enable () throws RouterException
 Starts all sockets and listening threads for datagrams and streams.
 
boolean disable () throws RouterException
 Unbinds all sockets and stops all listening threads for datagrams and streams.
 
void shutdown () throws RouterException
 Disables the router and releases all other resources.
 
boolean isEnabled () throws RouterException
 
void handleStartFailure (InitializationException ex) throws InitializationException
 Called by the enable() method before it returns.
 
List< NetworkAddress > getActiveStreamServers (InetAddress preferredAddress) throws RouterException
 
void received (IncomingDatagramMessage msg)
 
void received (UpnpStream stream)
 
void send (OutgoingDatagramMessage msg) throws RouterException
 
StreamResponseMessage send (StreamRequestMessage msg) throws RouterException
 
void broadcast (byte[] bytes) throws RouterException
 

Detailed Description

Interface of the network transport layer.

Encapsulates the transport layer and provides methods to the upper layers for sending UPnP stream (HTTP) org.fourthline.cling.model.message.StreamRequestMessages, sending (UDP) datagram org.fourthline.cling.model.message.OutgoingDatagramMessages, as well as broadcasting bytes to all LAN participants.

A router also maintains listening sockets and services, for incoming UDP unicast/multicast org.fourthline.cling.model.message.IncomingDatagramMessage and TCP org.fourthline.cling.transport.spi.UpnpStreams. An implementation of this interface handles these messages, e.g. by selecting and executing the right protocol.

An implementation must be thread-safe, and can be accessed concurrently. If the Router is disabled, it doesn't listen on the network for incoming messages and does not send outgoing messages.

See also
org.fourthline.cling.protocol.ProtocolFactory
Author
Christian Bauer

Member Function Documentation

◆ broadcast()

void org.fourthline.cling.transport.Router.broadcast ( byte[]  bytes) throws RouterException

Call this method to broadcast a UDP message to all hosts on the network.

Parameters
bytesThe byte payload of the UDP datagram.
Exceptions
RouterExceptionif a recoverable error, such as thread interruption, occurs.

Implemented in org.fourthline.cling.transport.RouterImpl.

◆ disable()

boolean org.fourthline.cling.transport.Router.disable ( ) throws RouterException

Unbinds all sockets and stops all listening threads for datagrams and streams.

Returns
true if the router was disabled. false if it wasn't running.

Implemented in org.fourthline.cling.transport.RouterImpl.

◆ enable()

boolean org.fourthline.cling.transport.Router.enable ( ) throws RouterException

Starts all sockets and listening threads for datagrams and streams.

Returns
true if the router was enabled. false if it's already running.

Implemented in org.fourthline.cling.transport.RouterImpl.

◆ getActiveStreamServers()

List< NetworkAddress > org.fourthline.cling.transport.Router.getActiveStreamServers ( InetAddress  preferredAddress) throws RouterException
Parameters
preferredAddressA preferred stream server bound address or null.
Returns
An empty list if no stream server is currently active, otherwise a single network address if the preferred address is active, or a list of all active bound stream servers.

Implemented in org.fourthline.cling.transport.RouterImpl.

◆ getConfiguration()

UpnpServiceConfiguration org.fourthline.cling.transport.Router.getConfiguration ( )
Returns
The configuration used by this router.

Implemented in org.fourthline.cling.transport.RouterImpl.

◆ getProtocolFactory()

ProtocolFactory org.fourthline.cling.transport.Router.getProtocolFactory ( )
Returns
The protocol factory used by this router.

Implemented in org.fourthline.cling.transport.RouterImpl.

◆ handleStartFailure()

void org.fourthline.cling.transport.Router.handleStartFailure ( InitializationException  ex) throws InitializationException

Called by the enable() method before it returns.

Parameters
exThe cause of the failure.
Exceptions
InitializationExceptionif the exception was not recoverable.

Implemented in org.fourthline.cling.transport.RouterImpl.

◆ isEnabled()

boolean org.fourthline.cling.transport.Router.isEnabled ( ) throws RouterException
Returns
true if the router is currently enabled.

Implemented in org.fourthline.cling.transport.RouterImpl.

◆ received() [1/2]

void org.fourthline.cling.transport.Router.received ( IncomingDatagramMessage  msg)

This method is called internally by the transport layer when a datagram, either unicast or multicast, has been received. An implementation of this interface has to handle the received message, e.g. selecting and executing a UPnP protocol. This method should not block until the execution completes, the calling thread should be free to handle the next reception as soon as possible.

Parameters
msgThe received datagram message.

Implemented in org.fourthline.cling.transport.RouterImpl.

◆ received() [2/2]

void org.fourthline.cling.transport.Router.received ( UpnpStream  stream)

This method is called internally by the transport layer when a TCP stream connection has been made and a response has to be returned to the sender. An implementation of this interface has to handle the received stream connection and return a response, e.g. selecting and executing a UPnP protocol. This method should not block until the execution completes, the calling thread should be free to process the next reception as soon as possible. Typically this means starting a new thread of execution in this method.

Parameters
stream

Implemented in org.fourthline.cling.transport.RouterImpl.

◆ send() [1/2]

void org.fourthline.cling.transport.Router.send ( OutgoingDatagramMessage  msg) throws RouterException

Call this method to send a UDP datagram message.

Parameters
msgThe UDP datagram message to send.
Exceptions
RouterExceptionif a recoverable error, such as thread interruption, occurs.

Implemented in org.fourthline.cling.transport.RouterImpl.

◆ send() [2/2]

StreamResponseMessage org.fourthline.cling.transport.Router.send ( StreamRequestMessage  msg) throws RouterException

Call this method to send a TCP (HTTP) stream message.

Parameters
msgThe TCP (HTTP) stream message to send.
Returns
The response received from the server.
Exceptions
RouterExceptionif a recoverable error, such as thread interruption, occurs.

Implemented in org.fourthline.cling.transport.RouterImpl.

◆ shutdown()

void org.fourthline.cling.transport.Router.shutdown ( ) throws RouterException

Disables the router and releases all other resources.

Implemented in org.fourthline.cling.transport.RouterImpl.


The documentation for this interface was generated from the following file: