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 / [RELEASE] AGK Multiplayer Server for Linux (With a new feature ! :)

Author
Message
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 21st May 2017 03:05 Edited at: 3rd Jun 2017 12:57
Hello the community !

i finally release my AppGameKit Multiplayer Server for Linux. (Now with Network Prediction/Reconciliation/Interpolation ! see below...)

It's a daemon written in PHP to allow easy customization and interactions between your games, websites and databases (MySQL for example). So the server could also work on MacOS X , and Windows in debug mode only (not as a daemon). You only need PHP-CLI and major modules installed.

The server is just... one PHP file and should be compatible PHP5>PHP7 (maybe PHP4 but not tested). You put it on your linux server. You chmod +x it, you launch it (even without any customization) and you're ready to go.

I've made the server fully compatible with almost all AppGameKit network commands.

However, I had to resolve one thing : supporting a lot of players without broadcasting all the local network variables to all the server-connected players. Players are generally "isolated" in "party","room" or "game" virtual spaces. or maybe in a totally different agk game !

So,I have added one important thing : Channels. Virtual channels (or rooms) can isolate group of clients/players as if they were on an independant host server. So, only one instance of the Server could host multiple Network games or apps.

To change default channel (channelNumber 0), your App Client only need to call the AppGameKit Command SetNetworkLocalInteger( networkId, "SERVER_CHANNEL", channel_number) and the server will do the rest and notify correctly each client which is concerned for join/quits/variables/updates/messages etc..


Of course, the AppGameKit Server is customizable interacting with network events as explained in the help documentation :



Edit 03/06/2017 : AGK Server has now a Plugin called "NetGamePlugin" for realtime Network games which needs Client-Side Prediction, Reconciliation and Interpolation to bring smooth animations !

For these kind of realtime game, The server is authoritative. Client simply sends movements (direction and Velocity but not the global position !) and Server will calculates World Position of each client and send them back to clients (with updatePlayer events). To prevent local latencies, Local player has its own event which use prediction and reconciliation. Thje plugin have been made to be basically 2D/3D Compatible.

As for the AppGameKit Server, everything is made in a "Event Driven Architecture". The plugin consists of two files : a server side plugin (AGKServer_NetGamePlugin.php to include in AppGameKit Server Core file) and a AppGameKit Client Plugin ( NetGamePlugin.agc )

Here is the documentation of the Server-side plugin :



here is the documentation of the Client-side plugin :



