Esempio n. 1
0
/* Start the WebSocket server and initialize default options. */
static void
start_server (void *ptr_data)
{
  GWSWriter *writer = (GWSWriter *) ptr_data;

  if ((writer->server = ws_init ("0.0.0.0", "7890")) == NULL)
    return;

  ws_set_config_strict (1);
  if (conf.addr)
    ws_set_config_host (conf.addr);
  if (conf.fifo_in)
    ws_set_config_pipein (conf.fifo_in);
  if (conf.fifo_out)
    ws_set_config_pipeout (conf.fifo_out);
  if (conf.origin)
    ws_set_config_origin (conf.origin);
  if (conf.port)
    ws_set_config_port (conf.port);
  if (conf.sslcert)
    ws_set_config_sslcert (conf.sslcert);
  if (conf.sslkey)
    ws_set_config_sslkey (conf.sslkey);
  writer->server->onopen = onopen;
  set_self_pipe (writer->server->self_pipe);

  /* select(2) will block in here */
  ws_start (writer->server);
  fprintf (stderr, "Stopping WebSocket server...\n");
  ws_stop (writer->server);
}
Esempio n. 2
0
static void
parse_long_opt (const char *name, const char *oarg)
{
  if (!strcmp ("echo-mode", name))
    ws_set_config_echomode (1);
  if (!strcmp ("max-frame-size", name))
    ws_set_config_frame_size (atoi (oarg));
  if (!strcmp ("origin", name))
    ws_set_config_origin (oarg);
  if (!strcmp ("pipein", name))
    ws_set_config_pipein (oarg);
  if (!strcmp ("pipeout", name))
    ws_set_config_pipeout (oarg);
  if (!strcmp ("strict", name))
    ws_set_config_strict (1);
  if (!strcmp ("access-log", name))
    ws_set_config_accesslog (oarg);
#if HAVE_LIBSSL
  if (!strcmp ("ssl-cert", name))
    ws_set_config_sslcert (oarg);
  if (!strcmp ("ssl-key", name))
    ws_set_config_sslkey (oarg);
#endif
  if (!strcmp ("std", name)) {
    ws_set_config_stdin (1);
    ws_set_config_stdout (1);
  }
  if (!strcmp ("stdin", name))
    ws_set_config_stdin (1);
  if (!strcmp ("stdout", name))
    ws_set_config_stdout (1);
}
Esempio n. 3
0
/* Read and set the WebSocket config options. */
static void
set_ws_opts (void)
{
  ws_set_config_strict (1);
  if (conf.addr)
    ws_set_config_host (conf.addr);
  if (conf.fifo_in)
    ws_set_config_pipein (conf.fifo_in);
  if (conf.fifo_out)
    ws_set_config_pipeout (conf.fifo_out);
  if (conf.origin)
    ws_set_config_origin (conf.origin);
  if (conf.port)
    ws_set_config_port (conf.port);
  if (conf.sslcert)
    ws_set_config_sslcert (conf.sslcert);
  if (conf.sslkey)
    ws_set_config_sslkey (conf.sslkey);
}