-
-
Notifications
You must be signed in to change notification settings - Fork 3k
WebSocket student project
Background information: The WebSocket technology in web browsers is relatively new, and addresses the lack of arbitrary TCP/UDP connections from JS in web pages. The protocol to connect to a server is well-specified, as is the protocol to sending and receiving data, but the nature of the data being sent/received is completely up to the web page and server. Implementing the API for web pages to interact with a WebSocket server will allow Servo to run more interesting web apps.
Initial step: Build Servo, then email the mozilla.dev.servo mailing list introducing your group. Make the script
crate depend on the rust-websocket (docs) library (modify its Cargo.toml as described in the documentation), and make a connection with a given server URL in the constructor (using the example as a reference). Implement the readyState
attribute by uncommenting it from WebSocket.webidl
and adding the appropriate missing getters. Use the similar implementation in components/script/dom/xmlhttprequest.rs
as a reference.
Subsequent steps:
- Make the connection occur asynchronously by immediately spawning a new thread which creates the
Client
, makes the request and obtains the response. Send aRunnable
message to the script task that contains the result of the connection (along with the resulting sender if it was successful). - Implement the feedback for establishing a connection as described by the spec.
- Implement sending data using the sender obtained in the original async message from the other thread.
- Implement receiving simple data using the receiver in the other thread. Following the steps in the spec, dispatch an asynchronous event to the script task that invokes the
onmessage
handler. - Implement connection closing per the spec.
- Pass tests by adding the websockets test directory to the list in tests/wpt/include.ini and running them using
./mach test tests/wpt/web-platform-tests/websockets
.