| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <!DOCTYPE html>
- <html class="writer-html5" lang="en" >
- <head>
- <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
- <meta property="article:modified_time" content="2017-10-28T12:25:25+00:00" /><meta property="og:title" content="Console API" />
- <meta property="og:type" content="website" />
- <meta property="og:url" content="https://docs.crownengine.org/html/latest/hackers/console_api.html" />
- <meta property="og:site_name" content="Crown 0.60.0 Manual" />
- <meta property="og:description" content="Any number of clients can connect to the engine via TCP/IP and communicate with simple JSON API. The default port number is 10001 as defined by CROWN_DEFAULT_CONSOLE_PORT. You can change the port number with--console-port option. TCP protocol: Every message starts with u32 hea..." />
- <meta name="description" content="Any number of clients can connect to the engine via TCP/IP and communicate with simple JSON API. The default port number is 10001 as defined by CROWN_DEFAULT_CONSOLE_PORT. You can change the port number with--console-port option. TCP protocol: Every message starts with u32 hea..." />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>Console API — Crown 0.60.0 Manual 0.61.0 documentation</title>
- <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
- <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
- <link rel="stylesheet" href="../_static/css/custom.css" type="text/css" />
- <link rel="shortcut icon" href="../_static/org.crownengine.Crown.svg"/>
- <link rel="canonical" href="https://docs.crownengine.org/html/latest/hackers/console_api.html" />
- <!--[if lt IE 9]>
- <script src="../_static/js/html5shiv.min.js"></script>
- <![endif]-->
-
- <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
- <script src="../_static/jquery.js"></script>
- <script src="../_static/underscore.js"></script>
- <script src="../_static/doctools.js"></script>
- <script src="../_static/js/theme.js"></script>
- <link rel="index" title="Index" href="../genindex.html" />
- <link rel="search" title="Search" href="../search.html" />
- <link rel="copyright" title="Copyright" href="../copyright.html" />
- <link rel="prev" title="Building" href="building.html" />
- </head>
- <body class="wy-body-for-nav">
- <div class="wy-grid-for-nav">
- <nav data-toggle="wy-nav-shift" class="wy-nav-side">
- <div class="wy-side-scroll">
- <div class="wy-side-nav-search" >
- <a href="../index.html">
- <img src="../_static/org.crownengine.Crown.svg" class="logo" alt="Logo"/>
- </a>
- <div class="version">
- Crown 0.60.0 Manual
- </div>
- <div role="search">
- <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
- <input type="text" name="q" placeholder="Search docs" />
- <input type="hidden" name="check_keywords" value="yes" />
- <input type="hidden" name="area" value="default" />
- </form>
- </div>
- </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
- <ul class="current">
- <li class="toctree-l1"><a class="reference internal" href="../changelog.html">Changelog</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../introduction.html">Introduction</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../installing_crown/index.html">Installing Crown</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../getting_started/index.html">Getting Started</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../importing_resources/index.html">Importing Resources</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../gameplay/index.html">Writing Gameplay</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../deploying/index.html">Deploying</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../reference/index.html">Reference</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../lua_api.html">Lua API reference</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../copyright.html">License</a></li>
- <li class="toctree-l1 current"><a class="reference internal" href="index.html">Hackers</a><ul class="current">
- <li class="toctree-l2"><a class="reference internal" href="building.html">Building</a></li>
- <li class="toctree-l2 current"><a class="current reference internal" href="#">Console API</a><ul>
- <li class="toctree-l3"><a class="reference internal" href="#tcp-protocol">TCP protocol</a></li>
- <li class="toctree-l3"><a class="reference internal" href="#json-messages">JSON messages</a></li>
- <li class="toctree-l3"><a class="reference internal" href="#execute-lua-scripts">Execute Lua scripts</a></li>
- </ul>
- </li>
- </ul>
- </li>
- </ul>
- </div>
- </div>
- </nav>
- <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
- <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
- <a href="../index.html">Crown 0.60.0 Manual</a>
- </nav>
- <div class="wy-nav-content">
- <div class="rst-content">
- <div role="navigation" aria-label="Page navigation">
- <ul class="wy-breadcrumbs">
- <li><a href="../index.html" class="icon icon-home"></a> »</li>
- <li><a href="index.html">Hackers</a> »</li>
- <li>Console API</li>
- <li class="wy-breadcrumbs-aside">
- <a href="../_sources/hackers/console_api.rst.txt" rel="nofollow"> View page source</a>
- </li>
- </ul>
- <hr/>
- </div>
- <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
- <div itemprop="articleBody">
-
- <section id="console-api">
- <h1>Console API<a class="headerlink" href="#console-api" title="Permalink to this headline">¶</a></h1>
- <p>Any number of clients can connect to the engine via TCP/IP and communicate
- 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>.
- You can change the port number with <code class="docutils literal notranslate"><span class="pre">--console-port</span></code> option.</p>
- <section id="tcp-protocol">
- <h2>TCP protocol<a class="headerlink" href="#tcp-protocol" title="Permalink to this headline">¶</a></h2>
- <p>Every message starts with u32 header containing the size in bytes of the
- following JSON message.</p>
- </section>
- <section id="json-messages">
- <h2>JSON messages<a class="headerlink" href="#json-messages" title="Permalink to this headline">¶</a></h2>
- <p>Every JSON message has a <code class="docutils literal notranslate"><span class="pre">type</span></code> key which identifies its type.
- Sending messages with unknown <code class="docutils literal notranslate"><span class="pre">type</span></code> will result with an error message:</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
- <span class="s2">"type"</span> <span class="p">:</span> <span class="s2">"error"</span><span class="p">,</span>
- <span class="s2">"message"</span> <span class="p">:</span> <span class="s2">"Unknown command"</span>
- <span class="p">}</span>
- </pre></div>
- </div>
- </section>
- <section id="execute-lua-scripts">
- <h2>Execute Lua scripts<a class="headerlink" href="#execute-lua-scripts" title="Permalink to this headline">¶</a></h2>
- <p>Executing Lua script is as simple as sending the following message:</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
- <span class="s2">"type"</span> <span class="p">:</span> <span class="s2">"script"</span><span class="p">,</span>
- <span class="s2">"script"</span> <span class="p">:</span> <span class="s2">"print('Hello, world!')"</span>
- <span class="p">}</span>
- </pre></div>
- </div>
- <p>All the tools are controlled by sending simple Lua scripts to them.</p>
- </section>
- </section>
- </div>
- </div>
- <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
- <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>
- </div>
- <hr/>
- <div role="contentinfo">
- <p>© <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.
- <span class="lastupdated">Last updated on Oct 28, 2017.
- </span></p>
- </div>
- Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
- <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
- provided by <a href="https://readthedocs.org">Read the Docs</a>.
-
- </footer>
- </div>
- </div>
- </section>
- </div>
- <script>
- jQuery(function () {
- SphinxRtdTheme.Navigation.enable(true);
- });
- </script>
- <!-- Theme Analytics -->
- <script async src="https://www.googletagmanager.com/gtag/js?id=G-XNVGCMNDZH"></script>
- <script>
- window.dataLayer = window.dataLayer || [];
- function gtag(){dataLayer.push(arguments);}
- gtag('js', new Date());
- gtag('config', 'G-XNVGCMNDZH', {
- 'anonymize_ip': true,
- });
- </script>
- </body>
- </html>
|