@Override
    public void onMessage(MutableWebSocketFrame aFrame, WebSocketContext aContext) {
        SocketIoMessage message = decoder.decode(aFrame);
        if (LOG.isDebugEnabled()) {
            if (SocketIoMessage.Type.EVENT.equals(message.type) && message.data != null) {
                final JsonElement event = json.parse(message.data);
                LOG.debug("S-IN:\n{}", json.toPrettyJson(event));
            } else {
                LOG.debug("S-IN: {}", message);
            }
        }


        switch (message.type) {
            case HEARTBEAT:
                listener.onHeartbeat();
                sendHeartBeat();
                break;

            case EVENT:
                processEvent(listener, message);
                break;

            case CONNECT:
                // just skip it
                break;

            case DISCONNECT:
                sendConnectionClose(aContext);
                break;

            // do nothing
            case NOOP:
                break;

            // not supported yet
            case ACK:
                break;

            default:
                LOG.error("Unknown message type: {}", message);
        }

    }