Jump to content


Photo

Extension: 39js (Socket.io)


  • Please log in to reply
71 replies to this topic

#31 dvdtv

dvdtv

    GMC Member

  • New Member
  • 17 posts

Posted 01 October 2011 - 06:06 PM

This look realy nice but i have got a problem. When i run the server.bat i see 1 line of text.
That line gives me online the place were de file stand. Then I start the proj_39jsexample en is start to play.
I changed the port to my port but that doesn't mean because I use localhost. Then I start the game
and I tried to show a message when I recieve a message but I dont recieve message from te server.

I hope you understand What I mean but my englisch isn't very well. Normaly I post on de dutch forum for game maker.

Greets,
or met vriendelijke groeten,
Dennis
  • 0

#32 FiLkAtA

FiLkAtA

    GMC Member

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

Posted 12 October 2011 - 11:46 AM

I'm trying to understand this and I hope you guys will help me out. To learn how this works I want to host the example somewhere and play around with it. I know how to host a game made with GM HTML5 but I'm confused how to host this because of the javascript server. Do I have to host it seperately and which files go where? Thanks in advance.
  • 0

#33 Smarty

Smarty

    GMC Member

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

Posted 12 October 2011 - 12:20 PM

I'm not so sure it's useful, let alone efficient, to try and enforce a 39dll syntax here, for a number of reasons. First of all you currently have no way to interface with the original 39dll socket implementation. Second, server-side code written using 39dll needs a rewrite anyway because none of what people ever wrote was using Javascript in the first place.

But the most important difference is in how 39dll and websockets treat the message part. Where 39dll tries to save pennies by concatenating binary data, websockets can only send text. By nature this is far more verbose, so the message part becomes larger in websockets than in 39dll no matter what you do. But because 39dll users expect control on the byte level, you deal with this difference in 39js by making the buffer commands push data into a text array and pulling (shifting) it out of it again. There is no difference at all in the buffer adding functions. There is no longer a point to have different functions to add different sizes of data to the buffer. There is no longer any point in making the distinction.

Edited by Smarty, 12 October 2011 - 10:17 PM.

  • 0

#34 Jolie

Jolie

    GMC Member

  • New Member
  • 105 posts

Posted 12 October 2011 - 12:39 PM

Wow, this is amazing!
This really extends the possibilities of GM HTML5!
  • 0

#35 Schalk

Schalk

    GMC Member

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

Posted 12 October 2011 - 09:42 PM

Thanks for sharing.

From what I understand, websockets are turned off in Opera and Firefox for security reasons, and the only browser which it currently works on is chrome.
  • 0

#36 blackhawkrobbo

blackhawkrobbo

    GMC Member

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

Posted 14 October 2011 - 03:58 PM

Wow. Simply: Wow!

This solves SO many problems!
I'll finally be able to:

Run the server program on a remote desktop
Run the server program in the background WITHOUT alarms messing up
RUN THE SERVER ON A LINUX MACHINE

Oh my god! Thank you soooo freaking much! This is REALLY awesome!
  • 0

#37 Fireball16

Fireball16

    Indie Developer

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

Posted 15 October 2011 - 03:37 PM

I am just wondering, can you have a .exe with the .39dll and connect it to a html5 server using the 39js?

So can you host a server on a webpage and have exe's connect to it? :ninja:
  • 0

#38 blackhawkrobbo

blackhawkrobbo

    GMC Member

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

Posted 16 October 2011 - 03:50 PM

I am just wondering, can you have a .exe with the .39dll and connect it to a html5 server using the 39js?

So can you host a server on a webpage and have exe's connect to it? :ninja:


:whistle:

You can't directly connect to a GM server running 39dll as socket.io uses websockets and doesn't allow raw tcp connections. However i'm looking into 2 options to make this possible. 1) modifying the 39dll to use websockify which translates websockets to normal socket traffic 2) rewriting 39dll as a websocket server.
Which both would require you to use a custom dll rather than plain 39dll, option 1 would potentially allow both players from gmhtml5 and normal gm to connect to the same server, whereas number 2 wouldn't (well unless they also connected over websockets).

