JohnnySheffield's Recent Forum Activity

  • Hi!

    First you have to SplitDataReceived to get some consistent LastDataElement.This plugin splits data where is a comma sign, eg.

    If your message looks like 'message',"Some,data,here" it will be split like this:

    Socket.LastDataElement(0)="Some"

    Socket.LastDataElement(1)="data"

    Socket.LastDataElement(2)="here"

    As you can notice, Socket.LastDataElement requires an index number, starting from zero.

    As for the error i cannot really tell you something useful, if you could post .capx and server code, it would be possible to pin-point the error more accurate.

    Also, there is a few versions of that plugin on the forum (it's pretty unstable plugin, there is great community effort to make it more stable, hence a few versions of it exist), so if you could tell us where did you download Socket plugin, or share the plugin here!

  • yup, srware iron is just variation of chrome, after i updated iron, everything was ok.

    on other browsers everything worked ok for me too, sorry for posting an error on old browser!

  • Just a report, after updating browser to 21.0.1200.0 everything was ok!

    Added just a textbox to a project. Preview looked ok, but when i changed tabs, or minimized window error occured:

    <img src="https://dl.dropbox.com/u/62601881/error/error.jpg" border="0">

    Capx

    After browser update, everything worked fine.

    On Chrome 21.0.1180.89 m and IE9 9.0.8112 everything was ok.

    System spec: Win7, 64bit, AMD Radeon HD 6700.

  • Update on stable version:

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

  • You can check out modded version of this plugin here:

    Link with minify problem sorted out!

  • 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!

  • 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 & 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!

  • Schoening

    Have you tried this? When i do this changes to the example the problem you mentioned doesn't happen...

    it's even easier than that wall of text i wrote:

    To juantar's example server just add at the right place:

    socket.on('disconnect', function (data) {

           

           socket.broadcast.emit("message",'D,' + mySelf[0] );

           entities[myNumber] = null;

           

    });

    To capx just add (as sub-event of "is data available?" event):

    http://imgur.com/2YZR6

  • Schoening

    I'm not on my computer so i cannot see the capx, but i think there is an event that sends "C" message to server whenever someone connects. Look what happens with that message. Also,you could be right, maybe server remembers disconnected player,but i believe if that is the case, you should check out the solution ?for the problem that lonehangman had few posts ago. If i'm wrong you should find out where the server sends "C" message, and mess around with that piece of code.

    I'm on my computer in a few hours so i'll look into it and come back with more details!

  • it's even easier than that wall of text i wrote:

    To juantar's example server just add at the right place:

    socket.on('disconnect', function (data) {

         

          socket.broadcast.emit("message",'D,' + mySelf[0] );

          entities[myNumber] = null;

         

    });

    To capx just add (as sub-event of "is data available?" event):

    http://imgur.com/2YZR6

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • First, when a player connects, server must give him his unique number, or a client must notify server what is his number, and store that number on server somehow (you can make your own list of numbers, or use a socket.id number or you can use constructs sprite ID, or etc. but clients and server must know what that number is).

    So, when connects, client can do something like:

    On connect

         Socket send message ("PLAYER, MYID") // in this case client notifys server what his number is

    Depending on what kind of arhitecture you want, you must code this part yourself, you can do something like this maybe (code is a mess, just for a general idea)

    myNumber = 0;

    var Me = [];

    io.sockets.on("connection", function (socket) {

         

        socket.on("message", function (data) {

            var new_data = data.split(',');

           

            if (new_data[0] == 'PLAYER') {

                  

              var myNumber = count++;    

              Me[0]='player'

              Me[1]=new_data[1];

    }

    socket.on('disconnect', function (data) {

              socket.broadcast.emit("message",'D,'+ Me[1]);

              //remove player from the list here somehow; Me[1]=null

                   }

    So, when a player disconnects, you can notify all connected games that a specific player is (D)ead, and what is his ID, so that client can:

    On Message "D"

           Pick instance(ID)

               Destroy

    sorry for the messy post, i'm in a hurry but that's how i'd do it. There is probably much more smarter way for this.

  • I don't know if anybody will need this, but here you go...

    -iPad GUI PSD (Retina Display)

    -iOS 5 GUI PSD (iPhone 4S)

    -Android GUI PSD (High-Density)

    -Baseline Grid

    -iPhone 4 GUI PSD (Retina Display)

    -iPad GUI PSD

    -iPhone GUI PSD

    -iPhone Sketch Elements AI

    -iPad Sketch Elements AI

    Link

JohnnySheffield's avatar

JohnnySheffield

Member since 31 Jul, 2012

Twitter
JohnnySheffield has 1 followers

Trophy Case

  • 12-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

15/44
How to earn trophies