]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res/res_http_websocket: Add a pre-session established callback 85/485/2
authorMatt Jordan <mjordan@digium.com>
Wed, 13 May 2015 14:55:58 +0000 (09:55 -0500)
committerMatt Jordan <mjordan@digium.com>
Wed, 20 May 2015 00:59:45 +0000 (19:59 -0500)
commit31cc24aad603716e7ef68b384faebd14e0dfa460
tree6da4e0e4e654218029325f130de6483d83e9d4a6
parentf9114179e6bc727cd9fe593d50313c19b6e63492
res/res_http_websocket: Add a pre-session established callback

This patch updates http_websocket and its corresponding implementation
with a pre-session established callback. This callback allows for
WebSocket server consumers to be notified when a WebSocket connection is
attempted, but before we accept it. Consumers can choose to reject the
connection, if their application specific logic allows for it.

As a result, this patch pulls out the previously private
websocket_protocol struct and makes it public, as
ast_websocket_protocol. In order to preserve backwards compatibility
with existing modules, the existing APIs were left as-is, and new APIs
were added for the creation of the ast_websocket_protocol as well as for
adding a sub-protocol to a WebSocket server.

In particular, the following new API calls were added:
* ast_websocket_add_protocol2 - add a protocol to the core WebSocket
  server
* ast_websocket_server_add_protocol2 - add a protocol to a specific
  WebSocket server
* ast_websocket_sub_protocol_alloc - allocate a sub-protocol object.
  Consumers can populate this with whatever callbacks they wish to
  support, then add it to the core server or a specified server.

ASTERISK-24988
Reported by: Joshua Colp

Change-Id: Ibe0bbb30c17eec6b578071bdbd197c911b620ab2
include/asterisk/http_websocket.h
res/res_http_websocket.c