Currently you have to rewrite your server into javascript and run on node.js, currently i'm writing code to allow gmhtml5 servers to run in node.js, so no rewrite is required.

But I do realise that node.JS isn't ideal for everyone and will also look into a php websocket server (which will require you to write all the server code in php). But it is worth mentioning the only advantage of this is it allows you to write in php, you can't just upload to a shared hosting service and expect it to work.

Its also worth mentioning that there are Java, Go, Perl, Ruby, Erlang and Python versions of socket.io which you can already use to write servers for your gmhtml5 games.


  • 0

#39 Schalk

Schalk

    GMC Member

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

Posted 17 October 2011 - 12:26 AM

"Chrome dev build 15.0.874.0 supports binary data and close reason and code."
  • 0

#40 Demion

Demion

    GMC Member

  • GMC Member
  • 46 posts

Posted 31 October 2011 - 11:38 AM

I think you can use websockify to "translate" websocket traffic to winsocket normal traffic. Only you need to port it to win32 and I think youll be able to use it with 39dll or selfmade server on real programming language. Now I personally working on it. If I made some progress I'll post here. Good luck.
  • 0

#41 Crhonos

Crhonos

    GMC Member

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

Posted 20 November 2011 - 04:36 PM

So i can't use my c++ 39 lib baseed server ?Then it's wothless call this a 39js, if it use diferents socket programming, and does not match with the 39dll things.

I don't know if this is the same thing as you guys done here but once i saw this code here in gmc:

import java.io.File;

import pl.org.shocker.lib39dll.*;

public class Main {
        public static void main(String[] args) {
                Lib39dll.libInit();
                
                try {
                        System.out.println(Lib39dll.myHost());
                        System.out.println(Lib39dll.myMAC());
                        
                        File file = new File("asdf.dat");
                        if (file.exists()) {
                                LibFile f = LibFile.open(file,EFileMode.Read);
                                Buffer.def.clear();
                                f.read();
                                f.close();
                                
                                System.out.println(Buffer.def.readString());
                                System.out.println(Buffer.def.readUInt());
                        } else {
                                Buffer.def.clear();
                                Buffer.def.writeString("lolzord");
                                Buffer.def.writeUInt(666);
                                
                                LibFile f = LibFile.open(file,EFileMode.Write);
                                f.write();
                                f.close();
                        }
                } catch (Lib39dllException e) {e.printStackTrace();}
                
                Lib39dll.libDeinit();
        }
}
It cames with other two files: http://ifile.it/m0vkh94
Also i think that is java, and not java script, anyway, i don't know the diference.


Can anyone tell me if it's the same thing , or if this one works with the original 39dll servers and whatevers ?

Also i get this error when trying to run the example java script server:
Posted Image

You could call this Web Socket Extension, and not 39js, this way you are going to stop making people gain false hope, of programming using 39dll server(in any language that 39dll works), and this extension for gml

I was also noticing, this 39js, does not work when running the game as exe, windows mode, do it ?
Also, sorry if i was rude, i got really disappointed as i was reading the posts.


Edit: I found that on google: http://www.ostrosoft..._javascript.asp
Doesn't know if this is what we want though.
Edit2: Found this one too: http://code.google.c...s/tutorial.html

Edit3:I was thinking, you could use a js server to receive the messages, and pass then as arguments to a C++ server or a Game Maker Server.This way i think, the server would not have to be changed at all.

Edited by Crhonos, 21 November 2011 - 06:22 PM.

  • 0

#42 lukeescude

lukeescude

    GMC Member

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

Posted 25 November 2011 - 12:11 AM

Good work!

It would be nice to be able to program a server that could accept both HTML5 web socket connections and application TCP connections at the same time.

Edited by lukeescude, 25 November 2011 - 12:16 AM.

  • 0

#43 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 25 November 2011 - 12:27 AM

Why not make it use JSON? It would be so much easier for everyone, and wouldn't need 39dll's horrible functions.
  • 0

#44 Crhonos

Crhonos

    GMC Member

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

Posted 26 November 2011 - 10:25 PM

39dll is the fastest one, thats why.
  • 0

#45 Manuel777

Manuel777

    InvaderGames

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

Posted 30 November 2011 - 04:17 AM

