| 86 | } |
| 87 | |
| 88 | ElementXML_Handle sml_ProcessMessage(Connection_Receiver_Handle hReceiverConnection, ElementXML_Handle hIncomingMsg, int action) |
| 89 | { |
| 90 | EmbeddedConnection* pConnection = GetConnectionFromHandle(hReceiverConnection) ; |
| 91 | |
| 92 | if (action == SML_MESSAGE_ACTION_CLOSE) |
| 93 | { |
| 94 | if (pConnection) |
| 95 | { |
| 96 | // Close our connection to the remote process |
| 97 | pConnection->ClearConnectionHandle() ; |
| 98 | |
| 99 | // When the embedded connection disconnects we're about to exit the application |
| 100 | // so shutdown any remote connections cleanly and do any other cleanup. |
| 101 | KernelSML* pKernelSML = reinterpret_cast<KernelSML*>(pConnection->GetUserData()); |
| 102 | assert(pKernelSML); |
| 103 | pKernelSML->Shutdown() ; |
| 104 | |
| 105 | // The shutdown call above will also delete our connection object as part of its cleanup |
| 106 | // so set it to NULL here to make sure we don't try to use it again. |
| 107 | pConnection = NULL ; |
| 108 | |
| 109 | delete pKernelSML; |
| 110 | } |
| 111 | |
| 112 | return NULL ; |
| 113 | } |
| 114 | |
| 115 | if (action == SML_MESSAGE_ACTION_SYNCH) |
| 116 | { |
| 117 | // Create an object to wrap this message. |
| 118 | // When this object is deleted, it releases our reference to this handle. |
| 119 | soarxml::ElementXML incomingMsg(hIncomingMsg) ; |
| 120 | |
| 121 | soarxml::ElementXML* pResponse = pConnection->InvokeCallbacks(&incomingMsg) ; |
| 122 | |
| 123 | if (!pResponse) |
| 124 | { |
| 125 | return NULL ; |
| 126 | } |
| 127 | |
| 128 | ElementXML_Handle hResponse = pResponse->Detach() ; |
| 129 | delete pResponse ; |
| 130 | return hResponse ; |
| 131 | } |
| 132 | |
| 133 | if (action == SML_MESSAGE_ACTION_ASYNCH) |
| 134 | { |
| 135 | // Store the incoming message on a queue and execute it on the receiver's thread (our thread) at a later point. |
| 136 | EmbeddedConnectionAsynch* eca = static_cast<EmbeddedConnectionAsynch*>(pConnection); |
| 137 | eca->AddToIncomingMessageQueue(hIncomingMsg) ; |
| 138 | |
| 139 | // There is no immediate response to an asynch message. |
| 140 | // The response will be sent back to the caller as another asynch message later, once the command has been executed. |
| 141 | return NULL ; |
| 142 | } |
| 143 | |
| 144 | if (action == SML_MESSAGE_ACTION_TRACE_ON || action == SML_MESSAGE_ACTION_TRACE_OFF) |
| 145 | { |
nothing calls this directly
no test coverage detected