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

0 favourites
  • 2 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • 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

  • Try Construct 3

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

    Try 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)