39dll is the fastest one, thats why.

U sure? :huh:

Edited by manuel777, 30 November 2011 - 04:17 AM.

  • 0

#46 Demion

Demion

    GMC Member

  • GMC Member
  • 46 posts

Posted 02 December 2011 - 02:35 AM

del

Edited by Demion, 08 December 2011 - 10:37 PM.

  • 0

#47 john316

john316

    GMC Member

  • GMC Member
  • 11 posts

Posted 12 December 2011 - 02:17 AM

Does anybody know how i can implement this into a javascript multiplayer engine?or where to start?
  • 0

#48 blackhawkrobbo

blackhawkrobbo

    GMC Member

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

Posted 26 December 2011 - 05:03 PM

@ kaibil:
You're just to dumb to understand it.

So, at TGMG: Thanks a lot for this. i've managed to make an online MMORPG with this and its still in development. There's still something i wonder - do you know when the client sends a 'disconnect' message? because it never seems to do so.
Also the client stops functionating when you lose focus from the game. For me, this is a problem:

Game starts, connects to server
Server keeps track of ping (reset to 0 every time he receives a message)
Client keeps track of ping as well (reset to 0 every time he receives a message)
Now when the client loses foces, the game pauses, and no more messages are sent -> Server logs out the player, deletes the player instance from the array.
->>Here's my problem: The socket doesn't get deleted. This means that whenever the client gets its focus back it sends messages and the server doesn't know what to do, since the player array is gone.
I've tried:
io.sockets.disconnect(global.player[player].tcp);
//Doesn't work (no disconnect method found)

gmsocketio_disconnect(global.player[player].tcp);
//Doens't do anything ( ? )

io.sockets.clients[global.player[player].tcp]._onDisconnect();
//Doesn't work (no disconnect method found)

So what i need to do: how can i close the socket on the server? This way the client will also see that he isn't receiving messages anymore and disconnect as well. Or maybe i can send a message that he has to disconnect? Is this possible and how can i accomplish this?

By the way - i've also seen this piece of code:
io.sockets.on('disconnected', function(socket) { // basically the tcpaccept function
		console.log("DISCONNECTED");
	});
But it never gets called. How come? And how can i force the disconnect status for a client?

Thanks in advance!

Edited by blackhawkrobbo, 26 December 2011 - 05:04 PM.

  • 0

#49 kaibil

kaibil

    GMC Member

  • GMC Member
  • 119 posts
  • Version:GM8

Posted 26 December 2011 - 10:06 PM

@ kaibil:
You're just to dumb to understand it.

So, at TGMG: Thanks a lot for this. i've managed to make an online MMORPG with this and its still in development. There's still something i wonder - do you know when the client sends a 'disconnect' message? because it never seems to do so.
Also the client stops functionating when you lose focus from the game. For me, this is a problem:

Game starts, connects to server
Server keeps track of ping (reset to 0 every time he receives a message)
Client keeps track of ping as well (reset to 0 every time he receives a message)
Now when the client loses foces, the game pauses, and no more messages are sent -> Server logs out the player, deletes the player instance from the array.
->>Here's my problem: The socket doesn't get deleted. This means that whenever the client gets its focus back it sends messages and the server doesn't know what to do, since the player array is gone.
I've tried:

io.sockets.disconnect(global.player[player].tcp);
//Doesn't work (no disconnect method found)

gmsocketio_disconnect(global.player[player].tcp);
//Doens't do anything ( ? )

io.sockets.clients[global.player[player].tcp]._onDisconnect();
//Doesn't work (no disconnect method found)

So what i need to do: how can i close the socket on the server? This way the client will also see that he isn't receiving messages anymore and disconnect as well. Or maybe i can send a message that he has to disconnect? Is this possible and how can i accomplish this?

By the way - i've also seen this piece of code:
io.sockets.on('disconnected', function(socket) { // basically the tcpaccept function
		console.log("DISCONNECTED");
	});
But it never gets called. How come? And how can i force the disconnect status for a client?

Thanks in advance!



And your too much of prick to explain it.
  • 0

#50 blackhawkrobbo

blackhawkrobbo

    GMC Member

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

