Jump to content


Photo

Extension: 39js (Socket.io)


  • Please log in to reply
67 replies to this topic

#1 TGMG

TGMG

    G-java creator

  • New Member
  • 706 posts
  • Version:GM8

Posted 27 September 2011 - 04:56 PM

39js
39js is a javascript implementation of the 39dll for GMhtml5. The overall aim is to allow current Game maker games based on 39dll the ability to convert to Html5 with minimal (if any) code changes. Currently 39js is still in a very early alpha stage but includes most of the functionality needed to make multiplayer html5 games in Game Maker. It uses Socket.io to support the widest possible range of browsers and devices (tested and working on iphone and most major Browsers).

Example (if my computer is on):
http://amorri40.github.com/39js/examplegame/

The example is made by Revel from this topic: http://gmc.yoyogames...howtopic=332957 the client gmk was simply imported into gmhtml5 and runs just like it would with 39dll, but the server was slightly changed and made into a javascript file running on nodeJs.

Download from Github:
https://github.com/amorri40/39js

At the moment i'm currently investigating alternative ways of developing the server in Game Maker rather than rewriting slightly for Javascript. Only the basic functions have been implemented so far, the rest of the functions will be implemented when the server can be developed in GM with minimal changes from the original example.

You can download the client example in the github (import in gmhtml5) and you can run the server by running the bat file in the server folder. The API is the same as 39dll (or will be when the rest are implemented).

Let me know if you need any help
  • 7

#2 HighQuality

HighQuality

    Wuka World Creator

  • GMC Member
  • 610 posts
  • Version:GM:HTML5

Posted 27 September 2011 - 05:15 PM

Would love to see this getting finished, if you somehow could get it working with a non-modified 39dll-based server that'd be amazing.

Anyways, great work so far, looking forward to updates :)
  • 0

#3 BlaXun

BlaXun

    Slime Online Creator

  • GMC Member
  • 2616 posts
  • Version:GM:Studio

Posted 27 September 2011 - 05:29 PM

...impressive. Damn, trying this right now. You made my day <3

I'll check this thread regulary
  • 0

#4 TerraFriedSheep

TerraFriedSheep

    GMC Member

  • GMC Member
  • 2826 posts
  • Version:GM:Studio

Posted 27 September 2011 - 05:57 PM

Nice to see some online multiplayer progress made so early on after the release of beta, it's satisfying seeing the little squares move around in their first grasp for multiplayer life :thumbsup:
  • 0

#5 True Valhalla

True Valhalla

    ಠ_ಠ

  • Retired Staff
  • 4900 posts
  • Version:GM:Studio

Posted 27 September 2011 - 11:19 PM

Well, doesn't seem to do anything beyond showing me some messages boxes when I try your link directly, and when I downloaded it and followed your instructions by running the batch file, it threw an error (something to do with process.nextTick).

Also, the example you're using is somewhat...average. It doesn't even check to see if the connection was successful. If you'd like to work with something more established, the Basic Network example I made a while ago might be better: http://bit.ly/oRbCNa

Additionally, the way you've setup the server is quite strange. Personally I'm thinking using PHP with a MySQL database as the back-end is a more logical way to go...perhaps it's time the GMC outgrew 39dll a little ;)
  • 0

#6 pedrosorio

pedrosorio

    GMC Member

  • GMC Member
  • 971 posts

Posted 27 September 2011 - 11:27 PM

Additionally, the way you've setup the server is quite strange. Personally I'm thinking using PHP with a MySQL database as the back-end is a more logical way to go...perhaps it's time the GMC outgrew 39dll a little ;)


That is probably too slow for real-time games, no?
  • 0

#7 True Valhalla

True Valhalla

    ಠ_ಠ

  • Retired Staff
  • 4900 posts
  • Version:GM:Studio

Posted 28 September 2011 - 01:31 AM

I don't see why it would be...the main issue for both 39dll or PHP is the time it takes for the message to travel from the client's PC to the server. No matter which method you use, there's still that ping time.

If you organize the structure well enough, it becomes irrelevant if it's a real-time game or not ;)
  • 0

#8 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9276 posts
  • Version:Unknown

Posted 28 September 2011 - 02:06 AM

The difference in connection type means an HTTP request is quite a bit slower than a socket connection.

However, the trick is to make the game fake while it waits.
  • 0

#9 Seki

Seki

    GMC Member

  • GMC Member
  • 219 posts

Posted 28 September 2011 - 02:08 AM

OMG, just what i needed, thanks... this might help out... Trying to make a native app work with this xDD... gonna be interesting :D
  • 0

#10 pedrosorio

pedrosorio

    GMC Member

  • GMC Member
  • 971 posts

Posted 28 September 2011 - 02:16 AM

The difference in connection type means an HTTP request is quite a bit slower than a socket connection.

However, the trick is to make the game fake while it waits.


