heroiclabs / nakama-cpp

Generic C/C++ client for Nakama server.
https://heroiclabs.com/docs/cpp-client-guide
Apache License 2.0
69 stars 25 forks source link

Client and Realtime Client different host/ssl config #12

Closed AlexandreK38 closed 5 years ago

AlexandreK38 commented 5 years ago

Hi, Currently, if we need to use a different host and/or SSL value for the client and the realtime client, the only way is to create a client as usual, and then a second one to be able to call the createRtClient(...) method, as this:

DefaultClientParameters parameters;

parameters.serverKey = nk_serverKey;
parameters.host      = nk_host;
parameters.port      = nk_port;
parameters.ssl       = nk_ssl;

_client = createDefaultClient(parameters);

... 
DefaultClientParameters parameters;
parameters.host = nk_rt_host;
parameters.ssl  = nk_rt_ssl;

NClientPtr clientForRt = createDefaultClient(parameters);
_rtClient = clientForRt->createRtClient(nk_rt_port, transport);
// we should have done _client->createRtClient(nk_rt_port, transport) if it was on the same host/same ssl config for both;

Maybe there should be a way to create the realtime client with the parameters we want :)

mofirouz commented 5 years ago

Good shout - @Dimon4eg could you kindly fast-forward a fix for this?

Dimon4eg commented 5 years ago

Sure, it's easy. I can add this new method to DefaultClient:

virtual NRtClientPtr createRtClient(const DefaultClientParameters& parameters, NRtTransportPtr transport = nullptr) = 0;

Is this ok?

AlexandreK38 commented 5 years ago

It should be :)