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

Get help using Construct 2

Post » Tue Jun 27, 2017 6:03 am

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
Posts: 1
Reputation: 277

Post » Tue Jun 27, 2017 5:29 pm

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:

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.
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
Posts: 1,419
Reputation: 4,867

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 4 guests