views:

110

answers:

0

Hi everybody,

i am working on an HTML5-Application which uses WebSockets.

My WebSocketServer sends a message to the WebSocketClient. The Client should now, based on the received message, trigger an javascript function.

Here is my example-code:

socket.onmessage = function (event) {

        if (event.data == "someAction") {
            triggerSomeAction();
        }

But it does not work, a string comparison does not seem to work with event.data. Has anybody worked yet with the WebSocket API and has a solution for my problem?

Greetings derHendrik