Skip to content

w3c-jseverywhere/websocket-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

#WebSocket Server API#

This repository is the home of the Web Socket Server API specification being worked on by the Client and Server JavaScript APIs Community Group for Packaged Web apps and Server-Side JS implementations. This API is considered for implementation in Wakanda Server

##Concepts##

This specification reuse concepts and content from the following W3C recommendations or Draft:

In Short, the proposed WebSocketServer interface looks like the WebSocketinterface but messaging behave with the SharedWorker port mechanism.

##How to use?##

###Dedicated Socket Workers###

var webSocketMetaData = self.webSocket;

self.onmessage = function (msgEvent) {
	self.postMessage(message);
};

###Shared Socket Workers###

self.onconnect = function handleClient(event) {
	var port = event.ports[0];
	var webSocketMetaData = event.webSocket;

	// handle client messages
	port.onmessage = function handleMessage(msgEvent) {
		// send a message to a specific client
		port.postMessage(message);
	}
};

##Interfaces##

Interface WebSocketServer {
	void addWebSocketHandler(String workerPath, String id, Boolean dedicatedOrShared)
	void removeWebSocketHandler(String id)
}
Interface WebSocketWorkerScope: DedicatedWorkerGlobalScope {
	readonly attribute WebSocketMeta webSocket
}
Interface WebSocketSharedWorkerScope: SharedWorkerGlobalScope {
}
Interface WebSocketMeta {

  readonly attribute DOMString url;

  // ready state
  const unsigned short CONNECTING = 0;
  const unsigned short OPEN = 1;
  const unsigned short CLOSING = 2;
  const unsigned short CLOSED = 3;
  readonly attribute unsigned short readyState;
  readonly attribute unsigned long bufferedAmount;

  // networking
  readonly attribute DOMString extensions;
  readonly attribute DOMString protocol;

  // messaging
           attribute DOMString binaryType;
}

It is possible to connect to WebSocket SharedWorkers using the standard SharedWorker constructor with the same ID. In this situation the event parameter of the 'onconnect' handler won't have the specific "webSocket" property

##How to contribute?##

Every one is welcome to contribute to this specification. If not already a member, start by joining the community group, which is open to anyone, and present yourself community group mailing list. Then create an issue on the github repository and mention it in another amail to the mailing list. You may join a pull request with edition suggestions.

##Useful links##

About

Web Socket Server API for Packaged apps and Server-Side JS implementations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published