AwaError AwaServerListClientsOperation_Perform(AwaServerListClientsOperation * operation, AwaTimeout timeout)
{
    AwaError result = AwaError_Unspecified;

    if (timeout >= 0)
    {
        if (operation != NULL)
        {
            // build an IPC message and inject our content (object paths) into it
            IPCMessage * request = IPCMessage_NewPlus(IPC_MESSAGE_TYPE_REQUEST, IPC_MESSAGE_SUB_TYPE_LIST_CLIENTS, ServerOperation_GetSessionID(operation->ServerOperation));
            IPCMessage * response = NULL;

            // a timeout of 0 means an infinite timeout
            result = IPC_SendAndReceive(ServerSession_GetChannel(ServerOperation_GetSession(operation->ServerOperation)), request, &response, timeout);

            if (result == AwaError_Success)
            {
                IPCResponseCode responseCode = IPCMessage_GetResponseCode(response);
                if (responseCode == IPCResponseCode_Success)
                {
                    // Free an old Clients record if it exists
                    if (operation->ServerResponse != NULL)
                    {
                        ServerResponse_Free(&operation->ServerResponse);
                    }

                    // Detach the response's content and add it to the Server Response
                    TreeNode contentNode = IPCMessage_GetContentNode(response);
                    TreeNode clientsNode = Xml_Find(contentNode, "Clients");
                    operation->ServerResponse = ServerResponse_NewFromServerOperation(operation->ServerOperation, clientsNode);

                    // if there are any cached Responses, free them
                    Map_FreeValues(operation->ClientResponseMap);

                    LogDebug("Perform ListClients Operation successful");
                    result = AwaError_Success;
                }
                else if (responseCode == IPCResponseCode_FailureBadRequest)
                {
                    result = LogErrorWithEnum(AwaError_IPCError, "Unable to perform List Clients operation");
                }
                else
                {
                    result = LogErrorWithEnum(AwaError_IPCError, "Unexpected IPC response code: %d", responseCode);
                }
            }

            IPCMessage_Free(&request);
            IPCMessage_Free(&response);
        }
        else
        {
            result = LogErrorWithEnum(AwaError_OperationInvalid, "Operation is NULL");
        }
    }
    else
    {
        result = LogErrorWithEnum(AwaError_OperationInvalid, "Invalid timeout specified");
    }
    return result;
}
AwaError AwaServerExecuteOperation_Perform(AwaServerExecuteOperation * operation, AwaTimeout timeout)
{
    AwaError result = AwaError_Unspecified;

    if (timeout >= 0)
    {
        if (operation != NULL)
        {
            const AwaServerSession * session = ServerOperation_GetSession(operation->ServerOperation);
            if (session != NULL)
            {
                if (ServerSession_IsConnected(session))
                {
                    TreeNode clientsTree = ServerOperation_GetClientsTree(operation->ServerOperation);
                    if (clientsTree != NULL)
                    {
                        if (TreeNode_GetChildCount(clientsTree) > 0)
                        {
                            // build an IPC message and inject our content into it
                            IPCMessage * request = IPCMessage_NewPlus(IPC_MESSAGE_TYPE_REQUEST, IPC_MESSAGE_SUB_TYPE_EXECUTE, ServerOperation_GetSessionID(operation->ServerOperation));

                            // Add Content to message
                            IPCMessage_AddContent(request, clientsTree);

                            // Send via IPC
                            IPCMessage * response = NULL;
                            result = IPC_SendAndReceive(ServerSession_GetChannel(session), request, &response, timeout);

                            // Process the response
                            if (result == AwaError_Success)
                            {
                                IPCResponseCode responseCode = IPCMessage_GetResponseCode(response);
                                if (responseCode == IPCResponseCode_Success)
                                {
                                    // Free an old Execute response record if it exists
                                    if (operation->Response != NULL)
                                    {
                                        ServerResponse_Free(&operation->Response);
                                    }

                                    // Detach the response's content and add it to the Server Response
                                    TreeNode contentNode = IPCMessage_GetContentNode(response);
                                    TreeNode clientsNode = Xml_Find(contentNode, "Clients");
                                    operation->Response = ServerResponse_NewFromServerOperation(operation->ServerOperation, clientsNode);

                                    LogDebug("Perform Execute Operation successful");

                                    result = ServerResponse_CheckForErrors(operation->Response);
                                }
                                else if (responseCode == IPCResponseCode_FailureBadRequest)
                                {
                                    result = LogErrorWithEnum(AwaError_IPCError, "Unable to perform Execute operation: Bad Request");
                                }
                                else
                                {
                                    result = LogErrorWithEnum(AwaError_IPCError, "Unexpected IPC response code: %d", responseCode);
                                }
                            }

                            IPCMessage_Free(&request);
                            IPCMessage_Free(&response);
                        }
                        else
                        {
                            result = LogErrorWithEnum(AwaError_OperationInvalid, "No paths specified");
                        }
                    }
                    else
                    {
                        result = LogErrorWithEnum(AwaError_Internal, "objectsTree is NULL");
                    }
                }
                else
                {
                    result = LogErrorWithEnum(AwaError_SessionNotConnected, "session is not connected");
                }
            }
            else
            {
                result = LogErrorWithEnum(AwaError_SessionInvalid, "session is NULL");
            }
        }
        else
        {
            result = LogErrorWithEnum(AwaError_OperationInvalid, "Operation is NULL");
        }
    }
    else
    {
        result = LogErrorWithEnum(AwaError_OperationInvalid, "Invalid timeout specified");
    }
    return result;
}