Help: Send and receive messages Webocket.

Discussion and feedback on Construct 2

Post » Wed Nov 20, 2013 2:35 am

After much work, managed to create a websocket server. Now, I would like to do the Following work.

A player presses a button and sends a text message to the other player connected to the websocket, and the second player can read and reply to the message received.

How I can perform this?

Thank you.

PD:Use scrible websocket.
Posts: 208
Reputation: 1,625

Post » Wed Nov 20, 2013 2:42 am

Could you have a look at the post I made on your "URGENT HELP PLZ" post ?

I think it explains this , but basically , you need to set up your server and client-side to be able to send AND receive messages

In C2 , checking for received messages is as easy as ;
Websocket - On Message Received
and sending is that easy too ;
Websocket - Send text

NOTE : You'll need to be connected to the server for this to work

You'll need to code the server to be able to receive and send messages
function onMessage ( uid , msg ) -- Called when a user sends a message
-- uid(string): userid of user messaging server
-- msg(string): message received
sendTo ( uid, msg ) -- Send a message to a user by their uid
-- uid(string): userid of who will receive msg
-- msg(string): message to be sent
Scribble Documentation (Clicky Clicky)Whiteclaws2013-11-20 02:43:48
Posts: 2,247
Reputation: 17,556

Post » Wed Nov 20, 2013 3:07 am

Thanks, but I have the following problem.

I have to create a supplied text box in the layout, so that the message is seen in that text box, or Aug for display.

Because, I do the following:

I create a text box in the layout.

When a player presses a button, Aug action: websocket send text: data: "hello"

And then realize that: on message Set text to websocket message text.

It does not work.

What Aug wrong?
Posts: 208
Reputation: 1,625

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 3 guests