cmiiller's Recent Forum Activity

  • Thanks for the ideas.

    I implemented it in a plugin as a message queue with a MessageQueueCount expression to get the number of queued messages (for convenience with using a Repeat loop), and then a Dequeue action which will update a Data expression with the data received on that message, and it works perfectly. I'll submit it as a revision to Zack0Wack0's git respository when I get a chance.

    So now my event sheet looks something like:

    Message Received

    + Repeat Server.MessageQueueCount times => Dequeue Message

    + if (Server.DataPart0 == "messageX") => Do Stuff

    + if (Server.DataPart0 == "messageY" && Server.DataPart0 == "blah") => Do Other Stuff

    + etc.

    There still doesn't seem to be a good way to do string parsing using the existing Construct2 functions, so I also made the plugin split the data received into parts based on a delimiter, and providing a bunch of expressions to get DataPart0 to DataPartN. Not that elegant but it does the trick.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • First off, thanks to Zack0Wack0 for building the WebSocket plugin, I'm new to this engine so it would have been really tedious to get that working.

    As some context to my question, I'm experimenting with using Construct 2 for a client-server type of game.

    I've run into a couple issues that limited what I could do with websockets and was curious if anyone had solutions:

    1) The event sheets don't seem to have any functions for parsing/manipulating string data so processing incoming data seemed impossible. (e.g. splitting "chat:Player says hi!" into the message type of "chat" and payload of "Player says hi!")

    2) I then looked to build a plugin that would do all the parsing, and it would expose events and expressions to the event sheets via that. That worked well except that from what I could tell, the events can't take parameters, and instead the event handler is expected to query state expressions (e.g. Socket.LastDataReceived in Zack0Wack0's plugin). Where this fails is that you could receive multiple messages from the socket before the next AI tick, and since each message just updates LastDataReceived it would result in only the most recently received message's data being available to the event sheet.

    Is there some existing functionality I could use? Or am I just trying to do something with Construct 2 that it's not currently designed for?

    Thank you!

cmiiller's avatar

cmiiller

Member since 8 Aug, 2011

None one is following cmiiller yet!

Trophy Case

  • 13-Year Club
  • Email Verified

Progress

14/44
How to earn trophies