console_api.rst 896 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ===========
  2. Console API
  3. ===========
  4. Any number of clients can connect to the engine via TCP/IP and communicate
  5. with simple JSON API. The default port number is 10001 as defined by ``CROWN_DEFAULT_CONSOLE_PORT``.
  6. You can change the port number with ``--console-port`` option.
  7. TCP protocol
  8. ------------
  9. Every message starts with u32 header containing the size in bytes of the
  10. following JSON message.
  11. JSON messages
  12. -------------
  13. Every JSON message has a ``type`` key which identifies its type.
  14. Sending messages with unknown ``type`` will result with an error message:
  15. .. code::
  16. {
  17. "type" : "error",
  18. "message" : "Unknown command"
  19. }
  20. Execute Lua scripts
  21. -------------------
  22. Executing Lua script is as simple as sending the following message:
  23. .. code::
  24. {
  25. "type" : "script",
  26. "script" : "print('Hello, world!')"
  27. }
  28. All the tools are controlled by sending simple Lua scripts to them.