Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / multiplayer game (server / client)

Author
Message
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 1st May 2017 16:46 Edited at: 1st May 2017 16:54
Hi

For my game (https://forum.thegamecreators.com/thread/219267), I have add a multiplayer mode.
I use HostNetwork() to create the server and JoinNetwork() for the client (to joint the server).
For the message, I use : CreateNetworkMessage(), AddNetworkMessageString(), GetNetworkMessage(), and so...

And it works fine with my PC and android phone/tablet .

But, now I would like to send the server application to a "real server" (external PC).
I have found some server not too expensive for my tests (dedicated server).

But does AppGameKit work on system like " Windows Server 2012 Standard Edition" ?
Because, I guess I have to send my server application on this server, and the application must be started on this server.

Do you think it's good enough for a game like "clash of" style (dual in realtime between max 4 players vs 4 players) but probably a lot of players connected to the server ^^ ?
AGK2 tier1 - http://www.dracaena-studio.com
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 1st May 2017 19:22
Does the server app handle multiple groups of 4 vs 4?

What's the maximum number of connections you think the server app might be able to handle?
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 2nd May 2017 07:07
Quote: "Does the server app handle multiple groups of 4 vs 4?"
Yes. For the moment, I haven't added that feature, but I have other online features I would like to add :
- arena : 1 player vs another player
- Donjon : Player vs the machine
- Raid : 1 player attack another player but the other player can't "defend" its city, it's automatic.
- and so...

Quote: "What's the maximum number of connections you think the server app might be able to handle?"

I don't know, the most possible ^^.
If I look and compare the other games like this, we can see that there are many players for these games (clash of lord, castle clash, clash of clans, samurai siege ...) : minimum 100 000 players.
So, I think the server app should handle at least between 10 000 and 30 000 connections (probably more).

I do not know if a server created with AGk is capable of handling so many simultaneous connections.

How much connections can handle a server made with AppGameKit ?

Thank you for your informations and comments .
AGK2 tier1 - http://www.dracaena-studio.com
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 2nd May 2017 15:24
Quote: "But does AppGameKit work on system like " Windows Server 2012 Standard Edition" ?"


Last time i tried this it did not work, mainly you will get trouble getting it running as the box you get normally do not have any real graphics/sound cards, everything is controlled via remote desktop, and AppGameKit cant do console applications. But its been a few years since i tried this , last time i ended up making it in purebasic, not sure if i still got the purebasic server code somewhere if i find it i will pm you a copy

https://forum.thegamecreators.com/thread/193886
best regards Preben Eriksen,
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 2nd May 2017 17:11
AGK will run on a Windows Server OS, but Preben is right, the machine has to have a video card that meets the minimums, which you won't find in a typical dedicated server rental.
I may be able to help you out though. I'm semi-retired from 25 years as an IT specialist and I've got several servers on a rack here in my home office. I can at least set you up with a
server instance so you can test your app. I'll need a day or two to set it up.

As for connections, the number of players you can support will greatly depend on how much data has to be sent, and how often. A stripped down AppGameKit app that doesn't manipulate
any graphics will run surprisingly fast, but network operations and game mechanics calculations can bog things down fast.

Let me know if you want me to set up that virtual server for you and I'll get started. I've got Windows 7 or Windows Server 2008 I can set you up with. Feel free to email me.
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 3rd May 2017 07:10
@Preben :
create the server in purebasic is a great idea .

I have tried and it works, but only for connexion and disconnexion, not for the send/receive message.

When I try to connect to the server (made in purebasic), it works, I receive the message on the server, when the client disconnect the server receive the message, but not the other message, and I don't know why.

Here is the purebasic server test code (based on the server code from purebasic) :


And the client in agk (based on the code from the documentation) :



If you have an idea how to fixe the problems, it could be really great .

KISTech :
Thank you for your proposal, I'll think about it .
For the moment. I make just some server test, I don't have a server which is ready to test (in AppGameKit, I can test on my machine, but I'm not sur it work on windows server 2012, and I'm not sur the performance will be enough good.
So i'm trying to create the server in purebasic to get better performances, and perhaps use sqllite database, and other great options.
AGK2 tier1 - http://www.dracaena-studio.com
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 3rd May 2017 13:56
Quote: "I have tried and it works, but only for connexion and disconnexion, not for the send/receive message."


Yes i know, i spent a good week using a packet sniffer to hack the agk protocol , so it will be more easy for you to wait for me searching for the code , i know i have it somewhere on a old usb or dvd but where ? , I check tomorrow , going to release some new stuff today

best regards Preben Eriksen,
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 3rd May 2017 14:33
Thanks preben I will wait for your code
Thanks a lot !
AGK2 tier1 - http://www.dracaena-studio.com
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 5th May 2017 08:40 Edited at: 5th May 2017 08:44
Blendman: PM you the purebasic code.

Paul: Something changed since i made the server code 5 years ago , it looks like the "Host" now also need to keep the "Clients" and connections alive , or the connection will go inactive (IsNetworkActive) after 5-10 sec. Should the Host now also sent "POLL/KEEPALIVE" to all the clients to keep the connections alive ? , AppGameKit protocol command "7" poll/keepalive ?

best regards Preben Eriksen,
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 5th May 2017 09:46
Hi

Preben : I have receive your code and test it.

You're right, the client is disconnected after 10 seconds.
AGK2 tier1 - http://www.dracaena-studio.com
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 5th May 2017 12:06
Paul: no need to check.

Found my old packet sniffer and see the differences , i will make a new version that works

Blendman pb allow you to compile for linux and this is a console app so perhaps your able to make a "AGK multiplayer server" version for standard apache/linux servers, that would be so great. at least it will work for all windows server versions.

best regards Preben Eriksen,

Attachments

Login to view attachments
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 9th May 2017 08:59
Blendman: PMed you a new server app
best regards Preben Eriksen,
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 11th May 2017 20:49
Quote: "Blendman: PM you the purebasic code.

Paul: Something changed since i made the server code 5 years ago , it looks like the "Host" now also need to keep the "Clients" and connections alive , or the connection will go inactive (IsNetworkActive) after 5-10 sec. Should the Host now also sent "POLL/KEEPALIVE" to all the clients to keep the connections alive ? , AppGameKit protocol command "7" poll/keepalive ?"


In my PHP Server Code which is dated from few years i already handled the "keep alive" check from clients. So it seems that is not new
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 16th May 2017 09:46
Is protocol command 4 is still the "quit/disconnect notification" command (for other clients) ? it seems that the GetNetworkFirstClient / GetNetworkNextClient commands don't care about it . it was working few month (years?) ago.

i see that (now?) the disconnection is the command 6 from the client which is disconnecting... i've tried to forward it "as it is" to other clients followed by the clientID but it's not better...
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 16th May 2017 15:14
Server->Client messages
0: ping request + results of other client pings (if client doesn't respond after 20 seconds then it is assumed disconnected)
1: new client
2: new variables
3: changed variables
4: disconnected client
5: network message
6: keep alive response

Client->Server messages:
0: ping response
1: unused
2: new variables
3: changed variables
4: unused
5: network message
6: client disconnecting itself
7: keep alive request (if the server doesn't respond after 5 seconds then it assumes it is disconnected)
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 16th May 2017 18:40
Thanks Paul.

Is the command message 4 (disconnected client) is refreshing correctly the other clients for you?

Between 2 Agk executables it doesn't work for me. Neither from my Unix Server. Disconnected clients are still considered connected.
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 17th May 2017 14:00
Quote: "i see that (now?) the disconnection is the command 6 from the client which is disconnecting... i've tried to forward it "as it is" to other clients followed by the clientID but it's not better..."

I fixed that on the server by:
Received a command 7.
Change the command byte in the packet to 6 , and forward it back to the same client.
That will keep it alive.
best regards Preben Eriksen,
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 17th May 2017 15:17 Edited at: 17th May 2017 15:19
it's not a problem with keepAlive. KeepAlive is working well (CMD7 from client and CMD 6 as response from server to client).

I'm talking about the CMD 6 from client for disconnection notification (NetworkClose or Quitting App).

1. Client "1" is closing network (NetworkClose)
2. Client "1" send CMD 6 to server
3. Server send CMD 4 (disconnected client notification) followed by Client ID (which is 1 in this case) to other clients (Client "2", Client "3",etc...)
4. Other clients should now have refreshed their Clients list to have the GetNetworkFirstClient/GetNetworkNextClient returning the clients list WITHOUT the client "1" (which is not the case...) <=== the bug is here
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 17th May 2017 16:36 Edited at: 18th May 2017 14:27
Quote: " i've tried to forward it "as it is" to other clients followed by the clientID but it's not better"

It sounds like you are doing it correctly, The server should send message 4 with the ID of the client that is disconnecting. When a client receives this message it will mark the client as disconnected, GetNetworkClientDisconnected will return 1, but it will not remove it. The user must call DeleteNetworkClient to finally remove the client from the list, this is to allow them to do some internal clean up of their own variables before the client finally disappears. Note that the deleting is done on the network thread, so DeleteNetworkClient may not have an immediate effect, but will eventually remove the client from the list.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 17th May 2017 18:14
Quote: "The server should send message 6 with the ID of the client that is disconnecting"


Paul,

The server should send message 4 or 6 ? (client send 6 to the server and server notify other clients with the message 4 .... no ?)

I will test with GetNetworkClientDisconnected
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 17th May 2017 18:29
Ok sending MSG 4 works better when i use DeleteNetworkClient :p ... sorry

Thanks Paul !
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 18th May 2017 14:26
Quote: "The server should send message 4 or 6 ? (client send 6 to the server and server notify other clients with the message 4 .... no ?)"

My mistake, you are correct that the server sends message 4 for disconnects.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 18th May 2017 17:05 Edited at: 18th May 2017 17:09
Ok Paul

Something i can't find by myself ... What are the last 4 bytes in the MSG which is sent for the clients list at a new client connection ? I set it to integer 0 as i can see in my packet sniffing but...

Actually i'm sending something like that (and it works wel) when a client connects to my server (and it works but i don't know the meaning of the last 4 bytes):


(int ServerID) (int ServerNameLength) (string ServerName) (int 0)
(int Player1ID) (int Player1NameLength) (string Player1Name) (int 0)
(int Player2ID) (int Player2NameLength) (string Player2Name) (int 0)
(int Player3ID) (int Player3NameLength) (string Player3Name) (int 0)
...
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 22nd May 2017 21:58 Edited at: 22nd May 2017 21:59
When a client connects to the server the server responds to the client with the list of all existing clients in the following format:

MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 22nd May 2017 23:07
Thank you Paul. It makes sense
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 22nd May 2017 23:45 Edited at: 23rd May 2017 00:27
Quote: "for each variable
        (int) variable name length
        (X bytes) variable name string data
        (int) variable type
        (int) variable mode

        (int or float) variable value"


"type" and "mode" or "mode" and "type" ? i have a doubt about the order when i see the Command 2 (new var) and 3 (update var)

Edit : It seems indeed that "type" and "mode" order are reversed (as paul is saying) when declaring user's variables to a new client... (not the case for CMD 2 (new variable creation) and CMD3 (variable update)).... Strange but ... it works

Thanks Paul
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 23rd May 2017 01:09 Edited at: 23rd May 2017 01:09
AGK Multiplayer PHP Server for Linux is available !

https://forum.thegamecreators.com/thread/219676
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Xaron
10
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 2nd Jun 2017 10:24 Edited at: 2nd Jun 2017 11:46
I'd be interested in that PB code as well.

Oh and I currently check if AGK2 runs on a Windows Server 2012 ...

edit: just tried, no it won't work on a Windows Server 2012 R2 VM.

Login to post a reply

Server time is: 2024-11-24 14:36:58
Your offset time is: 2024-11-24 14:36:58