I was thinking about this too when I wrote that. But PHP supports sockets.
  • 0

#11 TGMG

TGMG

    G-java creator

  • New Member
  • 706 posts
  • Version:GM8

Posted 28 September 2011 - 02:48 AM

Thanks HighQuality , BlaXun and Soulsnatcher was nice seeing you guys check out the example, even if it was just a rectangle moving on screen :thumbsup:

@True Valhalla : Sorry I switched off nodeJS for a while. I don't currently have a server/vps that i can let nodeJS run so it will be off at times.
It was just a very simple example which was supposed to look like this if my server was up:
Spoiler

The players weren't being destroyed as the game end event doesn't seem to work :confused:

Any chance I could distribute your basic networking example with 39js? It looks great :biggrin:

I setup the server in a strange way or a number of reasons, but mainly I wanted to keep most of the original code from the server example, so most of the code is the same, I also prefer javascript to php and would like to be able to run gmhtml5 as servers in nodeJS (with a simulated browser environment).

Also the output from nodeJS would be very useful as i can't reproduce it (works on mac and windows for me).

Also about using a php server instead of nodeJS, there is a websocket library for php here: http://code.google.com/p/phpwebsocket/ which would be a good starting place.

@Seki what do you mean by native app? If you need any help give me a shout
  • 0

#12 Barling

Barling

    GMC Member

  • New Member
  • 122 posts

Posted 28 September 2011 - 02:58 AM

server no work!

node.js:208
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module 'socket.io-client'
    at Function._resolveFilename (module.js:327:11)
    at Function._load (module.js:272:25)
    at Module.require (module.js:350:17)
    at require (module.js:361:17)
    at Module._compile (module.js:425:26)
    at Object..js (module.js:443:10)
    at Module.load (module.js:344:31)
    at Function._load (module.js:303:12)
    at Module.require (module.js:350:17)

Edited by Barling, 28 September 2011 - 03:00 AM.

  • 0

#13 True Valhalla

True Valhalla

    ಠ_ಠ

  • Retired Staff
  • 4900 posts
  • Version:GM:Studio

Posted 28 September 2011 - 03:02 AM

Any chance I could distribute your basic networking example with 39js? It looks great :biggrin:


Absolutely, feel free to. Please leave as much of the original code and comments in place though.
  • 0

#14 Seki

Seki

    GMC Member

  • GMC Member
  • 219 posts

Posted 28 September 2011 - 03:03 AM

Its easy as to make a HTML5 into a Native App, to sell on App Store, for Android and iOS (Blackberry and Symbian aswell), just need the tools, ive made a few games already... xD (just testing ones for the iPhone)
  • 0

#15 xot

xot

    media multimixer

  • Global Moderators
  • 4651 posts
  • Version:GM:Studio

Posted 28 September 2011 - 03:20 AM

The difference in connection type means an HTTP request is quite a bit slower than a socket connection.


As I understand it, the point of WebSockets (and by extension Node.js with Socket.io) is that an HTTP request is required only to establish the connection. After that the connection is held open and data flows without the need for futher HTTP requests. If it is working correctly, it should be just as fast as any other netcode. I've read of latency as low as 10ms using Node.js and Socket.io. That should be adequate for anything.
  • 0

#16 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9276 posts
  • Version:Unknown

Posted 28 September 2011 - 03:51 AM

As I understand it, the point of WebSockets (and by extension Node.js with Socket.io) is that an HTTP request is required only to establish the connection. After that the connection is held open and data flows without the need for futher HTTP requests. If it is working correctly, it should be just as fast as any other netcode. I've read of latency as low as 10ms using Node.js and Socket.io. That should be adequate for anything.

That sounds very promising, I can't wait to try out games made with this (and GM). I don't really have motivation to make my own MMORPG though.
  • 0

#17 Barling

Barling

    GMC Member

  • New Member
  • 122 posts

Posted 28 September 2011 - 04:08 AM

Server still isnt working i downloaded again just incase the guy updated it but nope.
  • 0

#18 TGMG

TGMG

    G-java creator

  • New Member
  • 706 posts
  • Version:GM8

Posted 28 September 2011 - 04:24 AM

How long ago did you download? Try now the server should be working.
  • 0

#19 Barling

Barling

    GMC Member

  • New Member
  • 122 posts

Posted 28 September 2011 - 05:28 AM

well now when i run the server the command line is just blank.
is something supposed to happen when I connect to the server? because my HTML5 game just shows a grey screen after I register/login.
  • 0

#20 TGMG

TGMG

    G-java creator

  • New Member
  • 706 posts
  • Version:GM8

Posted 28 September 2011 - 05:39 AM

Its supposed to be plank for now, I modified Socket.io as it was displaying too much terminal output but I will fix that.
Yes its supposed to say you have logged in, try again and check your javascript console (on chrome its view->Developer->Developer tools) it should say what is wrong.

You could test out my example to see what its supposed to do.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users