module-src_server-Server.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275
  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#line585">line 585</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#line745">line 745</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#line702">line 702</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#line756">line 756</a>
  182. </li></ul></dd>
  183. </dl>
  184. <h4 class="name" id="forceShutdown"><span class="type-signature"></span>forceShutdown<span class="signature">()</span><span class="type-signature"></span></h4>
  185. <div class="description">
  186. Forcibly shuts down the server. The server will stop receiving new calls
  187. and cancel all pending calls. When it returns, the server has shut down.
  188. This method is idempotent with itself and tryShutdown, and it will trigger
  189. any outstanding tryShutdown callbacks.
  190. </div>
  191. <dl class="details">
  192. <dt class="tag-source">Source:</dt>
  193. <dd class="tag-source"><ul class="dummy"><li>
  194. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line661">line 661</a>
  195. </li></ul></dd>
  196. </dl>
  197. <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>
  198. <div class="description">
  199. Registers a handler to handle the named method. Fails if there already is
  200. a handler for the given method. Returns true on success
  201. </div>
  202. <h5>Parameters:</h5>
  203. <table class="params">
  204. <thead>
  205. <tr>
  206. <th>Name</th>
  207. <th>Type</th>
  208. <th class="last">Description</th>
  209. </tr>
  210. </thead>
  211. <tbody>
  212. <tr>
  213. <td class="name"><code>name</code></td>
  214. <td class="type">
  215. <span class="param-type">string</span>
  216. </td>
  217. <td class="description last">The name of the method that the provided function should
  218. handle/respond to.</td>
  219. </tr>
  220. <tr>
  221. <td class="name"><code>handler</code></td>
  222. <td class="type">
  223. <span class="param-type">function</span>
  224. </td>
  225. <td class="description last">Function that takes a stream of request values and
  226. returns a stream of response values</td>
  227. </tr>
  228. <tr>
  229. <td class="name"><code>serialize</code></td>
  230. <td class="type">
  231. <span class="param-type">function</span>
  232. </td>
  233. <td class="description last">Serialization function for responses</td>
  234. </tr>
  235. <tr>
  236. <td class="name"><code>deserialize</code></td>
  237. <td class="type">
  238. <span class="param-type">function</span>
  239. </td>
  240. <td class="description last">Deserialization function for requests</td>
  241. </tr>
  242. <tr>
  243. <td class="name"><code>type</code></td>
  244. <td class="type">
  245. <span class="param-type">string</span>
  246. </td>
  247. <td class="description last">The streaming type of method that this handles</td>
  248. </tr>
  249. </tbody>
  250. </table>
  251. <dl class="details">
  252. <dt class="tag-source">Source:</dt>
  253. <dd class="tag-source"><ul class="dummy"><li>
  254. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line679">line 679</a>
  255. </li></ul></dd>
  256. </dl>
  257. <h5>Returns:</h5>
  258. <div class="param-desc">
  259. True if the handler was set. False if a handler was already
  260. set for that name.
  261. </div>
  262. <dl>
  263. <dt>
  264. Type
  265. </dt>
  266. <dd>
  267. <span class="param-type">boolean</span>
  268. </dd>
  269. </dl>
  270. <h4 class="name" id="start"><span class="type-signature"></span>start<span class="signature">()</span><span class="type-signature"></span></h4>
  271. <div class="description">
  272. Start the server and begin handling requests
  273. </div>
  274. <h5>This:</h5>
  275. <ul><li><a href="global.html#Server">Server</a></li></ul>
  276. <dl class="details">
  277. <dt class="tag-source">Source:</dt>
  278. <dd class="tag-source"><ul class="dummy"><li>
  279. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line595">line 595</a>
  280. </li></ul></dd>
  281. </dl>
  282. <h4 class="name" id="tryShutdown"><span class="type-signature"></span>tryShutdown<span class="signature">(callback)</span><span class="type-signature"></span></h4>
  283. <div class="description">
  284. Gracefully shuts down the server. The server will stop receiving new calls,
  285. and any pending calls will complete. The callback will be called when all
  286. pending calls have completed and the server is fully shut down. This method
  287. is idempotent with itself and forceShutdown.
  288. </div>
  289. <h5>Parameters:</h5>
  290. <table class="params">
  291. <thead>
  292. <tr>
  293. <th>Name</th>
  294. <th>Type</th>
  295. <th class="last">Description</th>
  296. </tr>
  297. </thead>
  298. <tbody>
  299. <tr>
  300. <td class="name"><code>callback</code></td>
  301. <td class="type">
  302. <span class="param-type">function</span>
  303. </td>
  304. <td class="description last">The shutdown complete callback</td>
  305. </tr>
  306. </tbody>
  307. </table>
  308. <dl class="details">
  309. <dt class="tag-source">Source:</dt>
  310. <dd class="tag-source"><ul class="dummy"><li>
  311. <a href="src_server.js.html">src/server.js</a>, <a href="src_server.js.html#line651">line 651</a>
  312. </li></ul></dd>
  313. </dl>
  314. </article>
  315. </section>
  316. </div>
  317. <nav>
  318. <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_metadata.html">src/metadata</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_metadata-Metadata.html">Metadata</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#getClientChannel">getClientChannel</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#Metadata">Metadata</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><li><a href="global.html#waitForClientReady">waitForClientReady</a></li><li><a href="global.html#writeFlags">writeFlags</a></li></ul>
  319. </nav>
  320. <br class="clear">
  321. <footer>
  322. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.3</a> on Thu Oct 29 2015 13:07:25 GMT-0700 (PDT)
  323. </footer>
  324. <script> prettyPrint(); </script>
  325. <script src="scripts/linenumber.js"> </script>
  326. </body>
  327. </html>