0 Favourites

Help: Send and receive messages Webocket.

  • 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.

  • Construct 3

    Buy Construct 3

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

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

  • 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?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)