CSC/ECE 517 Fall 2014/OSS M1451 ahs

From Expertiza_Wiki
Jump to navigation Jump to search

Project Topic Page

Implement the WebSocket API

This wiki page contains details on the work done for the initial step of the task of Implement WebSocket API for the Mozilla research project Servo.

Introduction

Rust <ref>http://en.wikipedia.org/wiki/Rust_(programming_language)</ref>

Rust is a curly-brace, block-structured expression language.

  • It visually resembles the C language family, but differs significantly in syntactic and semantic details.
  • Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency.
  • It supports a mixture of imperative procedural, concurrent actor, object-oriented and pure functional styles. Rust also supports generic programming and

metaprogramming, in both static and dynamic styles.

  • Example:
fn main() {
    println!("hello, world");
}

Servo <ref>http://en.wikipedia.org/wiki/Servo_(layout_engine)</ref>

Servo is an experimental web browser layout engine being developed by Mozilla.

  • The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are

handled by fine-grained, isolated tasks.

  • The project has a symbiotic relationship with the Rust programming language, in which it is being developed.
  • Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a

solid, embedded engine. Although Servo is a research project, it is designed to be "productisable"—the code that we write should be of high enough quality that it could eventually be shipped to users.

Task Architecture Diagrams<ref>https://github.com/servo/servo/wiki/Design#task-supervision-diagram</ref>

Task Supervision Diagram

Task Communication Diagram

Implementation Steps

We carried out the implementation for this project on a Mac machine. The steps we followed for the implementation are as follows:

Compiling Rust

1. The initial step to build Servo required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub using the following command:

git clone git://github.com/mozilla/rust.git
cd rust
./configure

2. Use the following commands to build the Rust compiler:

make
make check
make install

This will build and test the compiler, standard libraries, and supporting tools.

Build Servo

1. Fork the servo repository and clone the source code into the local repository using the command:

git clone https://github.com/servo/servo

2. Build servo using the following commands:

cd servo
./mach build
./mach run tests/html/about-mozilla.html

Part One Of the Project

-Created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo.

-We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project <ref>https://html.spec.whatwg.org/multipage/comms.html</ref>.

-We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor.

-We added The WebSocketTypeId to the struct in the eventtarget.rs file.

-We added the websocket module that we created to the lib.rs file.

-After making all the changes we build are changes into servo.

-Created a pull request.

Future Goals for the Project

-Create a basic connection to the server using the websocket connection protocol as specified in the protocol spec.

-In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public.

-Implement closing of connection along with on open and inclose events.

-Implement sending of short simple strings which fit within a single frame.

-Implement receiving of simple data and the on message event.

-Implement sending of fragmented data.

Design Pattern

We plan to implement the Factory<ref>http://en.wikipedia.org/wiki/Factory_(object-oriented_programming)</ref> design Pattern since our implementation of the WebSocket interface is a child of the EventTarget interface in Servo.

Appendix

-Steps for Installing Rust in detail.

-Steps for Building Servo in detail.

References

<references/>