group__Protocols-and-Plugins.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.11"/>
  7. <title>libwebsockets: Protocols and Plugins</title>
  8. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  9. <script type="text/javascript" src="jquery.js"></script>
  10. <script type="text/javascript" src="dynsections.js"></script>
  11. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  12. <script type="text/javascript" src="resize.js"></script>
  13. <script type="text/javascript" src="navtreedata.js"></script>
  14. <script type="text/javascript" src="navtree.js"></script>
  15. <script type="text/javascript">
  16. $(document).ready(initResizable);
  17. $(window).load(resizeHeight);
  18. </script>
  19. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  20. </head>
  21. <body>
  22. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  23. <div id="titlearea">
  24. <table cellspacing="0" cellpadding="0">
  25. <tbody>
  26. <tr style="height: 56px;">
  27. <td id="projectlogo"><img alt="Logo" src="libwebsockets.org-logo.png"/></td>
  28. <td id="projectalign" style="padding-left: 0.5em;">
  29. <div id="projectname">libwebsockets
  30. </div>
  31. <div id="projectbrief">Lightweight C library for HTML5 websockets</div>
  32. </td>
  33. </tr>
  34. </tbody>
  35. </table>
  36. </div>
  37. <!-- end header part -->
  38. <!-- Generated by Doxygen 1.8.11 -->
  39. <div id="navrow1" class="tabs">
  40. <ul class="tablist">
  41. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  42. <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
  43. <li class="current"><a href="modules.html"><span>Modules</span></a></li>
  44. <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
  45. <li><a href="files.html"><span>Files</span></a></li>
  46. </ul>
  47. </div>
  48. </div><!-- top -->
  49. <div id="side-nav" class="ui-resizable side-nav-resizable">
  50. <div id="nav-tree">
  51. <div id="nav-tree-contents">
  52. <div id="nav-sync" class="sync"></div>
  53. </div>
  54. </div>
  55. <div id="splitbar" style="-moz-user-select:none;"
  56. class="ui-resizable-handle">
  57. </div>
  58. </div>
  59. <script type="text/javascript">
  60. $(document).ready(function(){initNavTree('group__Protocols-and-Plugins.html','');});
  61. </script>
  62. <div id="doc-content">
  63. <div class="header">
  64. <div class="summary">
  65. <a href="#groups">Modules</a> &#124;
  66. <a href="#nested-classes">Data Structures</a> &#124;
  67. <a href="#typedef-members">Typedefs</a> &#124;
  68. <a href="#func-members">Functions</a> </div>
  69. <div class="headertitle">
  70. <div class="title">Protocols and Plugins</div> </div>
  71. </div><!--header-->
  72. <div class="contents">
  73. <table class="memberdecls">
  74. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="groups"></a>
  75. Modules</h2></td></tr>
  76. <tr class="memitem:group__generic-sessions"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__generic-sessions.html">plugin: generic-sessions</a></td></tr>
  77. <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
  78. </table><table class="memberdecls">
  79. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
  80. Data Structures</h2></td></tr>
  81. <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structlws__protocols.html">lws_protocols</a></td></tr>
  82. <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
  83. <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structlws__plugin__capability.html">lws_plugin_capability</a></td></tr>
  84. <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
  85. <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structlws__plugin.html">lws_plugin</a></td></tr>
  86. <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
  87. </table><table class="memberdecls">
  88. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
  89. Typedefs</h2></td></tr>
  90. <tr class="memitem:ga40994491e1567f91f579d2b444775266"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga40994491e1567f91f579d2b444775266"></a>
  91. typedef int(*&#160;</td><td class="memItemRight" valign="bottom"><b>lws_plugin_init_func</b>) (struct lws_context *, struct <a class="el" href="structlws__plugin__capability.html">lws_plugin_capability</a> *)</td></tr>
  92. <tr class="separator:ga40994491e1567f91f579d2b444775266"><td class="memSeparator" colspan="2">&#160;</td></tr>
  93. <tr class="memitem:ga83f7a924ba790fa273476075a59f08b0"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga83f7a924ba790fa273476075a59f08b0"></a>
  94. typedef int(*&#160;</td><td class="memItemRight" valign="bottom"><b>lws_plugin_destroy_func</b>) (struct lws_context *)</td></tr>
  95. <tr class="separator:ga83f7a924ba790fa273476075a59f08b0"><td class="memSeparator" colspan="2">&#160;</td></tr>
  96. </table><table class="memberdecls">
  97. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
  98. Functions</h2></td></tr>
  99. <tr class="memitem:ga25754726d97c5f519d313e691a9fe29d"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN const struct <a class="el" href="structlws__protocols.html">lws_protocols</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Protocols-and-Plugins.html#ga25754726d97c5f519d313e691a9fe29d">lws_vhost_name_to_protocol</a> (struct lws_vhost *vh, const char *name)</td></tr>
  100. <tr class="separator:ga25754726d97c5f519d313e691a9fe29d"><td class="memSeparator" colspan="2">&#160;</td></tr>
  101. <tr class="memitem:ga72ad550786ca7976463589d347e62112"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN const struct <a class="el" href="structlws__protocols.html">lws_protocols</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Protocols-and-Plugins.html#ga72ad550786ca7976463589d347e62112">lws_get_protocol</a> (struct lws *wsi)</td></tr>
  102. <tr class="separator:ga72ad550786ca7976463589d347e62112"><td class="memSeparator" colspan="2">&#160;</td></tr>
  103. <tr class="memitem:ga8bbe5e65faca068845704bab911a5030"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN const struct <a class="el" href="structlws__protocols.html">lws_protocols</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Protocols-and-Plugins.html#ga8bbe5e65faca068845704bab911a5030">lws_protocol_get</a> (struct lws *wsi) LWS_WARN_DEPRECATED</td></tr>
  104. <tr class="separator:ga8bbe5e65faca068845704bab911a5030"><td class="memSeparator" colspan="2">&#160;</td></tr>
  105. <tr class="memitem:gaec0c0477288ff3f83aff38d357b883d1"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Protocols-and-Plugins.html#gaec0c0477288ff3f83aff38d357b883d1">lws_protocol_vh_priv_zalloc</a> (struct lws_vhost *vhost, const struct <a class="el" href="structlws__protocols.html">lws_protocols</a> *prot, int size)</td></tr>
  106. <tr class="separator:gaec0c0477288ff3f83aff38d357b883d1"><td class="memSeparator" colspan="2">&#160;</td></tr>
  107. <tr class="memitem:gaf3be4243443baac0f8be1fcfb4d25129"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Protocols-and-Plugins.html#gaf3be4243443baac0f8be1fcfb4d25129">lws_protocol_vh_priv_get</a> (struct lws_vhost *vhost, const struct <a class="el" href="structlws__protocols.html">lws_protocols</a> *prot)</td></tr>
  108. <tr class="separator:gaf3be4243443baac0f8be1fcfb4d25129"><td class="memSeparator" colspan="2">&#160;</td></tr>
  109. <tr class="memitem:ga106b37ae9c247e84d191ab09441adc43"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Protocols-and-Plugins.html#ga106b37ae9c247e84d191ab09441adc43">lws_finalize_startup</a> (struct lws_context *context)</td></tr>
  110. <tr class="separator:ga106b37ae9c247e84d191ab09441adc43"><td class="memSeparator" colspan="2">&#160;</td></tr>
  111. </table>
  112. <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
  113. <h2>Protocol and protocol plugin -related apis</h2>
  114. <p>Protocols bind ws protocol names to a custom callback specific to that protocol implementaion.</p>
  115. <p>A list of protocols can be passed in at context creation time, but it is also legal to leave that NULL and add the protocols and their callback code using plugins.</p>
  116. <p>Plugins are much preferable compared to cut and pasting code into an application each time, since they can be used standalone. </p>
  117. <h2 class="groupheader">Function Documentation</h2>
  118. <a class="anchor" id="ga106b37ae9c247e84d191ab09441adc43"></a>
  119. <div class="memitem">
  120. <div class="memproto">
  121. <table class="memname">
  122. <tr>
  123. <td class="memname">LWS_VISIBLE LWS_EXTERN int lws_finalize_startup </td>
  124. <td>(</td>
  125. <td class="paramtype">struct lws_context *&#160;</td>
  126. <td class="paramname"><em>context</em></td><td>)</td>
  127. <td></td>
  128. </tr>
  129. </table>
  130. </div><div class="memdoc">
  131. <p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
  132. <p><a class="el" href="group__Protocols-and-Plugins.html#ga106b37ae9c247e84d191ab09441adc43">lws_finalize_startup()</a> - drop initial process privileges</p>
  133. <dl class="params"><dt>Parameters</dt><dd>
  134. <table class="params">
  135. <tr><td class="paramname">context</td><td>lws context</td></tr>
  136. </table>
  137. </dd>
  138. </dl>
  139. <p>This is called after the end of the vhost protocol initializations, but you may choose to call it earlier </p>
  140. </div>
  141. </div>
  142. <a class="anchor" id="ga72ad550786ca7976463589d347e62112"></a>
  143. <div class="memitem">
  144. <div class="memproto">
  145. <table class="memname">
  146. <tr>
  147. <td class="memname">LWS_VISIBLE LWS_EXTERN const struct <a class="el" href="structlws__protocols.html">lws_protocols</a>* lws_get_protocol </td>
  148. <td>(</td>
  149. <td class="paramtype">struct lws *&#160;</td>
  150. <td class="paramname"><em>wsi</em></td><td>)</td>
  151. <td></td>
  152. </tr>
  153. </table>
  154. </div><div class="memdoc">
  155. <p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
  156. <p><a class="el" href="group__Protocols-and-Plugins.html#ga72ad550786ca7976463589d347e62112">lws_get_protocol()</a> - Returns a protocol pointer from a websocket connection. </p><dl class="params"><dt>Parameters</dt><dd>
  157. <table class="params">
  158. <tr><td class="paramname">wsi</td><td>pointer to struct websocket you want to know the protocol of</td></tr>
  159. </table>
  160. </dd>
  161. </dl>
  162. <pre class="fragment"> Some apis can act on all live connections of a given protocol,
  163. this is how you can get a pointer to the active protocol if needed.</pre>
  164. </div>
  165. </div>
  166. <a class="anchor" id="ga8bbe5e65faca068845704bab911a5030"></a>
  167. <div class="memitem">
  168. <div class="memproto">
  169. <table class="memname">
  170. <tr>
  171. <td class="memname">LWS_VISIBLE LWS_EXTERN const struct <a class="el" href="structlws__protocols.html">lws_protocols</a>* lws_protocol_get </td>
  172. <td>(</td>
  173. <td class="paramtype">struct lws *&#160;</td>
  174. <td class="paramname"><em>wsi</em></td><td>)</td>
  175. <td></td>
  176. </tr>
  177. </table>
  178. </div><div class="memdoc">
  179. <p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
  180. <p><a class="el" href="group__Protocols-and-Plugins.html#ga8bbe5e65faca068845704bab911a5030">lws_protocol_get()</a> - deprecated: use lws_get_protocol </p>
  181. </div>
  182. </div>
  183. <a class="anchor" id="gaf3be4243443baac0f8be1fcfb4d25129"></a>
  184. <div class="memitem">
  185. <div class="memproto">
  186. <table class="memname">
  187. <tr>
  188. <td class="memname">LWS_VISIBLE LWS_EXTERN void* lws_protocol_vh_priv_get </td>
  189. <td>(</td>
  190. <td class="paramtype">struct lws_vhost *&#160;</td>
  191. <td class="paramname"><em>vhost</em>, </td>
  192. </tr>
  193. <tr>
  194. <td class="paramkey"></td>
  195. <td></td>
  196. <td class="paramtype">const struct <a class="el" href="structlws__protocols.html">lws_protocols</a> *&#160;</td>
  197. <td class="paramname"><em>prot</em>&#160;</td>
  198. </tr>
  199. <tr>
  200. <td></td>
  201. <td>)</td>
  202. <td></td><td></td>
  203. </tr>
  204. </table>
  205. </div><div class="memdoc">
  206. <p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
  207. <p><a class="el" href="group__Protocols-and-Plugins.html#gaf3be4243443baac0f8be1fcfb4d25129">lws_protocol_vh_priv_get()</a> - retreive a protocol's per-vhost storage</p>
  208. <dl class="params"><dt>Parameters</dt><dd>
  209. <table class="params">
  210. <tr><td class="paramname">vhost</td><td>vhost the instance is related to </td></tr>
  211. <tr><td class="paramname">prot</td><td>protocol the instance is related to</td></tr>
  212. </table>
  213. </dd>
  214. </dl>
  215. <p>Recover a pointer to the allocated per-vhost storage for the protocol created by <a class="el" href="group__Protocols-and-Plugins.html#gaec0c0477288ff3f83aff38d357b883d1">lws_protocol_vh_priv_zalloc()</a> earlier </p>
  216. </div>
  217. </div>
  218. <a class="anchor" id="gaec0c0477288ff3f83aff38d357b883d1"></a>
  219. <div class="memitem">
  220. <div class="memproto">
  221. <table class="memname">
  222. <tr>
  223. <td class="memname">LWS_VISIBLE LWS_EXTERN void* lws_protocol_vh_priv_zalloc </td>
  224. <td>(</td>
  225. <td class="paramtype">struct lws_vhost *&#160;</td>
  226. <td class="paramname"><em>vhost</em>, </td>
  227. </tr>
  228. <tr>
  229. <td class="paramkey"></td>
  230. <td></td>
  231. <td class="paramtype">const struct <a class="el" href="structlws__protocols.html">lws_protocols</a> *&#160;</td>
  232. <td class="paramname"><em>prot</em>, </td>
  233. </tr>
  234. <tr>
  235. <td class="paramkey"></td>
  236. <td></td>
  237. <td class="paramtype">int&#160;</td>
  238. <td class="paramname"><em>size</em>&#160;</td>
  239. </tr>
  240. <tr>
  241. <td></td>
  242. <td>)</td>
  243. <td></td><td></td>
  244. </tr>
  245. </table>
  246. </div><div class="memdoc">
  247. <p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
  248. <p><a class="el" href="group__Protocols-and-Plugins.html#gaec0c0477288ff3f83aff38d357b883d1">lws_protocol_vh_priv_zalloc()</a> - Allocate and zero down a protocol's per-vhost storage </p><dl class="params"><dt>Parameters</dt><dd>
  249. <table class="params">
  250. <tr><td class="paramname">vhost</td><td>vhost the instance is related to </td></tr>
  251. <tr><td class="paramname">prot</td><td>protocol the instance is related to </td></tr>
  252. <tr><td class="paramname">size</td><td>bytes to allocate</td></tr>
  253. </table>
  254. </dd>
  255. </dl>
  256. <p>Protocols often find it useful to allocate a per-vhost struct, this is a helper to be called in the per-vhost init LWS_CALLBACK_PROTOCOL_INIT </p>
  257. </div>
  258. </div>
  259. <a class="anchor" id="ga25754726d97c5f519d313e691a9fe29d"></a>
  260. <div class="memitem">
  261. <div class="memproto">
  262. <table class="memname">
  263. <tr>
  264. <td class="memname">LWS_VISIBLE LWS_EXTERN const struct <a class="el" href="structlws__protocols.html">lws_protocols</a>* lws_vhost_name_to_protocol </td>
  265. <td>(</td>
  266. <td class="paramtype">struct lws_vhost *&#160;</td>
  267. <td class="paramname"><em>vh</em>, </td>
  268. </tr>
  269. <tr>
  270. <td class="paramkey"></td>
  271. <td></td>
  272. <td class="paramtype">const char *&#160;</td>
  273. <td class="paramname"><em>name</em>&#160;</td>
  274. </tr>
  275. <tr>
  276. <td></td>
  277. <td>)</td>
  278. <td></td><td></td>
  279. </tr>
  280. </table>
  281. </div><div class="memdoc">
  282. <p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
  283. <p><a class="el" href="group__Protocols-and-Plugins.html#ga25754726d97c5f519d313e691a9fe29d">lws_vhost_name_to_protocol()</a> - get vhost's protocol object from its name</p>
  284. <dl class="params"><dt>Parameters</dt><dd>
  285. <table class="params">
  286. <tr><td class="paramname">vh</td><td>vhost to search </td></tr>
  287. <tr><td class="paramname">name</td><td>protocol name</td></tr>
  288. </table>
  289. </dd>
  290. </dl>
  291. <p>Returns NULL or a pointer to the vhost's protocol of the requested name </p>
  292. </div>
  293. </div>
  294. </div><!-- contents -->
  295. </div><!-- doc-content -->
  296. <!-- start footer part -->
  297. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  298. <ul>
  299. <li class="footer">Generated by
  300. <a href="http://www.doxygen.org/index.html">
  301. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  302. </ul>
  303. </div>
  304. </body>
  305. </html>