mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Set the WebSocket's Sender from the ConnectionEstablishedTask.
This needs to happen off a task because we won't be able to access the WebSocket object directly once this code moves to a background thread. There is no behaviour change, because we make sure that self.ready_state is not Connecting in Send().
This commit is contained in:
parent
78df6e8d3e
commit
91849cb603
1 changed files with 4 additions and 2 deletions
|
@ -147,14 +147,13 @@ impl WebSocket {
|
|||
}
|
||||
};
|
||||
|
||||
*ws.r().sender.borrow_mut() = Some(temp_sender);
|
||||
|
||||
//Create everything necessary for starting the open asynchronous task, then begin the task.
|
||||
let global_root = ws.r().global.root();
|
||||
let addr: Trusted<WebSocket> =
|
||||
Trusted::new(global_root.r().get_cx(), ws.r(), global_root.r().script_chan().clone());
|
||||
let open_task = box ConnectionEstablishedTask {
|
||||
addr: addr,
|
||||
sender: temp_sender,
|
||||
};
|
||||
global_root.r().script_chan().send(ScriptMsg::RunnableMsg(open_task)).unwrap();
|
||||
//TODO: Spawn thread here for receive loop
|
||||
|
@ -276,12 +275,15 @@ impl<'a> WebSocketMethods for &'a WebSocket {
|
|||
/// Task queued when *the WebSocket connection is established*.
|
||||
struct ConnectionEstablishedTask {
|
||||
addr: Trusted<WebSocket>,
|
||||
sender: Sender<WebSocketStream>,
|
||||
}
|
||||
|
||||
impl Runnable for ConnectionEstablishedTask {
|
||||
fn handler(self: Box<Self>) {
|
||||
let ws = self.addr.root();
|
||||
|
||||
*ws.r().sender.borrow_mut() = Some(self.sender);
|
||||
|
||||
// Step 1: Protocols.
|
||||
|
||||
// Step 2.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue