WebSockets: What do you want?

0 favourites
  • I'm starting to play with Construct 2 for the first time today, looking to see how I can use my WebSocket client / server technology with it. I can do anything I want re: WebSockets but don't have experience with Construct 2. Just thought it might be a lot more efficient to ask experienced users, who have perhaps tried or constructed apps with WebSockets, what you really need and want.

  • Not many of us have played with the websockets because we lack the server end of it.

    If you get it working, I am definitely interested in your progress.

  • I have my own server ... built it myself; fully standard compliant. I've had a demo running for about 2 years.

    highlevellogic.blogspot.se/2011/09/websocket-server-demonstration_26.html

    It definitely works and the browser side stuff is pretty easy, if all you're doing is sending and receiving data. I have also developed an application framework that can be wrapped around the WebSockets (called High Level Logic - HLL) with distributed applications in mind ... which could include multiplayer games.

    With or without HLL, I can make this baby work any way that I want to, and provide any support that I want to. The interesting thing right now is that it looks like Construct 2 could use this support, and I am very interested in applying the technology to games.

    I'm just starting to look at Construct 2, and wondering what the best way is to capture shared event data and apply it when it comes in.

    But also, the initial question ... do you have any thoughts on what would make use of WebSockets easy for you and give the results that you want?

    Do you for example, need to be able to program the server side with JavaScript? Or would you get fired up already if the WebSocket server did something as simple (not requiring app developers to program at all) as registering users for a game (can support more than one game group) and echoing incoming data back out to all active players accept the one who sent it?

  • Id say the biggest issue now is parsing the notification messages from servers.

    Most strings are in json key pair format, and C2's data objects use that, except they must all have the first key formatted to something they recognize.

  • Id say the biggest issue now is parsing the notification messages from servers.

    Most strings are in json key pair format, and C2's data objects use that, except they must all have the first key formatted to something they recognize.

    Thanks. I can look at that when I've gotten a little farther along so I have some way to id the problem and test. As per your description, it could be more than one thing. Top of my head says it may need to be serialized or deserialized, depending on how you want to access the results. I don't use JSON myself, but as I understand it, the functions for that are window.JSON.parse("a json string"); and window.JSON.stringify(myObj);

  • Well if the return string was already formatted to "{"c2dictionary":true,"data":{}}" then when you received the message you could just load it into the dictionary object, and compare known keys, or do a for each key.

    I would assume there shouldn't be many issues reloading the dictionary that way.

  • Well if the return string was already formatted to "{"c2dictionary":true,"data":{}}" then when you received the message you could just load it into the dictionary object, and compare known keys, or do a for each key.

    I would assume there shouldn't be many issues reloading the dictionary that way.

    OK. I'll try to figure out how to do that. Do you happen to have an opinion as to whether this will work with the "8 direction 1 (simple movement)" example?

  • You could set up key values named for the different directions, and use a Boolean 0, or 1 to tell an object to stop or go.

    Heres an example.

    capx

  • You could set up key values named for the different directions, and use a Boolean 0, or 1 to tell an object to stop or go.

    Heres an example.

    https://dl.dropboxusercontent.com/u/666516/ws4dir.capx

    OK, now I need to know how to update my free version. The project was saved in R143, and I have R139 ... so it wouldn't load.

  • And I apparently need to install CSWebSocket_plugin.js ... searched the directories and then googled, but haven't found it.

  • You will need to set up the server info in event 1.

    Thats just how it could be set up for the client side.

    Your end will require a fair bit more.

    Also that error notice should gone in the next release.

  • That's weird. It began running in Chrome after I used the short-cut to display the html file source, but I can't inspect code. And although it's not actually running in Firefox, I'm now (after viewing source too) looking at the CSWebsocket code in Firebug.

    OK ... So, I should set up server info in event 1 ... but how to I trigger the dictionary update based on received info as you suggested. I'm used to editing directly in code and I'm not seeing any in the development system so far.

    (also wish the forum would stop timing me out)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I might be catching on ... I can set values for key right, etc. on the websocket. Will that prepare and send a message? Will it interpret and apply if it receives a message with the codes I set in the same form?

  • Just as a quick experiment, I entered the ws address for my demo. I can see the connection being made from localhost:5000, the C2 program, with some crazy Cookie data in it, referring to one of my blog articles. But then when I click right, left, or whatever, it requests /robots.txt, which causes it to drop the WebSocket connection. (My demo doesn't take kindly to special requests.)

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