Skip to content

[WIP] Add WebSocket Support#2075

Closed
thdxr wants to merge 3 commits intojsdom:masterfrom
ironbay:master
Closed

[WIP] Add WebSocket Support#2075
thdxr wants to merge 3 commits intojsdom:masterfrom
ironbay:master

Conversation

@thdxr
Copy link

@thdxr thdxr commented Dec 6, 2017

Fixes #1195

Opening this PR to track progress.

Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might find https://github.com/jsdom/webidl2js#writing-implementation-class-files to be helpful when writing the implementation file. Some preliminary comments below.


const events = ["open", "error", "close"];

class WebSocketImpl {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should extends EventTargetImpl, after importing EventTargetImpl from require('../events/EventTarget-impl').implementation.

const events = ["open", "error", "close"];

class WebSocketImpl {
constructor() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will have to be constructor(args, privateData), and immediately after the declaration super(args, privateData) to initialize EventTarget.

// https://html.spec.whatwg.org/multipage/web-sockets.html#the-websocket-interface

enum BinaryType { "blob", "arraybuffer" };
[Constructor(USVString url, optional (DOMString or sequence<DOMString>) protocols = []), Exposed=(Window,Worker)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is going to have to contain WebIDL2JSFactory attribute as well, since EventTarget won't function w/o a ownerDocument, which is per-window.

Basically, instead of having a shared WebSocket interface in living/index.js, you would want to create a new interface in the Window constructor. Check out f77cc1e and https://github.com/jsdom/webidl2js#webidl2jsfactory.

@TimothyGu
Copy link
Member

This is superseded by #2088.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants