/****************************************************************** SendApplicationMessage - helper function to iterate through the processes for the specified application and send all applicable process Ids a message and give them time to process the message. ******************************************************************/ void SendApplicationMessage( __in LPCWSTR wzApplication, __in DWORD dwMessageId, __in DWORD dwTimeout ) { DWORD *prgProcessIds = NULL; DWORD cProcessIds = 0, iProcessId; HRESULT hr = S_OK; WcaLog(LOGMSG_VERBOSE, "Checking App: %ls ", wzApplication); hr = ProcFindAllIdsFromExeName(wzApplication, &prgProcessIds, &cProcessIds); if (SUCCEEDED(hr) && 0 < cProcessIds) { WcaLog(LOGMSG_VERBOSE, "App: %ls found running, %d processes, attempting to send message.", wzApplication, cProcessIds); for (iProcessId = 0; iProcessId < cProcessIds; ++iProcessId) { SendProcessMessage(prgProcessIds[iProcessId], dwMessageId, dwTimeout); } ProcWaitForIds(prgProcessIds, cProcessIds, dwTimeout); } ReleaseMem(prgProcessIds); }
void FWebJSScripting::UnbindUObject(const FString& Name, UObject* Object, bool bIsPermanent) { if (bIsPermanent) { // If overriding an existing permanent object, make it non-permanent if (PermanentUObjectsByName.Contains(Name) && (Object == nullptr || PermanentUObjectsByName[Name] == Object)) { Object = PermanentUObjectsByName.FindAndRemoveChecked(Name); BoundObjects.Remove(Object); return; } else { return; } } CefRefPtr<CefProcessMessage> DeleteValueMessage = CefProcessMessage::Create(TEXT("UE::DeleteValue")); CefRefPtr<CefListValue>MessageArguments = DeleteValueMessage->GetArgumentList(); CefRefPtr<CefDictionaryValue> Info = CefDictionaryValue::Create(); Info->SetString("name", *Name); Info->SetString("id", *PtrToGuid(Object).ToString(EGuidFormats::Digits)); Info->SetBool("permanent", bIsPermanent); MessageArguments->SetDictionary(0, Info); SendProcessMessage(DeleteValueMessage); }
void FWebJSScripting::BindUObject(const FString& Name, UObject* Object, bool bIsPermanent) { CefRefPtr<CefDictionaryValue> Converted = ConvertObject(Object); if (bIsPermanent) { // Each object can only have one permanent binding if (BoundObjects[Object].bIsPermanent) { return; } // Existing permanent objects must be removed first if (PermanentUObjectsByName.Contains(Name)) { return; } BoundObjects[Object]={true, -1}; PermanentUObjectsByName.Add(Name, Object); } CefRefPtr<CefProcessMessage> SetValueMessage = CefProcessMessage::Create(TEXT("UE::SetValue")); CefRefPtr<CefListValue>MessageArguments = SetValueMessage->GetArgumentList(); CefRefPtr<CefDictionaryValue> Value = CefDictionaryValue::Create(); Value->SetString("name", *Name); Value->SetDictionary("value", Converted); Value->SetBool("permanent", bIsPermanent); MessageArguments->SetDictionary(0, Value); SendProcessMessage(SetValueMessage); }
void FWebJSScripting::InvokeJSFunction(FGuid FunctionId, const CefRefPtr<CefListValue>& FunctionArguments, bool bIsError) { CefRefPtr<CefProcessMessage> Message = CefProcessMessage::Create(TEXT("UE::ExecuteJSFunction")); CefRefPtr<CefListValue> MessageArguments = Message->GetArgumentList(); MessageArguments->SetString(0, *FunctionId.ToString(EGuidFormats::Digits)); MessageArguments->SetList(1, FunctionArguments); MessageArguments->SetBool(2, bIsError); SendProcessMessage(Message); }
__declspec(dllexport) void DestroyFrame(fwString frameName) { auto procMessage = CefProcessMessage::Create("destroyFrame"); auto argumentList = procMessage->GetArgumentList(); argumentList->SetSize(1); argumentList->SetString(0, frameName.c_str()); auto rootWindow = Instance<NUIWindowManager>::Get()->GetRootWindow(); auto browser = rootWindow->GetBrowser(); browser->SendProcessMessage(PID_RENDERER, procMessage); std::unique_lock<std::shared_mutex> lock(frameListMutex); frameList.erase(frameName); }
void FWebJSScripting::InvokeJSFunction(FGuid FunctionId, int32 ArgCount, FWebJSParam Arguments[], bool bIsError) { CefRefPtr<CefListValue> FunctionArguments = CefListValue::Create(); for ( int32 i=0; i<ArgCount; i++) { SetConverted(FunctionArguments, i, Arguments[i]); } CefRefPtr<CefProcessMessage> Message = CefProcessMessage::Create(TEXT("UE::ExecuteJSFunction")); CefRefPtr<CefListValue> MessageArguments = Message->GetArgumentList(); MessageArguments->SetString(0, *FunctionId.ToString(EGuidFormats::Digits)); MessageArguments->SetList(1, FunctionArguments); MessageArguments->SetBool(2, bIsError); SendProcessMessage(Message); }