0 Favourites

How do I use messages from websocket server in construct 2?

  • I want to do:

    websocket On message => if message: "login" or "other message from server" go to Layout xx1

    Or how can I messages from server via websocket use to trigger events?

    sorry for my bad english

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic Locked topic
0 Favourites
Construct 3 any news?
889 125,650
uzumiapps's avatar
uzumiapps
Unread hot topic
353 32,116
yojona's avatar
yojona
Unread hot topic
313 26,517
Juryiel's avatar
Juryiel