]> git.sesse.net Git - casparcg/blobdiff - protocol/amcp/AMCPProtocolStrategy.cpp
[AMCP] #475 Added special command REQ that can be prepended before any command to...
[casparcg] / protocol / amcp / AMCPProtocolStrategy.cpp
index 871f25c918d17d7d9133925f28d8e0d43c825028..39529a709f3c6380e62298a45495930d28b29b5a 100644 (file)
@@ -19,7 +19,7 @@
 * Author: Nicklas P Andersson
 */
 
+
 #include "../StdAfx.h"
 
 #include "AMCPProtocolStrategy.h"
@@ -106,7 +106,7 @@ public:
        void Parse(const std::wstring& message, ClientInfoPtr client)
        {
                CASPAR_LOG_COMMUNICATION(info) << L"Received message from " << client->address() << ": " << message << L"\\r\\n";
-       
+
                command_interpreter_result result;
                if(interpret_command_string(message, result, client))
                {
@@ -115,7 +115,7 @@ public:
                        else
                                result.queue->AddCommand(result.command);
                }
-               
+
                if (result.error != error_state::no_error)
                {
                        std::wstringstream answer;
@@ -157,6 +157,22 @@ private:
                        if (!tokens.empty() && tokens.front().at(0) == L'/')
                                tokens.pop_front();
 
+                       std::wstring request_id;
+
+                       if (boost::iequals(tokens.front(), L"REQ"))
+                       {
+                               tokens.pop_front();
+
+                               if (tokens.empty())
+                               {
+                                       result.error = error_state::parameters_error;
+                                       return false;
+                               }
+
+                               request_id = tokens.front();
+                               tokens.pop_front();
+                       }
+
                        // Fail if no more tokens.
                        if (tokens.empty())
                        {
@@ -234,6 +250,9 @@ private:
                                if (result.command->parameters().size() < result.command->minimum_parameters())
                                        result.error = error_state::parameters_error;
                        }
+
+                       if (result.command)
+                               result.command->set_request_id(std::move(request_id));
                }
                catch (std::out_of_range&)
                {