psmtec-dklein / haxe-ws

Haxe WebSockets everywhere! Including javascript, flash and sys targets.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Haxelib Version

WebSockets everywhere! Including javascript, flash and sys targets.

class WebSocketExample {
    static public function main() {
        trace('testing!');
        var ws = WebSocket.create("ws://127.0.0.1:8000/", ['echo-protocol'], false);
        ws.onopen = function() {
            trace('open!');
            ws.sendString('hello friend!');
        };
        ws.onmessageString = function(message) {
            trace('message from server!' + message);
        };

        #if sys
        while (true) {
            ws.process();
            Sys.sleep(0.1);
        }
        #end
    }
}

About

Haxe WebSockets everywhere! Including javascript, flash and sys targets.


Languages

Language:Haxe 100.0%