Exemple #1
0
  public static void main(String[] args) {
    try {
      int Port = 8093;

      // SSDP broadcast
      SSDP ssdp = new SSDP(Port);
      ssdp.start();

      // RaspiCam interface
      raspiCam = new RaspiCam();
      RpcFactory rpcFactory = new RpcFactory();
      IRpcService<IRaspiCam> service =
          rpcFactory.createSingleInstanceService(raspiCam, IRaspiCam.class);
      IMessagingSystemFactory messaging = new TcpMessagingSystemFactory();
      IDuplexInputChannel inputChannel =
          messaging.createDuplexInputChannel("tcp://0.0.0.0:" + Port + "/");
      inputChannel.responseReceiverConnected().subscribe(clientConnected);
      raspiCam.InputChannel = inputChannel;

      service.attachDuplexInputChannel(inputChannel);

      System.out.println("RaspiCam service is running. Press ENTER to stop.");
      new BufferedReader(new InputStreamReader(System.in)).readLine();

      ssdp.shutdown();
      service.detachDuplexInputChannel();
    } catch (Exception err) {
      System.err.println("Service failed.");
      err.printStackTrace();
    }
  }
Exemple #2
0
 private static void onClientConnected(Object sender, ResponseReceiverEventArgs e) {
   raspiCam.ClientId = e.getResponseReceiverId();
 }