module-src_server-Server.html 15 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Class: Server</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Class: Server</h1>
  17. <section>
  18. <header>
  19. <h2>
  20. <span class="ancestors"><a href="module-src_server.html">src/server</a>~</span>
  21. Server
  22. </h2>
  23. </header>
  24. <article>
  25. <div class="container-overview">
  26. <h4 class="name" id="Server"><span class="type-signature"></span>new Server<span class="signature">(options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
  27. <div class="description">
  28. Constructs a server object that stores request handlers and delegates
  29. incoming requests to those handlers
  30. </div>
  31. <h5>Parameters:</h5>
  32. <table class="params">
  33. <thead>
  34. <tr>
  35. <th>Name</th>
  36. <th>Type</th>
  37. <th>Attributes</th>
  38. <th class="last">Description</th>
  39. </tr>
  40. </thead>
  41. <tbody>
  42. <tr>
  43. <td class="name"><code>options</code></td>
  44. <td class="type">
  45. <span class="param-type">Object</span>
  46. </td>
  47. <td class="attributes">
  48. &lt;optional><br>
  49. </td>
  50. <td class="description last">Options that should be passed to the internal server
  51. implementation</td>
  52. </tr>
  53. </tbody>
  54. </table>
  55. <dl class="details">
  56. <dt class="tag-source">Source:</dt>
  57. <dd class="tag-source"><ul class="dummy"><li>
  58. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line559">line 559</a>
  59. </li></ul></dd>
  60. </dl>
  61. </div>
  62. <h3 class="subsection-title">Methods</h3>
  63. <h4 class="name" id="addProtoService"><span class="type-signature"></span>addProtoService<span class="signature">(service, implementation)</span><span class="type-signature"></span></h4>
  64. <div class="description">
  65. Add a proto service to the server, with a corresponding implementation
  66. </div>
  67. <h5>Parameters:</h5>
  68. <table class="params">
  69. <thead>
  70. <tr>
  71. <th>Name</th>
  72. <th>Type</th>
  73. <th class="last">Description</th>
  74. </tr>
  75. </thead>
  76. <tbody>
  77. <tr>
  78. <td class="name"><code>service</code></td>
  79. <td class="type">
  80. <span class="param-type">Protobuf.Reflect.Service</span>
  81. </td>
  82. <td class="description last">The proto service descriptor</td>
  83. </tr>
  84. <tr>
  85. <td class="name"><code>implementation</code></td>
  86. <td class="type">
  87. <span class="param-type">Object.&lt;String, function()></span>
  88. </td>
  89. <td class="description last">Map of method names to
  90. method implementation for the provided service.</td>
  91. </tr>
  92. </tbody>
  93. </table>
  94. <dl class="details">
  95. <dt class="tag-source">Source:</dt>
  96. <dd class="tag-source"><ul class="dummy"><li>
  97. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line703">line 703</a>
  98. </li></ul></dd>
  99. </dl>
  100. <h4 class="name" id="addService"><span class="type-signature"></span>addService<span class="signature">(service, implementation)</span><span class="type-signature"></span></h4>
  101. <div class="description">
  102. Add a service to the server, with a corresponding implementation. If you are
  103. generating this from a proto file, you should instead use
  104. addProtoService.
  105. </div>
  106. <h5>Parameters:</h5>
  107. <table class="params">
  108. <thead>
  109. <tr>
  110. <th>Name</th>
  111. <th>Type</th>
  112. <th class="last">Description</th>
  113. </tr>
  114. </thead>
  115. <tbody>
  116. <tr>
  117. <td class="name"><code>service</code></td>
  118. <td class="type">
  119. <span class="param-type">Object.&lt;String, *></span>
  120. </td>
  121. <td class="description last">The service descriptor, as
  122. <a href="module-src_common.html#.getProtobufServiceAttrs">module:src/common.getProtobufServiceAttrs</a> returns</td>
  123. </tr>
  124. <tr>
  125. <td class="name"><code>implementation</code></td>
  126. <td class="type">
  127. <span class="param-type">Object.&lt;String, function()></span>
  128. </td>
  129. <td class="description last">Map of method names to
  130. method implementation for the provided service.</td>
  131. </tr>
  132. </tbody>
  133. </table>
  134. <dl class="details">
  135. <dt class="tag-source">Source:</dt>
  136. <dd class="tag-source"><ul class="dummy"><li>
  137. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line660">line 660</a>
  138. </li></ul></dd>
  139. </dl>
  140. <h4 class="name" id="bind"><span class="type-signature"></span>bind<span class="signature">(port, creds<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
  141. <div class="description">
  142. Binds the server to the given port, with SSL enabled if creds is given
  143. </div>
  144. <h5>Parameters:</h5>
  145. <table class="params">
  146. <thead>
  147. <tr>
  148. <th>Name</th>
  149. <th>Type</th>
  150. <th>Attributes</th>
  151. <th class="last">Description</th>
  152. </tr>
  153. </thead>
  154. <tbody>
  155. <tr>
  156. <td class="name"><code>port</code></td>
  157. <td class="type">
  158. <span class="param-type">string</span>
  159. </td>
  160. <td class="attributes">
  161. </td>
  162. <td class="description last">The port that the server should bind on, in the format
  163. "address:port"</td>
  164. </tr>
  165. <tr>
  166. <td class="name"><code>creds</code></td>
  167. <td class="type">
  168. <span class="param-type">boolean</span>
  169. </td>
  170. <td class="attributes">
  171. &lt;optional><br>
  172. </td>
  173. <td class="description last">Server credential object to be used for SSL. Pass
  174. nothing for an insecure port</td>
  175. </tr>
  176. </tbody>
  177. </table>
  178. <dl class="details">
  179. <dt class="tag-source">Source:</dt>
  180. <dd class="tag-source"><ul class="dummy"><li>
  181. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line714">line 714</a>
  182. </li></ul></dd>
  183. </dl>
  184. <h4 class="name" id="register"><span class="type-signature"></span>register<span class="signature">(name, handler, serialize, deserialize, type)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
  185. <div class="description">
  186. Registers a handler to handle the named method. Fails if there already is
  187. a handler for the given method. Returns true on success
  188. </div>
  189. <h5>Parameters:</h5>
  190. <table class="params">
  191. <thead>
  192. <tr>
  193. <th>Name</th>
  194. <th>Type</th>
  195. <th class="last">Description</th>
  196. </tr>
  197. </thead>
  198. <tbody>
  199. <tr>
  200. <td class="name"><code>name</code></td>
  201. <td class="type">
  202. <span class="param-type">string</span>
  203. </td>
  204. <td class="description last">The name of the method that the provided function should
  205. handle/respond to.</td>
  206. </tr>
  207. <tr>
  208. <td class="name"><code>handler</code></td>
  209. <td class="type">
  210. <span class="param-type">function</span>
  211. </td>
  212. <td class="description last">Function that takes a stream of request values and
  213. returns a stream of response values</td>
  214. </tr>
  215. <tr>
  216. <td class="name"><code>serialize</code></td>
  217. <td class="type">
  218. <span class="param-type">function</span>
  219. </td>
  220. <td class="description last">Serialization function for responses</td>
  221. </tr>
  222. <tr>
  223. <td class="name"><code>deserialize</code></td>
  224. <td class="type">
  225. <span class="param-type">function</span>
  226. </td>
  227. <td class="description last">Deserialization function for requests</td>
  228. </tr>
  229. <tr>
  230. <td class="name"><code>type</code></td>
  231. <td class="type">
  232. <span class="param-type">string</span>
  233. </td>
  234. <td class="description last">The streaming type of method that this handles</td>
  235. </tr>
  236. </tbody>
  237. </table>
  238. <dl class="details">
  239. <dt class="tag-source">Source:</dt>
  240. <dd class="tag-source"><ul class="dummy"><li>
  241. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line637">line 637</a>
  242. </li></ul></dd>
  243. </dl>
  244. <h5>Returns:</h5>
  245. <div class="param-desc">
  246. True if the handler was set. False if a handler was already
  247. set for that name.
  248. </div>
  249. <dl>
  250. <dt>
  251. Type
  252. </dt>
  253. <dd>
  254. <span class="param-type">boolean</span>
  255. </dd>
  256. </dl>
  257. <h4 class="name" id="shutdown"><span class="type-signature"></span>shutdown<span class="signature">()</span><span class="type-signature"></span></h4>
  258. <div class="description">
  259. Shuts down the server.
  260. </div>
  261. <dl class="details">
  262. <dt class="tag-source">Source:</dt>
  263. <dd class="tag-source"><ul class="dummy"><li>
  264. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line619">line 619</a>
  265. </li></ul></dd>
  266. </dl>
  267. <h4 class="name" id="start"><span class="type-signature"></span>start<span class="signature">()</span><span class="type-signature"></span></h4>
  268. <div class="description">
  269. Start the server and begin handling requests
  270. </div>
  271. <h5>This:</h5>
  272. <ul><li><a href="global.html#Server">Server</a></li></ul>
  273. <dl class="details">
  274. <dt class="tag-source">Source:</dt>
  275. <dd class="tag-source"><ul class="dummy"><li>
  276. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line569">line 569</a>
  277. </li></ul></dd>
  278. </dl>
  279. </article>
  280. </section>
  281. </div>
  282. <nav>
  283. <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-src_client.html">src/client</a></li><li><a href="module-src_common.html">src/common</a></li><li><a href="module-src_server.html">src/server</a></li></ul><h3>Classes</h3><ul><li><a href="module-src_client.makeClientConstructor-Client.html">Client</a></li><li><a href="module-src_client-ClientDuplexStream.html">ClientDuplexStream</a></li><li><a href="module-src_client-ClientReadableStream.html">ClientReadableStream</a></li><li><a href="module-src_client-ClientWritableStream.html">ClientWritableStream</a></li><li><a href="module-src_server-Server.html">Server</a></li><li><a href="module-src_server-ServerDuplexStream.html">ServerDuplexStream</a></li><li><a href="module-src_server-ServerReadableStream.html">ServerReadableStream</a></li><li><a href="module-src_server-ServerWritableStream.html">ServerWritableStream</a></li></ul><h3>Global</h3><ul><li><a href="global.html#callError">callError</a></li><li><a href="global.html#Credentials">Credentials</a></li><li><a href="global.html#getGoogleAuthDelegate">getGoogleAuthDelegate</a></li><li><a href="global.html#load">load</a></li><li><a href="global.html#loadObject">loadObject</a></li><li><a href="global.html#makeGenericClientConstructor">makeGenericClientConstructor</a></li><li><a href="global.html#propagate">propagate</a></li><li><a href="global.html#Server">Server</a></li><li><a href="global.html#ServerCredentials">ServerCredentials</a></li><li><a href="global.html#status">status</a></li></ul>
  284. </nav>
  285. <br class="clear">
  286. <footer>
  287. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a> on Tue Aug 18 2015 18:25:05 GMT-0700 (PDT)
  288. </footer>
  289. <script> prettyPrint(); </script>
  290. <script src="scripts/linenumber.js"> </script>
  291. </body>
  292. </html>