Right now, I am running a WebSocket server for my game's chat.
I developed a message format for passing messages to and from the server using JSON, like:
{ “to” : [ name0, name1, ... ], “frm” : name, “msg” : message text, “snt” : sent timestamp }
Just today, I found myself having to expand this out to include chat room invite messages also, so my current message API looks like:
{ "type" : message_type, "uri" : chat_room_uri, "cm": { “to” : [ name0, name1, ... ], “frm” : name, “msg” : message text, “snt” : sent timestamp } }
With this new message format, I can allow users to send private chat room invites using the global chat as a messaging framework, like:
{"type":"invite","uri":"/chat/s9sub73hfkjk37","cm":{}}
In your case, you could use JSON like:
{"event":event_type,"layout":layout_to_go_to} or whatever. You can craft the JSON to fit your needs exactly, then parse it using Yann 's JSON parser.