mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
move websocket creation to resource task
This commit is contained in:
parent
9f9d3570fc
commit
e8c8277f34
10 changed files with 234 additions and 101 deletions
|
@ -23,6 +23,7 @@ extern crate serde;
|
|||
extern crate stb_image;
|
||||
extern crate url;
|
||||
extern crate util;
|
||||
extern crate websocket;
|
||||
|
||||
use hyper::header::{ContentType, Headers};
|
||||
use hyper::http::RawStatus;
|
||||
|
@ -225,10 +226,43 @@ pub enum IncludeSubdomains {
|
|||
NotIncluded
|
||||
}
|
||||
|
||||
#[derive(HeapSizeOf, Deserialize, Serialize)]
|
||||
pub enum MessageData {
|
||||
Text(String),
|
||||
Binary(Vec<u8>),
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum WebSocketDomAction {
|
||||
SendMessage(MessageData),
|
||||
Close(u16, String),
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum WebSocketNetworkEvent {
|
||||
ConnectionEstablished,
|
||||
MessageReceived(MessageData),
|
||||
Close,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct WebSocketCommunicate {
|
||||
pub event_sender: IpcSender<WebSocketNetworkEvent>,
|
||||
pub action_receiver: IpcReceiver<WebSocketDomAction>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct WebSocketConnectData {
|
||||
pub resource_url: Url,
|
||||
pub origin: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum ControlMsg {
|
||||
/// Request the data associated with a particular URL
|
||||
Load(LoadData, LoadConsumer, Option<IpcSender<ResourceId>>),
|
||||
/// Try to make a websocket connection to a URL.
|
||||
WebsocketConnect(WebSocketCommunicate, WebSocketConnectData),
|
||||
/// Store a set of cookies for a given originating URL
|
||||
SetCookiesForUrl(Url, String, CookieSource),
|
||||
/// Retrieve the stored cookies for a given URL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue