use of org.eclipse.californium.core.server.resources.MyIpResource in project californium by eclipse.
the class MulticastTestServer method main.
public static void main(String[] args) throws UnknownHostException {
Configuration config = Configuration.createWithFile(CONFIG_FILE, CONFIG_HEADER, DEFAULTS);
Configuration.setStandard(config);
int unicastPort = config.get(CoapConfig.COAP_PORT);
int multicastPort = unicastPort;
switch(args.length) {
default:
System.out.println("usage: MulticastTestServer [unicast-port [multicast-port]]");
case 2:
multicastPort = Integer.parseInt(args[1]);
case 1:
unicastPort = Integer.parseInt(args[0]);
case 0:
}
CoapServer server = new CoapServer(config);
createEndpoints(server, unicastPort, multicastPort, config);
server.add(new HelloWorldResource());
server.add(new MyIpResource(MyIpResource.RESOURCE_NAME, true));
server.start();
}
use of org.eclipse.californium.core.server.resources.MyIpResource in project californium by eclipse.
the class ServerService method onStartCommand.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i("coap", "onStartCommand service");
executor.execute(new Runnable() {
@Override
public void run() {
Configuration config = Configuration.createStandardWithoutFile();
CoapServer server = new CoapServer(config);
NetworkInterface multicast = NetworkInterfacesUtil.getMulticastInterface();
if (multicast == null) {
setupUdp(server, config);
} else {
setupUdpIpv4(server, config);
setupUdpIpv6(server, config);
}
setupDtls(server, config);
server.add(new HelloWorldResource());
server.add(new MyIpResource(MyIpResource.RESOURCE_NAME, true));
startServer(server);
}
});
return START_STICKY;
}
Aggregations