You can simply compile and try the Sample AppGameKit Tier1 Game (very basic race game :p), it is configured by default to connect to my 24/7 AppGameKit Server Linux Box and contains a lot of comments. Use the key 'G' to make your network ghost appears.
Works Also on mobile devices (added a little Virtual Joystick

The plugin is surely not perfect and there is a lot of variant negotiations for Prediction/Reconciliation/Interpolation... (for example, Extrapolation !)

You can obviously write your own plugin or modify this one !

The basic AppGameKit Server PHP Core File is attached

The NetGamePlugin (AGK Server PHP Core + NGP Plugin + Sample AppGameKit App) is also Attached

Feedbacks or ideas will be appreciated !
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit

Attachments

Login to view attachments
Cor
AGK Developer
13
Years of Service
User Offline
Joined: 19th Dec 2010
Location: Its a trap!
Posted: 21st May 2017 07:08
Very very nice, i got it set up and running on my vps. Nice work! i can now actually make a multiplayer game easily. this is something that needs to be included with agk.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 21st May 2017 21:29 Edited at: 21st May 2017 21:35
New commands added / renamed for compatibility :

- GetNetworkClientVariable($ClientID, $VariableName) => Get Local variable (integer or float) from client (Now Respect the AppGameKit Network ResetMode)
- GetNetworkClientInteger($ClientID, $VariableName) => Alias of GetNetworkClientVariable command
- GetNetworkClientFloat($ClientID, $VariableName) => Alias of GetNetworkClientVariable command
- SetNetworkLocalInteger($ChannelNumber, $VariableName, $Value [, $ResetMode = 0]) => Sets/updates a server local integer variable which will be transmitted to clients of $ChannelNumber
- SetNetworkLocalFloat($ChannelNumber, $VariableName, $Value [, $ResetMode = 0]) => Sets/updates a server local float variable which will be transmitted to clients of $ChannelNumber


First post updated !
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Cor
AGK Developer
13
Years of Service
User Offline
Joined: 19th Dec 2010
Location: Its a trap!
Posted: 22nd May 2017 05:17
Thanks for the update MikeMax, im following this closely. One quick question for you, I noticed that when i connected with another player via the demo on my server the other players were somewhat jittery in their movement. Is this normal, or what can be done to make it more smooth?
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 22nd May 2017 06:53 Edited at: 22nd May 2017 07:29
Cor,

It's normal and you are now facing to the real difficulty of Internet multiplayer games ! I was waiting for this kind of questions

but first thing, have you played with ServerLatency variable (which uses SetNetworkLatency AppGameKit command) on the App side ? more you down it, more it will smooth. But if your client connection is not fast enough it will not be sufficient (which is generally the case for games which require instant-reaction). Is the jitter effect the same when you connect on my demo server ? maybe your VPS internet connection is slower than mine.

Multiplayer over the internet is totally different of multiplayer over Local Area Network in terms of latency and so, smooth. it's a big subject (except maybe if you have fibered connection from all clients to server ...).

I think this server will now bring the subject of "Network Prediction / Compensation / Interpolation" in this place . There are few solutions and here are some ressources :

- All the parts of this article are very interesting to understand : http://www.gabrielgambetta.com/fpm1.html ( and especially the "live demo" which could help you (code in page which can be easily translated to AppGameKit Code) : http://www.gabrielgambetta.com/fpm_live.html)

- https://en.wikipedia.org/wiki/Client-side_prediction

- https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

- And surely on main TGC Forums ! Try to search about "network latency" or something like that in DBP forums maybe

There is a lot of ressources on internet about multiplayer latency compensation/prediction/interpolation and google should help you to use the better technique for your case.

I will also modify the Demo app and adapt server events to add compensation/prediction/interpolation to help everyone to understand with AppGameKit Code in a near future
--------------------------------
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 00:57 Edited at: 23rd May 2017 01:04
few optimizations and New commands added :

- GetChannelClientsCount($ChannelNumber) => (integer) Retrieve number of clients in $ChannelNumber
- GetChannelClientsList($ChannelNumber) => (array of ("ID","Name","ChannelNumber")) Retrieve Clients Names,IDs,ChannelNumber in $ChannelNumber ($ChannelNumber = -1 to retrieve ALL connected Clients with respective ChannelNumber)

- New method in class NetworkMessage : SendChannel(ChannelNumber) => Send the message to each Client present in ChannelNumber and clear the buffer

First post updated.
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Cor
AGK Developer
13
Years of Service
User Offline
Joined: 19th Dec 2010
Location: Its a trap!
Posted: 25th May 2017 02:14
awesome thanks Mike Max! what else do you have in the works for this?
Wilf
Valued Member
17
Years of Service
User Offline
Joined: 1st Jun 2006
Location: Gone to Unity.
Posted: 25th May 2017 14:54
Completely awesome in every way.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 25th May 2017 16:22
Thanks for your comments !

To answer to Cor, i'm working on :

- An easy way to implement Network Prediction/interpolation in multiplayer AppGameKit games (on server side and with a set of commands as a library in AppGameKit for clients side)
- Commands to create Virtual Client/Players (bots) and interact with.
- Make the server able to work in a cluster (with server mirrors to prevent server failures)

--------------------------------
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: 26th May 2017 16:52 Edited at: 26th May 2017 16:53
Event added :

- onAGKClientUpdateVariable($ClientID,$VariableName,$VariableValue) => Triggered when a client has updated a local variable.

Method Added :

- StopPropagation() => Tell explicitely to the server to DO NOT transmit received message or variables to concerned client(s) (or ALL client if DestinationID=0) (To use only in very special cases... but the method exists !). should be in onAGKClientNetworkMessage event server's function or in onAGKClientUpdateVariable event server's function.

First post updated.
--------------------------------
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: 1st Jun 2017 17:35 Edited at: 1st Jun 2017 17:35
I have now a working bundle solution for "live" networking games (Multiplayer PHP Linux Server + little AppGameKit Tier1 .agc Lib) which handles Client Side Prediction, Reconciliation and linear and angular Interpolations using an easy implementation (i think !).

So i will release the Multiplayer Server updated with a simple Tier1 example very soon !

But for the moment i have to write the documentation !
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Cor
AGK Developer
13
Years of Service
User Offline
Joined: 19th Dec 2010
Location: Its a trap!
Posted: 1st Jun 2017 19:02
Awesome work MikeMax, i look forward to trying it out!
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 2nd Jun 2017 07:34
Awesome stuff. Out of curiosity, is there a special reason to use PHP for that? Probably because it's already installed everywhere? Have you tested how many connections this solution could handle (I know it depends on the server)?
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 2nd Jun 2017 08:00
@Xaron, you're right.

Server side needs (depending on each game), more or less server code. But sometimes a lot of logic is on server side. I think the most widespread and easy "server" language is PHP. Actually the server emulate a multi-thread server but i will turn it on a real multi-thread server app. (And later, i will do another version in C/C++ later maybe depending on performance issue).

I will have to do a benchmark soon and i will ask for evryone help here to connect at the same time !
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 2nd Jun 2017 08:24
Nice! Actually I planned to do something in C++ or C# for the server side.

Out of curiosity (as I'm still new to AppGameKit and its multiplayer stuff): Is there an advantage to use that build in AppGameKit multiplayer commands vs the standard sockets stuff?
I mean the fancy multiplayer commands in AppGameKit do probably something in the background like client connection handling (detect disconnects etc) already? If so, how do you emulate that, I mean you need the internal protocol for that?
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 2nd Jun 2017 09:41 Edited at: 2nd Jun 2017 09:46
This Multiplayer PHP server is aimed to bring an easy way for Tier1 Coders with PHP Knowledges to add Multiplayer capabilities to their projects. (a lot of AppGameKit Tier1 Coders also knows the PHP Language).

Actually AppGameKit doesn't support UDP Sockets in Tier1 (which is the better way for realtime multiplayer games). The AppGameKit Multiplayer protocol only relies on TCP and have many commands already known by the community. So i have decided to use these built-in commands with reverse engineering and help from AppGameKit Team.

Except for the protocol used (TCP instead of UDP), the TCP protocol behind AppGameKit Multiplayer commands is well thought and already optimized (client variables, client list, etc etc...) . So it would be useless to rewrite another client side (Tier1) protocol which could be slower than the biuilt-in one. I am talking about "basic" multiplayer commands with no need of Prediction/reconciliation/interpolation.

For realtime multiplayer games, i have created a Tier1 library for client side, and a NetGamePlugin (in PHP which is simply included in the "core version" of my Multiplayer PHP Server) for server side with a client side events driven architecture to make the things easier (as it already done in core server side). You will see that very soon

The error should be to consider PHP as only a "web language" or a poor "script" language ... it can do almost the same things as C/C++ in most cases and it is cross-platform and well known by a lot of coders. It can uses linux forks, multi-thread, etc... . The only problem could be, indeed, the performance ((due to "only" ByteCode compilation but it produces very good results though but i have a lot of ideas to avoid these kinds of problems

For C++ i agree with you ... for C# i am more reserved (you can use mono or something like that but needs some requirements for Linux machines.. c# is still a Microsoft Language .
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 2nd Jun 2017 09:46
Yes you're right, PHP can be very fast performance wise.

As I've got you here to answer questions and you seem to know the AppGameKit stuff pretty well: Does anything speak against to use AppGameKit Tier 1 directly for server side stuff. I know this would run on Windows only, but this isn't an issue for me.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 2nd Jun 2017 09:56
You have a simple example project in {AGK Path}\Projects\Multiplayer\GettingStarted which shows you the server side and the client side in the same app
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 2nd Jun 2017 10:03 Edited at: 2nd Jun 2017 10:04
Yes I know, thanks! Question is, can it be used for classic multiplayer games where the server hosts, let's say, several hundreds of clients?

edit: Well I guess I'm just going to try.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 2nd Jun 2017 10:23 Edited at: 2nd Jun 2017 10:25
I don't know if TGC has done a benchmark with so much clients before with a Tier1 server. That's also a challenge for me to see if a PHP Server side version (with a always-on server box) can handle a lot of clients.

A Tier1 server can run on windows/mac/linux desktop (the problem is the miss of a command-line interpreter of the bytecode file (it may be a good feature !) ... so the server needs all the requirements of the AppGameKit Player (OpenGL Libs, etc,etc..). That's why it's difficult to keep a 24/24 AppGameKit Tier1 Server (but not impossible).

The only test i have done is with 16 Clients on the same machine, all connected to my Linux PHP server. and everything was working well

To demonstrate my NetGame Library, i will do something graphical with a ChatBox to encourage people to stay connected and see how it runs (and each person will be able to runs multiple instance of an AppGameKit Client if they want).
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 2nd Jun 2017 11:50
Thanks again!

So about your example. I think it's because I still not used any AppGameKit stuff really but why do you have to create a host in the basic example when you just want to do the client stuff there?
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 2nd Jun 2017 14:01
i'm not sure to understand your question ... ?
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 2nd Jun 2017 14:15
Well ya, just read my text and thought wow, what an awful question.

In your example you do something like:

networkId=HostNetwork("mynet",nickname$,ServerPort)

As far as I'm aware that's for creating a host. Some lines later you use the JoinNetwork commands which probably shall connect to your PHP server. So I just wondered what this HostNetwork command on the client side is for?
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 2nd Jun 2017 14:38 Edited at: 2nd Jun 2017 14:38
HostNetwork is only in the case of hosting a game directly in AGK. For example over a Wifi LAN (so you can use a NetworkName instead of IP Address because you can broadcast your game network across a LAN).

I have used that to make the reverse engineering in the same app between two AppGameKit app.

With my PHP Server, you don't need this command. only the JoinNetwork one with the IP/Port of PHP Server and a Nickname.
--------------------------------
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: 3rd Jun 2017 12:42 Edited at: 4th Jun 2017 19:11
The AppGameKit PHP Server has now a plugin called NetGamePlugin (NGP) to make it handle latencies and make games smoother !

- Some bugs have been fixed in the Core Server.
- NGP plugin added with a small example with an integrated chat.

First post updated with explanations and files !
--------------------------------
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: 4th Jun 2017 17:46
i have updated the basic race demo tier1 project which had a bug in the chat display after manual disconnection /reconnection
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 4th Jun 2017 19:06
Merci! This is getting better and better! Will try it soon and probably use it for my next project, kind of a tower defense game.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 4th Jun 2017 20:49
You're welcome !

Feel free to use it and make me few feedbacks
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Cor
AGK Developer
13
Years of Service
User Offline
Joined: 19th Dec 2010
Location: Its a trap!
Posted: 8th Jun 2017 19:01
im going to try out the latest build on my vps soon. i will post my feedback
Cor
AGK Developer
13
Years of Service
User Offline
Joined: 19th Dec 2010
Location: Its a trap!
Posted: 13th Jun 2017 03:23
Update, runs great on my vps! super cool !
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 13th Jun 2017 17:51
That was the aim !

Well done
--------------------------------
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: 9th Feb 2023 07:22
Hi all !

Due tu multiple requests, AppGameKit Multipler Server is now available on GitHub :

https://github.com/MikeMaxFR/AGKMultiplayerServer

I have no more time since many years to maintain it so, feel free to fork it and update it (and fix it for newer PHP Versions

Long life to TGC !

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 9th Feb 2023 20:08
Nice work! Added an AppGameKit Toolmaker badge

Login to post a reply

Server time is: 2024-04-24 10:55:04
Your offset time is: 2024-04-24 10:55:04