virtual result Construct(void);
- result SendMessage(int clientId, const BundleBuffer& buffer);
+ result SendMessage(int clientId, const BundleBuffer& metadata, const BundleBuffer& buffer);
void SetMessagePortService(_MessagePortService& service);
bool OnCheckRemotePort(const BundleBuffer& buffer, int* pResult);
- bool OnSendMessage(const BundleBuffer& buffer, int* pResult);
+ bool OnSendMessage(const BundleBuffer& metadata, const BundleBuffer& buffer, int* pResult);
virtual void OnIpcRequestReceived(IpcServer& server, const IPC::Message& message);
if (trusted.Equals(L"TRUE", false))
{
- String localAppId = bundle_get_val(buffer.b, LOCAL_APPID);
- String remoteAppId = bundle_get_val(buffer.b, REMOTE_APPID);
+ String localAppId = bundle_get_val(b, LOCAL_APPID);
+ String remoteAppId = bundle_get_val(b, REMOTE_APPID);
// Check the preloaded
if (!IsPreloaded(localAppId, remoteAppId))
}
int
-_MessagePortService::SendMessage(const BundleBuffer& buffer)
+_MessagePortService::SendMessage(const BundleBuffer& metadata, const BundleBuffer& buffer)
{
result r = E_SUCCESS;
int clientId = 0;
- bundle* b = buffer.b;
+ bundle* b = metadata.b;
- String key = GetKey(buffer, false);
+ String key = GetKey(metadata, false);
SysLog(NID_IO, "Sends a message to a remote message port [%ls]", key.GetPointer());
String trustedMessage(bundle_get_val(b, TRUSTED_MESSAGE));
if (trustedMessage.Equals(L"TRUE", false))
{
- String localAppId = bundle_get_val(buffer.b, LOCAL_APPID);
- String remoteAppId = bundle_get_val(buffer.b, REMOTE_APPID);
+ String localAppId = bundle_get_val(b, LOCAL_APPID);
+ String remoteAppId = bundle_get_val(b, REMOTE_APPID);
// Check the preloaded
if (!IsPreloaded(localAppId, remoteAppId))
}
}
- r = __pStub->SendMessage(clientId, buffer);
+ r = __pStub->SendMessage(clientId, metadata, buffer);
SysTryReturn(NID_IO, r == E_SUCCESS, MESSAGEPORT_ERROR_IO_ERROR, E_SYSTEM,
"[E_SYSTEM] Failed to send a message.");
const char* pAppId = null;
const char* pPortName = null;
+ bundle* b = buffer.b;
+
if (local)
{
- pAppId = bundle_get_val(buffer.b, LOCAL_APPID);
- pPortName = bundle_get_val(buffer.b, LOCAL_PORT);
+ pAppId = bundle_get_val(b, LOCAL_APPID);
+ pPortName = bundle_get_val(b, LOCAL_PORT);
}
else
{
- pAppId = bundle_get_val(buffer.b, REMOTE_APPID);
- pPortName = bundle_get_val(buffer.b, REMOTE_PORT);
+ pAppId = bundle_get_val(b, REMOTE_APPID);
+ pPortName = bundle_get_val(b, REMOTE_PORT);
}
String key(pAppId);
}
bool
-_MessagePortStub::OnSendMessage(const BundleBuffer& buffer, int* pResult)
+_MessagePortStub::OnSendMessage(const BundleBuffer& metadata, const BundleBuffer& buffer, int* pResult)
{
SysAssertf(__pService != null, "MessagePort service has not been initialized.\n");
- *pResult = __pService->SendMessage(buffer);
+ *pResult = __pService->SendMessage(metadata, buffer);
+ bundle_free(metadata.b);
bundle_free(buffer.b);
return true;
}
result
-_MessagePortStub::SendMessage(int clientId, const BundleBuffer& buffer)
+_MessagePortStub::SendMessage(int clientId, const BundleBuffer& metadata, const BundleBuffer& buffer)
{
SysAssertf(__pService != null, "MessagePort service has not been initialized.\n");
- result r = __pIpcServer->SendResponse(clientId, new MessagePort_sendMessageAsync(buffer));
+ result r = __pIpcServer->SendResponse(clientId, new MessagePort_sendMessageAsync(metadata, buffer));
SysTryReturnResult(NID_IO, r == E_SUCCESS, r, "Failed to send a response message.");