websocket

HTML5 websocket support for sys platforms. Unblocked and threaded servers for neko.
https://bitbucket.org/yar3333/haxe-websocket

To install, run:

haxelib install websocket 2.0.2 

See using Haxelib in Haxelib documentation for more information.

README.md

websocket

WebSocket implementation for sys platforms. Unblocked and threaded servers for neko.

Example

See tests folder. Quick code below:

// Haxe / Neko

class MyConnection extends neko.net.WebSocketServerLoop.ClientData
{
	// your custom fields if you need data associated to each connection
}

class Main
{
	static function main()
	{
		var serverLoop = new neko.net.WebSocketServerLoop<MyConnection>(function(socket) return new MyConnection(socket));
		
		serverLoop.processIncomingMessage = function(connection:MyConnection, message:String)
		{
			trace("Incoming: " + message);
			// use "connection.ws" to send answer
			// use "serverLoop.closeConnection(connection.ws.socket)" to close connection and remove socket from processing
		};
		
		serverLoop.run(new Host("localhost"), 5121);   
	}
}
// JavaScript or Haxe

var ws = new WebSocket("ws://localhost:5121"); // use native js WebSocket class (js.html.WebSocket in haxe)
ws.onopen = function()
{
	console.log("CONNECT");
	ws.send("TestString");
};
ws.onmessage = function(e)
{
	console.log("RECEIVE: " + e.data);
};
ws.onclose = function()
{
	console.log("DISCONNECT");
};
Contributors
yar3333
Version
2.0.2
Published
2 years ago
License
LGPL

All libraries are free

Every month, more than thousand developers use haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on Github!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on Github