From 3160d63c696612f460e5d0ebe1eb4dfb2bb3e5a1 Mon Sep 17 00:00:00 2001 From: Vincent Petithory Date: Sun, 6 Jul 2014 23:32:57 +0200 Subject: Add IPC: Manaplus now accepts connections on the 44007 port. * Uses SDL_Net/SDL_Thread. * Port can be changed with envvar IPC_PORT. * Default port is first checked then incremented until one is available. * start on demand with /ipctoggle (shuts down server socket) It has a simple text protocol: TYPE arg1 [args]... Message types: * CMD: execs a command supported by manaplus, e.g /emote * LTALK: talks in general tab * TALK: talks in current focused tab * [TODO] KEY: do as if the KEY was pressed on keyboard --- src/commands.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/commands.cpp') diff --git a/src/commands.cpp b/src/commands.cpp index 94781aef5..00da06cbb 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -63,6 +63,7 @@ #include "net/download.h" #include "net/gamehandler.h" #include "net/guildhandler.h" +#include "net/ipc.h" #include "net/net.h" #include "net/uploadcharinfo.h" #include "net/partyhandler.h" @@ -289,6 +290,26 @@ impHandler2(help) helpWindow->requestMoveToTop(); } +impHandler0(ipcToggle) +{ + if (ipc) + { + IPC::stop(); + if (!ipc) + debugChatTab->chatLog("IPC service stopped."); + else + debugChatTab->chatLog("Unable to stop IPC service."); + } + else + { + IPC::start(); + if (ipc) + debugChatTab->chatLog(strprintf("IPC service available on port %d", ipc->port())); + else + debugChatTab->chatLog("Unable to start IPC service"); + } +} + impHandler2(where) { std::ostringstream where; -- cgit v1.2.3-70-g09d2