[PLUGIN] Zack0Wack0's Socket.io mod

0 favourites
From the Asset Store
The I18N (Translation) is a Construct plugin created to translate text in game.
  • EDIT2: I became a father month ago, so I haven't got time to sort this plugin and post to some decent level of tidyness. I believe I'll manage to find some time in the next week, so i'll re-upload the plugin with some modifications and hopefully new possibilities!

    EDIT: You can download more stable version of this plugin(without new ACE's except send custom event(aka emit), but with minify problem sorted out): Link to stable plugin

    And you can check for yourself: Juantars multiplayer demo example minified!

    Socket away!

    -----------------------------

    Added:

    OnEventReceived

       - Triggered when Construct receives a custom socket event.

    OnAnyEvent

       - Triggered when the socket receives any event. (All of them!)

    one new action:

    Emit

       - Emit a custom event through socket. (You must specify which event, and what data to send with that event)

    and two expressions:

    LastSocketEvent

       -Get the last event that was triggered in Construct.

    LastSocketEmittedEvent

       -Get the last event that was emitted by Construct.

    Changes:

    1) Socket.send ---> socket.emit('message' , data)

    2) On data received

    -Triggered when socket receives a chunk of data, regardless of event

    3) Included recent modifications by juantar & bhavanvaishnav

    4) Changed dependency from "socket.io.js" to "socket.io.min.js"

    5) Overridden socket.io's emit; hackish solution; not satisfied but works for now, waiting for more decent implementation: link

    Problematic code starts at line 110 in runtime.js

    5) You can minify the plugin!

    Tested on C2 r95, SRWare Iron, 15.0.900.1.

    Please test on more browsers and in more situations; haven't had time to test it properly.

    I don't recommend to use it in production code, big chance of unexpected behavior!

    Download here:

    link

    Greatest improvement is possibility of minify, if somebody wishes, i can edit older versions of plugin to be minifiable, but i believe this is a good progress!

    I'm learning plugin development and javascript with this plugin, so i would be grateful for any help in improving it!

    Have a nice day!

  • Good job, seems like you already have something solid right here, I'll test it when I get home.

    But from the list of conditions and expressions, I can already imagine the possibilities :)

  • Thank you Rory!

    On the side note, playing with plugin, currently experiencing some weird behavior with LastDataElement expression, seems like it catches elements it shouldn't (one element from event before). Hmmm...

    I have to work now, will try to fix it later, another signal this is just for testing purposes!

  • Update on stable version:

    Separated emit and send actions, so it doesn't break old projects. Please download again.

  • Thanks a ton!

    Finally able to minify. Worked with Google Chrome and didn't have to change any of the previous plugin settings.

    Cheers mate.

  • Wait.. Is it the Stable Link or the sheffield?

    And do I have to run any cmd to update node or socket.io?

  • Schoening

    I would recommend to use stable link, but there is no server included in the plugin, so you have to write your own.

    It will work with juantars multiplayer demo, so you don't have to change server code.

    If i didn't understand you well, please ask again, English is not my first language :)

    Aaand i will edit the first post to clarify it a little bit more!

  • Could you give a quick explaination how the:

    var myNumber = count++;

    Works? What does determine the count++? And can I replace it with a Facebook ID for example?

  • hmmm...

    where is that line of code? i'm looking at runtime.js of both mods of plugin (stable and unstable) and i can't find it!

    It sounds like it's on server side, if i remember correctly, but i'm not so sure about it...

  • Does data Split only work with "," ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Plugin uses string.split(separator,limit) method. Separator and limit are optional attributes and you can ommit them. If you do, method will return an array with a single element;

    var URL="WWW.Google.com", var result=URL.split(); result will be an array with a single element (WWW.Google.com).

    If you use var Ucan="do it", Ucan.split("") will return an array with elements (d,o, ,i,t). (Mind the white space!).

    If you do something like var query="split.string method JavaScript" and then query.split("i",2),returned array will be: (spl, t.str). This is an example use of a limit attribute in a string.split method.

    If you need an datasplit action in the c2 plugin with a different character than ",", just edit the right line of code in the runtime.js; if you use this method on your server side, I hope this post will be of use!

    Cheers!

  • Just found out that Socket.io 1.0 is probably going to be pre-released some time this week. The newest feature is that it will include the engine.io 0.3 for the communication layer. As it seems it will introduce a better user experience and a lot of improvements.

    Sounds nice.

    I will really really try to release improved plugin for the pre-release of socket/io 1.0, and hopefully make socket communications with this nice plugin a little bit easier!

    <img src="smileys/smiley35.gif" border="0"> it, i really dig Guillermos work

    Cheers!

  • Nice work Johnny, I'm definitely going to set some time over xmas to look at this! <img src="smileys/smiley20.gif" border="0" align="middle" />

  • Nice plugin!! Thank you, Johnny.

    I want to use this plugin in 'CocoonJs'.

    Now I got this error.

    <img src="https://www.dropbox.com/s/tvgvs5cljrgv59l/socket.io_error.PNG" border="0" />

    dropbox.com/s/tvgvs5cljrgv59l/socket.io_error.PNG

    Please help!

  • Not sure what's happening there, I haven't used cocoon.js so probably I won't be as much of help with this issue.

    I looked at cocoon.js documentation, and they don't mention support for socket.io, just websockets so I,m not sure can we edit this plugin to work with cocoon.js.

    Maybe try to use the websocket version here (scroll to the websocket version)

    But i cannot guarantee will it work with new version of construct or cocoonjs because out to s an old plugin.

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