public class BlaubotFactory
extends java.lang.Object
Constructor and Description |
---|
BlaubotFactory() |
Modifier and Type | Method and Description |
---|---|
static Blaubot |
createBlaubot(java.util.UUID appUuid,
IBlaubotAdapter adapter,
IBlaubotBeacon... beacons)
Creates a Blaubot instance from a given adapter and multiple beacons using a random unique device id for the ownDevice.
|
static Blaubot |
createBlaubot(java.util.UUID appUuid,
IBlaubotDevice ownDevice,
IBlaubotAdapter adapter,
IBlaubotBeacon... beacons)
Creates a Blaubot instance from a given adapter and multiple beacons.
|
static IBlaubotAdapter |
createBlaubotWebsocketAdapter(IBlaubotDevice ownDevice,
java.lang.String host,
int port)
Create a websocket adapter via reflection
|
static BlaubotServer |
createBlaubotWebsocketServer(IBlaubotDevice ownDevice)
Creates a blaubot server using websockets, the default port 8080 on all interfaces (0.0.0.0).
|
static BlaubotServer |
createBlaubotWebsocketServer(IBlaubotDevice ownDevice,
int httpPort)
Creates a blaubot server using websockets on all interfaces (0.0.0.0)
using the given httpPort.
|
static BlaubotServer |
createBlaubotWebsocketServer(IBlaubotDevice ownDevice,
java.lang.String host,
int port)
Creates a blaubot server using the websocket acceptor
|
static Blaubot |
createEthernetBlaubot(java.util.UUID appUUID)
Creates a ethernet blaubot instance with the default ports 17171, 17172, 17173
and does some dirty stuff to get around android's no network on main thread
policy.
|
static Blaubot |
createEthernetBlaubot(java.util.UUID appUUID,
int acceptorPort,
int beaconPort,
int beaconBroadcastPort,
java.net.InetAddress ownInetAddress)
Creates a blaubot instance using an existing network and the tcp socket adapter with the multicast beacon.
|
static Blaubot |
createEthernetBlaubotWithBonjourBeacon(java.util.UUID appUUID,
int acceptorPort,
int beaconPort,
java.net.InetAddress ownInetAddress)
Creates a blaubot instance using the bonjour beacon.
|
static Blaubot |
createEthernetBlaubotWithFixedDevicesBeacon(java.util.UUID appUUID,
IBlaubotDevice ownDevice,
int acceptorPort,
int beaconPort,
java.net.InetAddress ownInetAddress,
java.util.Set<java.lang.String> fixedDevicesSet)
Creates a blaubot instance using the ethernet adapter.
|
static IBlaubotAdapter |
createJsr82Adapter(BlaubotUUIDSet uuidSet,
IBlaubotDevice ownDevice)
Creates a JSR82 adapter that can be used on Windows, Mac and Linux, if a jsr82 implementation is available.
|
static Blaubot |
createJsr82BluetoothBlaubot(java.util.UUID appUUID)
Sets up a default
Blaubot instance using a Jsr82 bluetooth stack for connections and a multicast beacon (ip network) for discovery. |
static Blaubot |
createWebSocketBlaubotWithBonjourBeacon(java.util.UUID appUUID,
int websocketPort,
int beaconPort,
java.net.InetAddress ownInetAddress)
Creates a blaubot instance using an existing network and the websocket adapter with the bonjour beacon.
|
static Blaubot |
createWebSocketBlaubotWithMulticastBeacon(java.util.UUID appUUID,
int websocketPort,
int beaconPort,
int beaconBroadcastPort,
java.net.InetAddress ownInetAddress)
Creates a blaubot instance using an existing network and the websocket adapter with the multicast beacon.
|
static GeoBeaconServer |
createWebSocketGeoBeaconServer(int webSocketAcceptPort,
double geoRadius)
Creates a standalone GeoBeaconServer which uses WebSockets as an endpoint for a GeoLocationBeacon.
|
static GeoLocationBeacon |
createWebSocketGeoLocationBeacon(IBlaubotDevice ownDevice,
java.lang.String beaconServerHost,
int beaconServerPort)
Creates a GeoLocationBeacon using WebSockets.
|
static ConnectionMetaDataDTO |
createWebSocketMetaDataDTO(java.lang.String host,
java.lang.String path,
int port)
This shortcut method creates a websocket meta data object that can be used to provide endpoint
information when using a websocket based BlaubotServer or GeoBeaconServer.
|
static BlaubotServerConnector |
createWebSocketServerConnector(java.lang.String host,
int port,
java.lang.String websocketPath,
IBlaubotDevice ownDevice,
java.lang.String serverDeviceUniqueDeviceId)
Creates a WebSocket ServerConnector.
|
static java.net.InetAddress |
getLocalIpAddress()
TODO: move to another location
|
public static Blaubot createEthernetBlaubot(java.util.UUID appUUID)
appUUID
- the app's uuidpublic static Blaubot createEthernetBlaubotWithBonjourBeacon(java.util.UUID appUUID, int acceptorPort, int beaconPort, java.net.InetAddress ownInetAddress)
appUUID
- the app's uuidacceptorPort
- the port of the connector's accepting socketbeaconPort
- the port for the beacon to accept connections onownInetAddress
- the own InetAddress
of the network to act onpublic static Blaubot createEthernetBlaubot(java.util.UUID appUUID, int acceptorPort, int beaconPort, int beaconBroadcastPort, java.net.InetAddress ownInetAddress)
appUUID
- the app's uuidacceptorPort
- the port of the connector's accepting socketbeaconPort
- the port of the beacon's accepting socketbeaconBroadcastPort
- the broadcast port. Has to be the same for all instances.ownInetAddress
- the own InetAddress
of the network to act onpublic static Blaubot createWebSocketBlaubotWithMulticastBeacon(java.util.UUID appUUID, int websocketPort, int beaconPort, int beaconBroadcastPort, java.net.InetAddress ownInetAddress) throws java.lang.ClassNotFoundException
appUUID
- the app's uuidwebsocketPort
- the port for the websocket acceptor to listen onbeaconPort
- the port of the beacon's accepting socketbeaconBroadcastPort
- the broadcast port. Has to be the same for all instances.ownInetAddress
- the ip of this device to bind the websocket tojava.lang.ClassNotFoundException
- if the blaubot-websocket dependency could not be resolvedpublic static Blaubot createWebSocketBlaubotWithBonjourBeacon(java.util.UUID appUUID, int websocketPort, int beaconPort, java.net.InetAddress ownInetAddress) throws java.lang.ClassNotFoundException
appUUID
- the app's uuidwebsocketPort
- the port for the websocket acceptor to listen onbeaconPort
- the port of the beacon's accepting socketownInetAddress
- the own InetAddress
of the network to act onjava.lang.ClassNotFoundException
- if the blaubot-websocket dependency could not be resolvedpublic static Blaubot createEthernetBlaubotWithFixedDevicesBeacon(java.util.UUID appUUID, IBlaubotDevice ownDevice, int acceptorPort, int beaconPort, java.net.InetAddress ownInetAddress, java.util.Set<java.lang.String> fixedDevicesSet) throws java.net.UnknownHostException
appUUID
- the app's uuidownDevice
- the own device unique id. Note that it's uniqueId has to be present in the fixed device setacceptorPort
- the port of the connector's accepting socketbeaconPort
- the port of the beacon's accepting socketownInetAddress
- the own InetAddress
of the network to act onfixedDevicesSet
- a set of fixed devices to connect to (represented as uniqueIdStrings)java.net.UnknownHostException
- if inetAddress was invalidpublic static Blaubot createBlaubot(java.util.UUID appUuid, IBlaubotDevice ownDevice, IBlaubotAdapter adapter, IBlaubotBeacon... beacons)
appUuid
- the app's unique uuidownDevice
- the own device containing this device's unique identifieradapter
- the adapter to be used (Sockets, WebSockets, Bluetooth, ...)beacons
- the becaons to be used (Bluetooth, NFC, Multicast, Bonjour, ...)public static Blaubot createBlaubot(java.util.UUID appUuid, IBlaubotAdapter adapter, IBlaubotBeacon... beacons)
appUuid
- the app's unique uuidadapter
- the adapter to be used (Sockets, WebSockets, Bluetooth, ...)beacons
- the becaons to be used (Bluetooth, NFC, Multicast, Bonjour, ...)public static java.net.InetAddress getLocalIpAddress()
public static Blaubot createJsr82BluetoothBlaubot(java.util.UUID appUUID) throws java.lang.RuntimeException, java.lang.ClassNotFoundException
Blaubot
instance using a Jsr82 bluetooth stack for connections and a multicast beacon (ip network) for discovery.
Note that you have to include a Jsr82 compliant implementation into your classpath (i.e. bluecove (windows, mac); bluecove-gpl (linux); bluez)appUUID
- the app's unique uuidjava.lang.RuntimeException
- if no Jsr82 implementation is available at runtime or cannot access the bluetooth stackjava.lang.ClassNotFoundException
- if the blaubot-jsr82 jar is not available from the classpathpublic static final IBlaubotAdapter createJsr82Adapter(BlaubotUUIDSet uuidSet, IBlaubotDevice ownDevice) throws java.lang.ClassNotFoundException
uuidSet
- uuid set (created from the app uid)ownDevice
- the own devicejava.lang.ClassNotFoundException
- if the blaubot-jsr82 jar is not in the classpathpublic static BlaubotServer createBlaubotWebsocketServer(IBlaubotDevice ownDevice, java.lang.String host, int port) throws java.lang.ClassNotFoundException
ownDevice
- the own devicehost
- the interfaces to bind the websockets to.port
- the port to open the websocket server onjava.lang.ClassNotFoundException
- if the websocket jar is not in the classpathpublic static final IBlaubotAdapter createBlaubotWebsocketAdapter(IBlaubotDevice ownDevice, java.lang.String host, int port) throws java.lang.ClassNotFoundException
ownDevice
- the own device (and uniqueDeviceId)host
- the own host address (interfaces to bind to)port
- the port for the acceptor to accept connections onjava.lang.ClassNotFoundException
- if the websocket jar is not in the classpathpublic static final ConnectionMetaDataDTO createWebSocketMetaDataDTO(java.lang.String host, java.lang.String path, int port) throws java.lang.ClassNotFoundException
host
- the hostname to connect topath
- the path to connect the websocket with (with leading slash)port
- the portjava.lang.ClassNotFoundException
- if the websocket jar is not in the classpathpublic static BlaubotServer createBlaubotWebsocketServer(IBlaubotDevice ownDevice) throws java.lang.ClassNotFoundException
ownDevice
- the own devicejava.lang.ClassNotFoundException
- if the websocket jar is not in the classpathpublic static BlaubotServer createBlaubotWebsocketServer(IBlaubotDevice ownDevice, int httpPort) throws java.lang.ClassNotFoundException
ownDevice
- the own devicehttpPort
- the httpPort for the http server to server requestsjava.lang.ClassNotFoundException
- if the websocket jar is not in the classpathpublic static BlaubotServerConnector createWebSocketServerConnector(java.lang.String host, int port, java.lang.String websocketPath, IBlaubotDevice ownDevice, java.lang.String serverDeviceUniqueDeviceId) throws java.lang.ClassNotFoundException
host
- the server's hostname or IPv4-Addressport
- the server's portwebsocketPath
- the uri path used by the websocket acceptorownDevice
- the OWN device of the connecting blaubot instanceserverDeviceUniqueDeviceId
- the server's unique device id.java.lang.ClassNotFoundException
- if the websocket jar is not in the classpathpublic static GeoLocationBeacon createWebSocketGeoLocationBeacon(IBlaubotDevice ownDevice, java.lang.String beaconServerHost, int beaconServerPort) throws java.lang.ClassNotFoundException
GeoData
object to set the the
current location.ownDevice
- the ownDevice (Blaubot-Instance device)beaconServerHost
- the hostname or ip of the beacon serverbeaconServerPort
- the port on which the beacon server listensjava.lang.ClassNotFoundException
- if blaubot-websockets is not in the classpathpublic static GeoBeaconServer createWebSocketGeoBeaconServer(int webSocketAcceptPort, double geoRadius) throws java.lang.ClassNotFoundException
webSocketAcceptPort
- the websocket port to serve ongeoRadius
- the geo radius in km used to inform nearby beaconsjava.lang.ClassNotFoundException
- if blaubot-websockets is not in the classpath