Пример #1
0
        internal bool OnBrowserProcessMessage(CefBrowser browser, CefFrame frame, CefProcessId sourceProcess, CefProcessMessage message)
        {
            if (message.Name == PROCESS_MESSAGE_BRIDGE_MESSAGE)
            {
                var buff = message.Arguments.GetBinary(0);
                var json = Encoding.UTF8.GetString(buff.ToArray());



                var msg = BridgeMessage.FromJson(json);
                buff.Dispose();



                foreach (var handler in MessageHandlers)
                {
                    handler.OnBrowserSideMessageReceived(msg.Name, frame, msg.Arguments);
                }
                //if (ProcessMessageHandlers.ContainsKey(msg.Name))
                //{
                //    ProcessMessageHandlers[msg.Name].Invoke(this, frame, msg.Arguments);
                //}

                return(true);
            }

            return(false);
        }
Пример #2
0
        public void SendProcessMessage(CefFrame frame, BridgeMessage message)
        {
            var msg  = CefProcessMessage.Create(PROCESS_MESSAGE_BRIDGE_MESSAGE);
            var json = message.ToJson();

            msg.Arguments.SetBinary(0, CefBinaryValue.Create(Encoding.UTF8.GetBytes(json)));
            frame.SendProcessMessage(ProcessType, msg);
            msg.Dispose();
        }