Mutliplayer
#1
Apost 
I figured that this is a new project, and I just have to say I love it!
I guess I wanna make a multiplayer game, and I have seen in the API that there are some server client functions build into this framework.
But for the rest no tutorials or documentation besides the api.
So is it possible to build a multiplayer game with MurlEngine?

Many thnxs in advanced and keep up the good work ;-)
Reply
#2
Apost 
(23 Aug 2013, 0:43)SteZZz Wrote: I figured that this is a new project, and I just have to say I love it!
I guess I wanna make a multiplayer game, and I have seen in the API that there are some server client functions build into this framework.
But for the rest no tutorials or documentation besides the api.
So is it possible to build a multiplayer game with MurlEngine?

Many thnxs in advanced and keep up the good work ;-)

Thanks for your reply!
Yes it is possible to create a multiplayer game and you are right, there is currently no tutorial for network support available (that's one of the reasons why the engine is still in public beta).

We have some regression tests using the client/server classes, see the attached source files. Unfortunately the test code is undocumented, but if you are familiar with C++ programming and networking you should get the idea.

To add the classes to a tutorial logic code you can simply implement the following (hello_world v3):

In your hello_world_logic.h file:

#include "app_socket_client_logic.h"
#include "app_socket_server_logic.h"

class HelloWorldLogic : public Logic::BaseProcessor
{
public:
HelloWorldLogic(Logic::IFactory* factory);
virtual ~HelloWorldLogic();

protected:
virtual Bool OnInit(const Logic::IState* state);

private:
SocketClientLogic mSocketClientLogic;
SocketServerLogic mSocketServerLogic;
};

In your hello_world_logic.cpp file:

App::HelloWorldLogic::HelloWorldLogic(Logic::IFactory* factory)
: BaseProcessor(factory)
, mSocketClientLogic(factory)
, mSocketServerLogic(factory)
{
}

Bool App::HelloWorldLogic::OnInit(const Logic::IState* state)
{
IAppConfiguration* config = state->GetAppConfiguration();
if (config->GetPlatformConfiguration()->IsTargetClassMatching(IEnums::TARGET_CLASS_COMPUTER))
{
AddChild(mSocketServerLogic);
}
else
{
AddChild(mSocketClientLogic);
}

...
}

Don't forget to add the app_socket_client_logic.cpp and app_socket_server_logic.cpp to the project / makefile.

This example starts the server on a desktop computer and the client on mobile devices.

The test shows only some console outputs, but you can see how it works.

The test server uses broadcasts to announce to the clients, this works only within local networks (depending on your router configuration), so if you want to connect via wide area networks you have to specify the server name/ip on the client side.

I hope this will help you for now.

best regards
Andy


Attached Files
.zip   murl_net_client_server_sample.zip (Size: 4.48 KB / Downloads: 1)
Reply


Forum Jump:


Copyright © 2011-2017 Spraylight GmbH.