Posted 26 December 2011 - 11:35 PM


@ kaibil:
You're just to dumb to understand it.
.....



And your too much of prick to explain it.


True. What do you want me to explain? The whole basics of a multiplayer game are in here. Joining, seeing each other, a working server... What more do you need? A complete, ready-to-go game that you can change?

Why not ask WHAT you need and WHY and maybe then i won't be a prick and explain it to you.
  • 0

#51 kaibil

kaibil

    GMC Member

  • GMC Member
  • 119 posts
  • Version:GM8

Posted 27 December 2011 - 04:44 PM



@ kaibil:
You're just to dumb to understand it.
.....



And your too much of prick to explain it.


True. What do you want me to explain? The whole basics of a multiplayer game are in here. Joining, seeing each other, a working server... What more do you need? A complete, ready-to-go game that you can change?

Why not ask WHAT you need and WHY and maybe then i won't be a prick and explain it to you.


I dont WANT YOU to explain me anything, according to you, Im "dumb", so stop replying back to my posts. Please.
  • 0

#52 iceshield

iceshield

    GMC Member

  • GMC Member
  • 460 posts

Posted 07 January 2012 - 11:23 AM

There is a way of making servers within the client? Like the basic Pong example from 39dll where the method is a basic slave and master ?
Or the server can run on a webserver?

Edited by iceshield, 07 January 2012 - 04:02 PM.

  • 0

#53 blackhawkrobbo

blackhawkrobbo

    GMC Member

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

Posted 10 January 2012 - 06:49 PM

Hey iceshield!

I've got my own server running. NodeJS is an application that runs javascript outside of the browser.
It works on windows, linux, and many others. I've managed to turn my Linux CentOS 5.5 machine into a game server using nodejs.

As it is JavaScript, you will still be able to run it within the client. You should take all the server scripts and modify them to work inside of the browser. This requires quite some experience. Maybe i'll start on such a project soon.

As for now, i recommend using the nodejs server.

Good luck!
  • 0

#54 thijsmie

thijsmie

    GMC Member

  • GMC Member
  • 27 posts

Posted 12 January 2012 - 10:13 AM

Good extension! I use it for the Yogscast videogame. I hope you can add the function tcpconnected, because some parts of my engine rely on this functions. Also, is there any way of converting websockets into winsockets? Because if I had the source code of this conversion I could add that into my existing C++ server for mac and windows clients....
  • 0

#55 blackhawkrobbo

blackhawkrobbo

    GMC Member

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

Posted 14 January 2012 - 04:23 PM

Maybe this is something:

http://jahovaos.com/...nt_Stream_.html
  • 0

#56 thijsmie

thijsmie

    GMC Member

  • GMC Member
  • 27 posts

Posted 15 January 2012 - 12:07 PM

Maybe this is something:

http://jahovaos.com/...nt_Stream_.html


Looks good, but the wrong way round. This explains how to use winsockets in node.js, but I want to use websockets in C++... C++ is a lot faster, and this is for the official yogscast game server, so I expect a lot of traffic...

But thanks for the response ;)

Thijs
  • 0

#57 blackhawkrobbo

blackhawkrobbo

    GMC Member

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

Posted 16 January 2012 - 06:39 PM

I think you might want to make your own websocket DLL / library - allthough i think those already exist :)
  • 0

#58 Saxton

Saxton

    GMC Member

  • New Member
  • 7 posts
  • Version:GM:Studio

Posted 06 February 2012 - 08:54 PM

Hi,

how can I let the server check if the players are still online?

thanks
  • 0

#59 theloon

theloon

    GMC Member

  • GMC Member
  • 83 posts

Posted 06 February 2012 - 09:55 PM

Does this require a server? I was hoping for something allowing peer to peer.
  • 0

#60 blackhawkrobbo

blackhawkrobbo

    GMC Member

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

Posted 07 February 2012 - 05:24 PM

@theloon: Yes, this requires a server (e.g. nodejs ) to run somewhere. You could create your own server but you'll have to port the server to run in a local browser.

@Saxton: I would build in a timeout function. (10 seconds after the last message received the player disconnects). I've noticed that the disconnect callback never gets called.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users