vibe.d beta banner
get vibe.d
0.8.2

Asynchronous I/O that doesn’t get in your way, written in D

Module vibe.http.websockets

Implements WebSocket support and fallbacks for older browsers.

Example

void handleConn(scope WebSocket sock)
{
	// simple echo server
	while (sock.connected) {
		auto msg = sock.receiveText();
		sock.send(msg);
	}
}

void startServer()
{
	import vibe.http.router;
	auto router = new URLRouter;
	router.get("/ws", handleWebSockets(&handleConn));

	// Start HTTP server using listenHTTP()...
}

Functions

NameDescription
connectWebSocket(url, settings)Returns a WebSocket client object that is connected to the specified host.
handleWebSocket(on_handshake, req, res)Establishes a web socket conection and passes it to the on_handshake delegate.
handleWebSockets(on_handshake)Returns a HTTP request handler that establishes web socket conections.

Classes

NameDescription
IncomingWebSocketMessageRepresents a single incoming WebSocket message as an InputStream.
OutgoingWebSocketMessageRepresents a single outgoing WebSocket message as an OutputStream.
WebSocketRepresents a single WebSocket connection.
WebSocketExceptionException thrown by vibe.http.websockets.

Structs

NameDescription
Frame

Enums

NameDescription
FrameOpcode

Aliases

NameTypeDescription
WebSocketHandshakeDelegatevoid delegate(scope WebSocket)
Authors

Jan Krüger

Copyright

© 2012-2014 RejectedSoftware e.K.

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.