Provides basic command handling functionality for unix socket commands.
Provides default functionality for handling unix socket commands.
Boost Software License Version 1.0. See LICENSE_BOOST.txt for details. Alternatively, this file may be distributed under the terms of the Tango 3-Clause BSD License (see LICENSE_BSD.txt for details).
Copyright (c) 2009-2016 dunnhumby Germany GmbH. All rights reserved.
Unix domain socket connection handler
The connection handler expects the client to send UTF-8 text data in the form of '\n'-separated lines. Each line starts with a command. The command is terminated with either a linebreak '\n' or a space ' '. If it is terminated with a space then the rest of the line are the arguments for the command. Whitespace at the beginning of the line, command and arguments is trimmed. Examples:
"my-cmd\n" -- command = "my-cmd", arguments = "" " my-cmd \n" -- ditto "my-cmd arg1 arg2\n" -- command = "my-cmd", arguments = "arg1 arg2" " my-cmd arg1 arg2 \n" -- ditto
Empty lines or lines containing only white space are ignored.
The constructor takes a command handler that must contain a method matching
where command is the name of the command (as explained above), args is everything after the command and send_response sends the response string to the client. Note that the response should end in a '\n' newline character, which is not automatically added.