console_api.html 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <!DOCTYPE html>
  2. <html class="writer-html4" lang="en" >
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>Console API &mdash; Crown 0.54.0 Manual 0.54.0 documentation</title><link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  7. <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  8. <link rel="stylesheet" href="../_static/css/custom.css" type="text/css" /><link rel="shortcut icon" href="../_static/crown-black-socket.svg"/>
  9. <!--[if lt IE 9]>
  10. <script src="../_static/js/html5shiv.min.js"></script>
  11. <![endif]-->
  12. <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
  13. <script type="text/javascript" src="../_static/jquery.js"></script>
  14. <script type="text/javascript" src="../_static/underscore.js"></script>
  15. <script type="text/javascript" src="../_static/doctools.js"></script>
  16. <script type="text/javascript" src="../_static/language_data.js"></script>
  17. <script src="../_static/js/theme.js"></script>
  18. <link rel="index" title="Index" href="../genindex.html" />
  19. <link rel="search" title="Search" href="../search.html" />
  20. <link rel="copyright" title="Copyright" href="../copyright.html" />
  21. <link rel="prev" title="Building" href="building.html" />
  22. </head>
  23. <body class="wy-body-for-nav">
  24. <div class="wy-grid-for-nav">
  25. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  26. <div class="wy-side-scroll">
  27. <div class="wy-side-nav-search" >
  28. <a href="../index.html"><img src="../_static/crown-black-socket.svg" class="logo" alt="Logo"/>
  29. </a>
  30. <div class="version">
  31. Crown 0.54.0 Manual
  32. </div>
  33. <div role="search">
  34. <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
  35. <input type="text" name="q" placeholder="Search docs" />
  36. <input type="hidden" name="check_keywords" value="yes" />
  37. <input type="hidden" name="area" value="default" />
  38. </form>
  39. </div>
  40. </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
  41. <ul class="current">
  42. <li class="toctree-l1"><a class="reference internal" href="../changelog.html">Changelog</a></li>
  43. <li class="toctree-l1"><a class="reference internal" href="../introduction.html">Introduction</a></li>
  44. <li class="toctree-l1"><a class="reference internal" href="../installing_crown/index.html">Installing Crown</a></li>
  45. <li class="toctree-l1"><a class="reference internal" href="../getting_started/index.html">Getting Started</a></li>
  46. <li class="toctree-l1"><a class="reference internal" href="../reference/index.html">Reference</a></li>
  47. <li class="toctree-l1"><a class="reference internal" href="../lua_api.html">Lua API reference</a></li>
  48. <li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
  49. <li class="toctree-l1"><a class="reference internal" href="../copyright.html">License</a></li>
  50. <li class="toctree-l1 current"><a class="reference internal" href="index.html">Hackers</a><ul class="current">
  51. <li class="toctree-l2"><a class="reference internal" href="building.html">Building</a></li>
  52. <li class="toctree-l2 current"><a class="current reference internal" href="#">Console API</a><ul>
  53. <li class="toctree-l3"><a class="reference internal" href="#tcp-protocol">TCP protocol</a></li>
  54. <li class="toctree-l3"><a class="reference internal" href="#json-messages">JSON messages</a></li>
  55. <li class="toctree-l3"><a class="reference internal" href="#execute-lua-scripts">Execute Lua scripts</a></li>
  56. </ul>
  57. </li>
  58. </ul>
  59. </li>
  60. </ul>
  61. </div>
  62. </div>
  63. </nav>
  64. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
  65. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  66. <a href="../index.html">Crown 0.54.0 Manual</a>
  67. </nav>
  68. <div class="wy-nav-content">
  69. <div class="rst-content">
  70. <div role="navigation" aria-label="Page navigation">
  71. <ul class="wy-breadcrumbs">
  72. <li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
  73. <li><a href="index.html">Hackers</a> &raquo;</li>
  74. <li>Console API</li>
  75. <li class="wy-breadcrumbs-aside">
  76. <a href="../_sources/hackers/console_api.rst.txt" rel="nofollow"> View page source</a>
  77. </li>
  78. </ul>
  79. <hr/>
  80. </div>
  81. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  82. <div itemprop="articleBody">
  83. <div class="section" id="console-api">
  84. <h1>Console API<a class="headerlink" href="#console-api" title="Permalink to this headline">¶</a></h1>
  85. <p>Any number of clients can connect to the engine via TCP/IP and communicate
  86. with simple JSON API. The default port number is 10001 as defined by <code class="docutils literal notranslate"><span class="pre">CROWN_DEFAULT_CONSOLE_PORT</span></code>.
  87. You can change the port number with <code class="docutils literal notranslate"><span class="pre">--console-port</span></code> option.</p>
  88. <div class="section" id="tcp-protocol">
  89. <h2>TCP protocol<a class="headerlink" href="#tcp-protocol" title="Permalink to this headline">¶</a></h2>
  90. <p>Every message starts with u32 header containing the size in bytes of the
  91. following JSON message.</p>
  92. </div>
  93. <div class="section" id="json-messages">
  94. <h2>JSON messages<a class="headerlink" href="#json-messages" title="Permalink to this headline">¶</a></h2>
  95. <p>Every JSON message has a <code class="docutils literal notranslate"><span class="pre">type</span></code> key which identifies its type.
  96. Sending messages with unknown <code class="docutils literal notranslate"><span class="pre">type</span></code> will result with an error message:</p>
  97. <div class="code highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  98. <span class="s2">&quot;type&quot;</span> <span class="p">:</span> <span class="s2">&quot;error&quot;</span><span class="p">,</span>
  99. <span class="s2">&quot;message&quot;</span> <span class="p">:</span> <span class="s2">&quot;Unknown command&quot;</span>
  100. <span class="p">}</span>
  101. </pre></div>
  102. </div>
  103. </div>
  104. <div class="section" id="execute-lua-scripts">
  105. <h2>Execute Lua scripts<a class="headerlink" href="#execute-lua-scripts" title="Permalink to this headline">¶</a></h2>
  106. <p>Executing Lua script is as simple as sending the following message:</p>
  107. <div class="code highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  108. <span class="s2">&quot;type&quot;</span> <span class="p">:</span> <span class="s2">&quot;script&quot;</span><span class="p">,</span>
  109. <span class="s2">&quot;script&quot;</span> <span class="p">:</span> <span class="s2">&quot;print(&#39;Hello, world!&#39;)&quot;</span>
  110. <span class="p">}</span>
  111. </pre></div>
  112. </div>
  113. <p>All the tools are controlled by sending simple Lua scripts to them.</p>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
  119. <a href="building.html" class="btn btn-neutral float-left" title="Building" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
  120. </div>
  121. <hr/>
  122. <div role="contentinfo">
  123. <p>&#169; <a href="../copyright.html">Copyright</a> Except where otherwise noted, content on this page is licensed under a CC-BY-SA 4.0 Int. License.</p>
  124. </div>
  125. Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
  126. <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
  127. provided by <a href="https://readthedocs.org">Read the Docs</a>.
  128. </footer>
  129. </div>
  130. </div>
  131. </section>
  132. </div>
  133. <script>
  134. jQuery(function () {
  135. SphinxRtdTheme.Navigation.enable(true);
  136. });
  137. </script>
  138. <!-- Theme Analytics -->
  139. <script async src="https://www.googletagmanager.com/gtag/js?id=G-XNVGCMNDZH"></script>
  140. <script>
  141. window.dataLayer = window.dataLayer || [];
  142. function gtag(){dataLayer.push(arguments);}
  143. gtag('js', new Date());
  144. gtag('config', 'G-XNVGCMNDZH', {
  145. 'anonymize_ip': true,
  146. });
  147. </script>
  148. </body>
  149. </html>