org.teleal.cling.transport
Interface Router

All Known Implementing Classes:
AndroidWifiSwitchingRouter, RouterImpl

public interface Router

Interface of the network transport layer.

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

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

Author:
Christian Bauer
See Also:
ProtocolFactory

Method Summary
 void broadcast(byte[] bytes)
           Call this method to broadcast a UDP message to all hosts on the network.
 UpnpServiceConfiguration getConfiguration()
           
 int getLocalStreamPort(InetAddress address)
           
 NetworkAddressFactory getNetworkAddressFactory()
           
 ProtocolFactory getProtocolFactory()
           
 void received(IncomingDatagramMessage msg)
           This method is called internally by the transport layer when a datagram, either unicast or multicast, has been received.
 void 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.
 void send(OutgoingDatagramMessage msg)
           Call this method to send a UDP datagram message.
 StreamResponseMessage send(StreamRequestMessage msg)
           Call this method to send a TCP (HTTP) stream message.
 void shutdown()
          Unbinds all sockets and stops all listening threads for datagrams and streams.
 

Method Detail

getConfiguration

UpnpServiceConfiguration getConfiguration()
Returns:
The configuration used by this router.

getProtocolFactory

ProtocolFactory getProtocolFactory()
Returns:
The protocol factory used by this router.

getNetworkAddressFactory

NetworkAddressFactory getNetworkAddressFactory()
Returns:
The network interface and address binding configuration of this router.

getLocalStreamPort

int getLocalStreamPort(InetAddress address)
Parameters:
address - A bound address of a local network interface.
Returns:
The local port this router is listening on for TCP stream (HTTP) requests or 0 if the given address was not managed by this router.

shutdown

void shutdown()
Unbinds all sockets and stops all listening threads for datagrams and streams.


received

void 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:
msg - The received datagram message.

received

void 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 -

send

void send(OutgoingDatagramMessage msg)

Call this method to send a UDP datagram message.

Parameters:
msg - The UDP datagram message to send.

send

StreamResponseMessage send(StreamRequestMessage msg)

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

Parameters:
msg - The TCP (HTTP) stream message to send.
Returns:
The response received from the server.

broadcast

void broadcast(byte[] bytes)

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

Parameters:
bytes - The byte payload of the UDP datagram.


Copyright © 2010 Teleal GmbH, Switzerland. All Rights Reserved.