ws_listen

ws_listen(const struct ws_listen_options *options)

Listens for connections.

int server_callback(struct ws_client *client, enum ws_event event, void *user)
{
  switch(event)
  {
  case LIBWS_EVENT_CONNECTED:
    // new client connected
    break;
  case LIBWS_EVENT_RECEIVED:
    // received data from client
    break;
  default:
    break;
  }

  return 0;
}

struct ws_listen_options options;
options.context = context;
options.port = 1234;
options.callback = server_callback;
struct ws* ws = ws_connect(&options);

Parameters

options[in] Listen options

Returns

A new websocket, or NULL.