0 Favourites

Socket.io Mod

  • Hi all,

    I've applied some mods to the already modified Zack0Wack0's original. Taken from JohnnySheffields version here.

    Here's my version:

    Socket io plugin

    New Expressions:

    Socket.DataAtVAr("variable name") <- this will allow you to select incoming values by using the variable name.

    e.g. if the sever sent {id:5, x:2, y:5} for an event "move player", you can do On event "move player" > Opponent.X = int(Socket.DataAtVar("x"))

    Socket.LoadDataJSONStringify <- this can be injected into a hash table or anything that takes a JSON string.

    New Action:

    EmitAsJSONString <- this will allow you to send data as JSON. It will convert the JSON string to JSON prior to sending. Note, because C2 does not allow using escape characters like \ or the use of single quotes. You need to escape double quotes using "".

    e.g: "{""y"":""" & int(MyPlayer.Y) & """}"

    converts to {y:value}

    I'm finding the DataAtVar and the EmitAsJSONString really workable and much cleaner than the comma values and LastDataElement.

    I'm working on a decent example for you all and a template server file for multiplayer. I'll release that soon for those interested.

    :)

  • Nice, i have no experience how to use socket.io, however im waiting for your a decent example, sweet.

  • Looking forward to the example as well :]

  • Great work!

    Really glad someone took time to improve socket.io integration in C2.

    Cheers!

  • You still working on things here, Ace?

  • Index

    I am indeed - I've updated this plugin further in fact. A bit of an overhaul as the LastEvent code was not capturing events that were in quick succession.

    It's hard work but want to demonstrate real time multiplayer so I'll be with you shortly!

  • UPDATE

    Subscribe to Construct videos now

    Notice I've changed the plugin to do away with csv's and instead implement a loop through events, checking their names and accessing data with a CurDataAtVar("var") expression.

    /UDPATE

  • Glad to hear you're still fiddling with this. I haven't ran into the need to use it yet- but once Johnny's falls too far behind I'll probably switch over.

    I looked at the official one websocket one. I just don't understand how to edit the url to use Https(Wss) since the plugin layout is strange to me.

    About the video. If you're looking into doing multiplayer stuff- I don't know too much about it. I wish I knew where I originally heard this from.

    Basically- you should allow the client to predict with periodic updates. That means sending the direction, speed, and so on only when there's a difference. The client then emulates that. The server will also send a hard update of coordinates every ~2 seconds(depending on need) making sure the client isn't too detached from the original. This cuts the amount of messaging by a ton.

  • Index

    The official websocket plugin is just concerned with sending messages between clients (like a chat feature). The good thing about this plugin is the ability to communicate objects of data (JSON) with clients and servers which is what you need for multiplayer gaming.

    These plugins will come on a lot over the next year or so as UDP becomes accepted in browsers.

    Yes, you are correct about the prediction. It's called Client Side Prediction and can vary depending on your game.

    Concepts such as CSP, Lag compensation and inter/extra-polation are difficult to grasp and because they integrate with the game mechanics, you don't often see 'plugins' for such things.

    Also, because of cheating, you need to simulate the game on the server so can't really get away from learning how to code. This could in theory be implemented into Construct but it would require major effort and good design thought from the developers.

  • Any news on if the Socket.io behavior for the official releases will have these features in future though?

    Thanks for this plugin!

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Rory

    I wouldn't know sorry. I do know that Socket.io itself is closing in on version 1 release and there are already frameworks such as multiplayer.js for node that are incorporating these features. I've not used them as yet.

    The challenge comes in designing configurable features that can suit lots of multiplayer game types.

  • Google is working on something for faster UDP usage. I think it was leaked information though so there's not too much about it just yet.

    Also~ I'll be keeping watch on this thread. Keep it updated with your progress. :]

  • Nice progress with this plugin!

    You've made some nice additions to the whole socket.io plugin.

    I see that you're using the "unstable" version of the plugin that has the "On any event" condition.

    Although it is crucial to have that kind of condition for making something useful without editing the runtime.js everytime you need a trigger for a custom event, it uses some pretty hackish solution to achieve this. Socket.io doesn't have the Socket.on("*"){} or some other wildcard event that will catch all received events as for now, altough there is some talk about it; see here.

    I had some problems with current implementation with "On Any event" and sometimes it caused problems (non triggered events, although i sent them to client).

    Another issue with this plugin is received data handling. Currently, data is stacked in the LastData array, then extracted from it with some dubious(?) methods. Official websocket plugin has a much more tidy way of handling this, but i'm not sure is that solution suitable for this kind of plugin.

    Also, this plugin became really dispersed on a bunch of variants across the forum. Can we find something like github or sourceforge to track changes and sum our efforts to have one great plugin, instead of 5 different ones? Any suggestions?

    Cheers!

  • JohnnySheffield

    Yes, GitHub would be great.

    I've amended this plugin to create a much better means of accessing events which I haven't released. GitHub will certainly help get our thoughts together. I'll set it up...

  • That's good. When you set it up, please notify me, so i can start contributing to the project!

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