mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:12:44 +00:00 
			
		
		
		
	 95559c4277
			
		
	
	
		95559c4277
		
	
	
	
	
		
			
			This patch adds a basic initial implementation of these API's. Since LibWeb currently doesn't support workers, this implementation of messaging doesn't bother with serializing and deserializing messages.
		
			
				
	
	
		
			31 lines
		
	
	
	
		
			761 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
	
		
			761 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibWeb/DOM/Document.h>
 | |
| #include <LibWeb/HTML/MessageChannel.h>
 | |
| #include <LibWeb/HTML/MessagePort.h>
 | |
| 
 | |
| namespace Web::HTML {
 | |
| 
 | |
| MessageChannel::MessageChannel(Bindings::WindowObject& global_object)
 | |
| {
 | |
|     auto& context = global_object.impl().associated_document();
 | |
| 
 | |
|     // 1. Set this's port 1 to a new MessagePort in this's relevant Realm.
 | |
|     m_port1 = MessagePort::create(context);
 | |
| 
 | |
|     // 2. Set this's port 2 to a new MessagePort in this's relevant Realm.
 | |
|     m_port2 = MessagePort::create(context);
 | |
| 
 | |
|     // 3. Entangle this's port 1 and this's port 2.
 | |
|     m_port1->entangle_with({}, *m_port2);
 | |
| }
 | |
| 
 | |
| MessageChannel::~MessageChannel()
 | |
| {
 | |
| }
 | |
| 
 | |
| }
 |