provided at the user callback directly.
However if you need it, for ALL callbacks wsi is valid and has a valid context
-pointer you can recover using lws_get_ctx(wsi).
+pointer you can recover using lws_get_context(wsi).
v1.5-chrome47-firefox41
lwsl_ext("checking client ext %s\n", ext_name);
n = 0;
- ext = lws_get_ctx(wsi)->extensions;
+ ext = lws_get_context(wsi)->extensions;
while (ext && ext->callback) {
if (strcmp(ext_name, ext->name)) {
ext++;
/* allow him to construct his context */
- ext->callback(lws_get_ctx(wsi), ext, wsi,
+ ext->callback(lws_get_context(wsi), ext, wsi,
LWS_EXT_CALLBACK_CLIENT_CONSTRUCT,
wsi->active_extensions_user[
wsi->count_active_extensions],
* initialization if they want to.
*
* NOTE the wsi is all zeros except for the context pointer
- * so lws_get_ctx(wsi) can work in the callback.
+ * so lws_get_context(wsi) can work in the callback.
*/
info->protocols[context->count_protocols].callback(&wsi,
LWS_CALLBACK_PROTOCOL_INIT, NULL, NULL, 0);
for (n = 0; n < wsi->count_active_extensions; n++) {
m = wsi->active_extensions[n]->callback(
- lws_get_ctx(wsi),
+ lws_get_context(wsi),
wsi->active_extensions[n], wsi,
reason,
wsi->active_extensions_user[n],
lws_return_http_status(struct lws *wsi, unsigned int code, const char *html_body)
{
int n, m;
- struct lws_context *context = lws_get_ctx(wsi);
+ struct lws_context *context = lws_get_context(wsi);
unsigned char *p = context->serv_buf +
LWS_SEND_BUFFER_PRE_PADDING;
unsigned char *start = p;
LWS_VISIBLE void
lws_libev_accept(struct lws *new_wsi, int accept_fd)
{
- struct lws_context *context = lws_get_ctx(new_wsi);
+ struct lws_context *context = lws_get_context(new_wsi);
struct ev_io *r = &new_wsi->w_read.watcher;
struct ev_io *w = &new_wsi->w_write.watcher;
LWS_VISIBLE void
lws_libev_io(struct lws *wsi, int flags)
{
- struct lws_context *context = lws_get_ctx(wsi);
+ struct lws_context *context = lws_get_context(wsi);
if (!LWS_LIBEV_ENABLED(context))
return;
}
LWS_VISIBLE LWS_EXTERN struct lws_context *
-lws_get_ctx(const struct lws *wsi)
+lws_get_context(const struct lws *wsi)
{
return wsi->context;
}
lws_get_fops(struct lws_context *context);
LWS_VISIBLE LWS_EXTERN struct lws_context *
-lws_get_ctx(const struct lws *wsi);
+lws_get_context(const struct lws *wsi);
/*
* Wsi-associated File Operations access helpers
lws_plat_file_open(struct lws *wsi, const char *filename,
unsigned long *filelen, int flags)
{
- return lws_get_fops(lws_get_ctx(wsi))->open(wsi, filename,
+ return lws_get_fops(lws_get_context(wsi))->open(wsi, filename,
filelen, flags);
}
static LWS_INLINE int
lws_plat_file_close(struct lws *wsi, lws_filefd_type fd)
{
- return lws_get_fops(lws_get_ctx(wsi))->close(wsi, fd);
+ return lws_get_fops(lws_get_context(wsi))->close(wsi, fd);
}
static LWS_INLINE unsigned long
lws_plat_file_seek_cur(struct lws *wsi, lws_filefd_type fd, long offset)
{
- return lws_get_fops(lws_get_ctx(wsi))->seek_cur(wsi, fd, offset);
+ return lws_get_fops(lws_get_context(wsi))->seek_cur(wsi, fd, offset);
}
static LWS_INLINE int
lws_plat_file_read(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
unsigned char *buf, unsigned long len)
{
- return lws_get_fops(lws_get_ctx(wsi))->read(wsi, fd, amount, buf, len);
+ return lws_get_fops(lws_get_context(wsi))->read(wsi, fd, amount, buf, len);
}
static LWS_INLINE int
lws_plat_file_write(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
unsigned char *buf, unsigned long len)
{
- return lws_get_fops(lws_get_ctx(wsi))->write(wsi, fd, amount, buf, len);
+ return lws_get_fops(lws_get_context(wsi))->write(wsi, fd, amount, buf, len);
}
/*
lwsl_debug("%s: wsi %p\r\n", __func__, (void *)wsi);
- lws_service_fd(lws_get_ctx(wsi), &pollfd);
+ lws_service_fd(lws_get_context(wsi), &pollfd);
}
extern "C" void mbed3_tcp_stream_bind(void *sock, int port, struct lws *wsi)
lwsl_debug("%s: lws %p\n", __func__, wsi);
- lws_service_fd(lws_get_ctx(wsi), &pollfd);
+ lws_service_fd(lws_get_context(wsi), &pollfd);
}
/*
* created. mbed3_tcp_stream_accept() is also called from
* here to bind the conn and new wsi together
*/
- lws_server_socket_service(lws_get_ctx(wsi),
+ lws_server_socket_service(lws_get_context(wsi),
wsi, (struct pollfd *)conn);
conn->ts->setOnError(TCPStream::ErrorHandler_t(conn, &lws_conn::onError));
lwsl_debug("%s: wsi %p (servicing now)\r\n", __func__, (void *)wsi);
- lws_service_fd(lws_get_ctx(wsi), &pollfd);
+ lws_service_fd(lws_get_context(wsi), &pollfd);
}
void lws_conn_listener::onError(Socket *s, socket_error_t err)
/* fetch the per-frame nonce */
- n = lws_get_random(lws_get_ctx(wsi), wsi->u.ws.mask_nonce, 4);
+ n = lws_get_random(lws_get_context(wsi), wsi->u.ws.mask_nonce, 4);
if (n != 4) {
lwsl_parser("Unable to read from random device %s %d\n",
SYSTEM_RANDOM_FILEPATH, n);
int lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len)
{
- struct lws_context *context = lws_get_ctx(wsi);
+ struct lws_context *context = lws_get_context(wsi);
size_t real_len = len;
int n, m;
if (!wsi || !wsi->protocol || wsi->position_in_fds_table < 0)
return 1;
- context = lws_get_ctx(wsi);
+ context = lws_get_context(wsi);
if (!context)
return 1;
/* check a client's extension against our support */
- ext = lws_get_ctx(wsi)->extensions;
+ ext = lws_get_context(wsi)->extensions;
while (ext && ext->callback) {
* particular connection + protocol
*/
- n = lws_get_ctx(wsi)->protocols[0].callback(wsi,
+ n = lws_get_context(wsi)->protocols[0].callback(wsi,
LWS_CALLBACK_CONFIRM_EXTENSION_OKAY,
wsi->user_space, ext_name, 0);
/* allow him to construct his context */
- ext->callback(lws_get_ctx(wsi),
+ ext->callback(lws_get_context(wsi),
ext, wsi,
LWS_EXT_CALLBACK_CONSTRUCT,
wsi->active_extensions_user[
int lws_handshake_server(struct lws *wsi, unsigned char **buf, size_t len)
{
- struct lws_context *context = lws_get_ctx(wsi);
+ struct lws_context *context = lws_get_context(wsi);
struct allocated_headers *ah;
int protocol_len, n, hit;
char protocol_list[128];
const char *other_headers,
int other_headers_len)
{
- struct lws_context *context = lws_get_ctx(wsi);
+ struct lws_context *context = lws_get_context(wsi);
unsigned char *response = context->serv_buf +
LWS_SEND_BUFFER_PRE_PADDING;
unsigned char *p = response;
switch (wsi->pps) {
case LWS_PPS_HTTP2_MY_SETTINGS:
case LWS_PPS_HTTP2_ACK_SETTINGS:
- lws_http2_do_pps_send(lws_get_ctx(wsi), wsi);
+ lws_http2_do_pps_send(lws_get_context(wsi), wsi);
break;
default:
break;
context = SSL_get_ex_data(ssl, openssl_websocket_private_data_index);
/*
- * give him a fake wsi with context set, so he can use lws_get_ctx()
+ * give him a fake wsi with context set, so he can use lws_get_context()
* in the callback
*/
memset(&wsi, 0, sizeof(wsi));
/*
* give him a fake wsi with context set, so he can use
- * lws_get_ctx() in the callback
+ * lws_get_context() in the callback
*/
memset(&wsi, 0, sizeof(wsi));
wsi.context = context;
/*
* give him a fake wsi with context set, so he can use
- * lws_get_ctx() in the callback
+ * lws_get_context() in the callback
*/
memset(&wsi, 0, sizeof(wsi));
wsi.context = context;
lwsl_notice("mirror: LWS_CALLBACK_CLIENT_ESTABLISHED\n");
- lws_get_random(lws_get_ctx(wsi), rands, sizeof(rands[0]));
+ lws_get_random(lws_get_context(wsi), rands, sizeof(rands[0]));
mirror_lifetime = 16384 + (rands[0] & 65535);
/* useful to test single connection stability */
if (longlived)
case LWS_CALLBACK_CLIENT_WRITEABLE:
for (n = 0; n < 1; n++) {
- lws_get_random(lws_get_ctx(wsi), rands, sizeof(rands));
+ lws_get_random(lws_get_context(wsi), rands, sizeof(rands));
l += sprintf((char *)&buf[LWS_SEND_BUFFER_PRE_PADDING + l],
"c #%06X %d %d %d;",
(int)rands[0] & 0xffffff,
switch (psf->state) {
case FRAGSTATE_START_MESSAGE:
- lws_get_random(lws_get_ctx(wsi), &ran, sizeof(ran));
+ lws_get_random(lws_get_context(wsi), &ran, sizeof(ran));
psf->packets_left = (ran % 1024) + 1;
fprintf(stderr, "Spamming %d random fragments\n",
psf->packets_left);
* code for rx spill because the rx buffer is full
*/
- lws_get_random(lws_get_ctx(wsi), &ran, sizeof(ran));
+ lws_get_random(lws_get_context(wsi), &ran, sizeof(ran));
chunk = (ran % 8000) + 1;
psf->total_message += chunk;
- lws_get_random(lws_get_ctx(wsi), bp, chunk);
+ lws_get_random(lws_get_context(wsi), bp, chunk);
for (n = 0; n < chunk; n++)
psf->sum += bp[n];
if (((ringbuffer_head - pss->ringbuffer_tail) &
(MAX_MESSAGE_QUEUE - 1)) == (MAX_MESSAGE_QUEUE - 15))
- lws_rx_flow_allow_all_protocol(lws_get_ctx(wsi),
+ lws_rx_flow_allow_all_protocol(lws_get_context(wsi),
lws_get_protocol(wsi));
if (lws_partial_buffered(wsi) || lws_send_pipe_choked(wsi)) {
lws_rx_flow_control(wsi, 0);
done:
- lws_callback_on_writable_all_protocol(lws_get_ctx(wsi),
+ lws_callback_on_writable_all_protocol(lws_get_context(wsi),
lws_get_protocol(wsi));
break;