Jump to content


Photo

Extension: 39js (Socket.io)


  • Please log in to reply
67 replies to this topic

#41 Crhonos

Crhonos

    GMC Member

  • GMC Member
  • 219 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
  • 513 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.
  • 1

#44 Crhonos

Crhonos

    GMC Member

  • GMC Member
  • 219 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
  • 2847 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
  • 9 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
  • 266 posts

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
  • 266 posts

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
  • 393 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
  • 266 posts

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
  • 22 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
  • 266 posts

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
  • 22 posts

Posted 15 January 2012 - 12:07 PM

Maybe this is something:

http://jahovaos.com/groups/jahovaos/weblog/1e3f0/TCP_Winsock_Sockets_and__Server_Sent_Event_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
  • 266 posts

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
  • 1 posts

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
  • 70 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
  • 266 posts

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