Socket.io Mod

Post your completed addons to share with the community

Post » Mon Feb 11, 2013 12:55 am

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.

:)

B
5
Posts: 39
Reputation: 678

Post » Mon Feb 11, 2013 1:37 am

Nice, i have no experience how to use socket.io, however im waiting for your a decent example, sweet.
B
96
S
25
G
20
Posts: 3,052
Reputation: 22,638

Post » Mon Feb 11, 2013 11:23 pm

Looking forward to the example as well :]
B
20
S
5
G
8
Posts: 325
Reputation: 6,473

Post » Tue Feb 19, 2013 9:41 am

Great work!

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

Cheers!
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Fri Mar 01, 2013 5:00 pm

You still working on things here, Ace?
B
72
S
10
G
6
Posts: 104
Reputation: 7,550

Post » Fri Mar 01, 2013 9:53 pm

@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!
B
5
Posts: 39
Reputation: 678

Post » Sat Mar 02, 2013 12:28 am

UPDATE
Youtube video of progress here

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
B
5
Posts: 39
Reputation: 678

Post » Sat Mar 02, 2013 6:01 am

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.
B
72
S
10
G
6
Posts: 104
Reputation: 7,550

Post » Sat Mar 02, 2013 3:58 pm

@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.
B
5
Posts: 39
Reputation: 678

Post » Sat Mar 02, 2013 4:54 pm

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

Thanks for this plugin!
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Next

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 3 guests