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 / Networking Client Loop Bricks Server Client Count.

Author
Message
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 2nd Dec 2017 02:30 Edited at: 2nd Dec 2017 02:43
Following this example with C++ equivalents:
https://www.appgamekit.com/documentation/guides/8_networking.htm

The function agk::GetNetworkNumClients(iNetID) returns a 1 when the network is created (which is correct as the server also counts as 1 connection) However whenever a client of a 2nd application instance connects, the server does not update, still showing that theres only one connection. However the client reports 2 connections with the same function after connection.




So the above loop is straight from the examples in the AppGameKit docs. It is supposed to go through every connected client on the AppGameKit server hosted network (in the example it was checking for disconnected clients and deleting them from the connection but I'm also using this for adding player data to an array).
Now here's the weird part. IF in the server, I'm going to place the above code within this if statement:



Then the server WILL report 2 connections. So for some reason if I start cycling through the clients on the network ONLY after there's more than 1 connection it works. I'm not even doing anything with these connections. I'm just reading their ID. that's all.
The logic of the loop above should make sense. If the server is the only one online then it would still return a 1 connection. 1 (xx=1) is equal to 1 (return of the function) so it should still get the ID from GetNetworkFirstClient(iNetID);.
But it's not even that I'm not getting the id from GetNetworkFirstClient(iNetID);. It's that the server still reports only 1 connection.

I can also do this instead (leave the loop but comment out all the ID retrieval stuff):


This will effectively ALSO report 2 connections. So something about the agk::GetNetworkNextClient(iNetID); is screwing up the engine.
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 2nd Dec 2017 06:20
Ok just wanted to update. I got it to work

Instead of a For loop I ended up using a Do While loop

The functions:
GetNetworkFirstClient
GetNetworkNextClient

Apparently MUST go through every single client entry or the networking code won't resume. It get stuck.
The function will actually return a 0 Once it reaches the end of the list so I ended up doing

Do {
get id of the First or Next client
do stuff
} {while id != 0}
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 6th Dec 2017 23:42
indeed, this is the good (and only) method

Login to post a reply

Server time is: 2024-04-26 13:54:12
Your offset time is: 2024-04-26 13:54:12