Seamless Godot server builds!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
and look at that our message was received on the server and you can tell because we passed in our client ID and the server sent a message right back that says right back at you client count number [Music] one I had my first look at the gdau game engine last week I actually recorded the unboxing of it if you will and it's basically me just fumbling through the editor trying to figure out how the interface works and where everything goes and I actually imported an asset and created A Primitive so if you're looking for basically a gdau hello world go check out that video but because this is mostly a multiplayer Focus Channel I wanted to dive in and and see what it could do and the first thing I did was I created a websocket connection between a gdau client and a AWS Lambda server or they can talk back and forth and send messages while that might be a good place to start I wanted to see what kind of multiplayer functionality gdau had out of the box other than websockets do they have built-in support for rpcs and sync variables and that sort of thing so diving into their multiplayer documentation you can see that they've got a high and lowlevel API they support both TCP and UDP and they basically encourage you to use their UDP abstraction because it's easy to use yeah they you lose a little bit of fine grain functionality but you still have access to those lower level apis if you want and if you read through here they do talk about their midlevel abstraction and the scripts and classes that they use to encapsulate all this functionality they talk about their hosting resources and how you can set those things up and because I was interested in setting up a client in server I took a look at the initializing the network section they have how to set up a client and server respectively but I felt like this wasn't a complete setup like I felt like there was something missing from this documentation so I went out to the internet and tried to find other resources about how you can get a multiplayer client server up and running like I wanted to see some other people's examples well that ended up being a waste of time because ultimately it really just is this and I and I was really impressed by how quickly it was to actually get something up and running so at the top level we have this startup control node which may not be ideal for a multiplayer setup in general but for this hello world it's okay and inside I have a client status panel and also a place to receive messages from the server and the send message button down here will just send the same canned message to the server and if we have a look at the code this is it this is the whole Network functionality we have to create a client in server and the first thing that happens of course is this ready function is called then I check for any command line arguments and where this becomes helpful is if you're trying to execute a Linux executable on a server like an ec2 instance you can pass in a command line argument like in this case a-s to indicate to it to run as a server so that's what we're doing here and if there's no Das s if there's no command line argument here it just assumes to start as a client so let's take a look at at that start server and start client functionality the first thing we do with the server is we set up some callbacks for when a client connects or disconnects and those are down here at the bottom and all I'm doing is just printing out hey the client connected or hey the client disconnected with the client ID that connected or disconnected and with the client if we connect to the server we just update the status to say we connected and if we disconnect we just print out a disconnected message so if we come back up to the start server functionality the only thing we're doing here is we create This Server object check with this enet multiplayer Pier we tell the server to start on Port 80 and we only allow two clients and to make sure that gdau knows this is a server configuration we set this multiplayer peer object to the server configuration we just created and then for the client we update the status that hey we're connecting to a client and then we create another multiplayer perer object we tell it the IP and Port of the server we need to connect to and then we set this multiplayer peer object to the client we just created so that's it that is the complete setup we need for the server and client to start properly so once the client has connected to the server we can begin sending RPC messages so let's take a look so the first RPC here can only be called from clients that means it's going to be called from a client but executed on the server and we know that because we added this anyer mode to the RPC annotation and we also have a check here that says is server and that might be redundant in this case because we already have this any peer mode but I just wanted to make sure that this is only executing on the server so once this RPC is called from a client it prints out a message on the server it updates how many calls we've had from the client and then we respond to the client hey we got your message this RPC call to the client would actually call to all clients because I don't have a specific client ID selected here but that's okay because this is just a hello world and the next RPC we have is only called from the server and we know that because we have this Authority mode set in the RPC annotation and once we receive this message from the client we print out the message and then we also add the message to our UI and the way I'm triggering these rpcs to be called you can hit the send message button on our interface to call this function down here and it will print out that we're sending a message and then it actually makes the RPC call to the server so when you click on the send message to server button it calls this server RPC right here which is up here it prints it out on the server updates how many calls we have and then it sends a message right back to the client RPC which is down here and then we update our status text so let's have a quick demo of what that looks like so the first thing we need to do is export this project for the server so you go up to export and if you don't have a server option here you hit add and then you add this Linux option and then this will show up you don't have anything to do over on the initial options page because the architecture is x86 64 by default so come over to resources and select the resources that you want want to include so if you had some client side objects that you didn't want to include in your server side build because you want to reduce the cost of of those server side builds you can uncheck them here so I have everything checked because everything is needed and then all you do is hit export project I'm just naming it server and you hit save close that out and as you can see here these are the files that are created and this is what we're going to upload to our ec2 server and if you're curious on how to set up an ec2 instance to push out your server I actually did another video it might be Unity specific but at least the ec2 part is the same so go check that out if you're curious on how to set up an ec2 instance to get it ready for your gdau server and to upload it to the server I'm using SCP and of course I use ec2 user at the IP address of the server so let's go ahead and upload that okay great and let's go ahead and SSH into that server great so now I'm in the ec2 server and if you want to take a look at the server folder is exactly what we just built so let's go ahead and run the gdos server and you can see here that I passed in the- S command line argument to indicate that it needs to run as the server version okay so now the gdau server is running on the ec2 instance and you can see it printed out the- s argument to indicate to start as a server so let's go ahead and run the client so as soon as the client starts it's going to try to connect to the server so if the server is not running it'll just kind of sit there so make sure your server is running for this test before you start the client so keep an eye over in This Server console here because as soon as I hit play it's going to show the client is connected and there it is so we have our status updated that says we connected to the server from the client and our server has indicated that Yep this client has connected so if we hit send message to server it'll send a canned message so let's go ahead and do that and look at that our message was received on the server and you can tell because we passed in our client ID and the server sent a message right back that says right back at you client count number one so number one just means how many messages we've sent so if I send another message there's two three four and of course if you look down in the output you can see we've sent four messages there and of course if we hit this x it will disconnect us from the server and you can see here our server is printed out that that client has disconnected and if you want to just kill that gdau server just go ahead and hit contrl C and we're done and then go ahead and type exit to get out of there so I know this is a pretty simple basic setup for client server but it is a hello world but think about it right out of the box gdau gives you the ability to export a dedicated Linux server build that we were able to immediately put on an ec2 in and have a connection between the client server you had access to rpcs they do have uh like sync VAR functionality and if you are using ec2 to test make sure you shut it down when you're done using it because you don't want to burn through your free tier status and if you've enjoyed this video let me know with a like And subscribe and keep me posted on whatever little Network projects you've been able to spin off with this new gdau engine and our journey through this learning experience this collective learning experience anyways hope you enjoyed it thanks for watching
Info
Channel: Battery Acid Dev
Views: 6,943
Rating: undefined out of 5
Keywords:
Id: 7YkhYTNuLU4
Channel Id: undefined
Length: 9min 28sec (568 seconds)
Published: Sat Sep 30 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.