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 / Network Help

Author
Message
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 27th Aug 2014 22:21 Edited at: 27th Aug 2014 22:39
I have setup a host device and various other devices joined as clients with no problems or connection issues. I am trying to maintain a Client List on all devices connected including the host.

When each client connects the ClientList populates with no problems on all devices. The problem is when one or many disconnect from the host I can't get rid of the disconnected clients (On the ClientList) on any of the remaining connected client devices. The host device repopulates the ClientList with no problems when one or many devices disconnects but all other clients keep the original ClientList (Including the clients that were deleted by the host.)

I guess my question is when the host device deletes a client do all other clients connected automatically refresh its internal clients list when GetNetworkFirstClient or GetNetworkNextClient commands are run on all other client devices after the host deletes them?

Here is my code:

Repopulate ClientList on Host Device:



Repopulate ClientList on all Client Devices:
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 28th Aug 2014 21:08
Clients must also check GetNetworkClientDisconnected and call DeleteNetworkClient if they detect a disconnected client. The host is really just a client with zero latency, it sets up a server in the background and then connects to itself, so everyone should be doing the same checks.
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 29th Aug 2014 15:47 Edited at: 29th Aug 2014 16:10
I didn't knew that too...

Now i wonder why AppGameKit don't reuse the ClientID.
So if there are 3 clients on the server.. now client 2 disconnected.
if someone join again he now have ClientID 4 instead of reuse the old ID and being client 2.

My question: is that intended and we have to bother with that or am i doing something wrong?

And what is GetNetworkServerID( iNetID ) for?
Is the server not always Client 1.
Can the server-client dissconnect and connect again somehow? so that GetNetworkServerID() returns somewhat greater 1.

Wouldn't it be better if the server is always clinet 1 and all subsequent clients reuse a given ID pool.

Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 29th Aug 2014 16:28
Quote: "So if there are 3 clients on the server.. now client 2 disconnected.
if someone join again he now have ClientID 4 instead of reuse the old ID and being client 2."


This is because disconnections close the network socket so it has to be cleaned up by deleting the old client, if the client reconnects it is assigned a new network socket so is given a new ID.

Quote: "And what is GetNetworkServerID( iNetID ) for?
Is the server not always Client 1."


Currently yes, the server is always ID 1

Quote: "Can the server-client dissconnect and connect again somehow?"


It should be impossible for the server client to disconnect from itself, if that happens then weird things might start happening.
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 29th Aug 2014 17:32 Edited at: 29th Aug 2014 17:38
Quote: "This is because disconnections close the network socket so it has to be cleaned up by deleting the old client, if the client reconnects it is assigned a new network socket so is given a new ID."


Do i understand that right? the ClientID just increases while clients join the server.
Sorry for my thread hijack.

My Server Code


My Client Code


Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 29th Aug 2014 17:39
Quote: "Do i understand that right? the ClientID just increases while clients join the server."


Yes
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 4th Sep 2014 02:31
This is not working as expected. It seems that only the host machine keeps an updated list of deleted/disconnected clients and when the same code is ran on any client device it does not remove deleted/disconnected clients.

However, every client device updates fine when new clients are added/connected. Just have a problem keeping an up to date list of deleted/disconnected clients.

Was this a bug or is there a fix?
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 4th Sep 2014 02:58 Edited at: 4th Sep 2014 03:00
i have an idea....

when your clients connect they can request an updated list of players from the server.... when a player disconnects the server can automate a message back to all clients with the current connected list.

this is the easiest way to do it.... manage it with net messages.

the servers list is the master list....let it spread the news of connected and disconnected players to your clients

just a thought....

bug? fix? dunno but you can always code yourself around these types of problems.

aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 4th Sep 2014 03:07
Thank you SoftMotion3D. I originally had the same idea as you previously posted but just wanted to know if there was a bug or if that command only updates deleted clients on the host machine.

Would be so much easier rather than coding back and forth every time a client joins or disconnects.
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 4th Sep 2014 03:10
yeah i know.... its a pain. i have run into the exact same problem and did the net message relay as a solution.

aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 4th Sep 2014 03:14
Which version of AppGameKit are you using? I noticed there was a recent update for AppGameKit Network....
Gonna try it soon.
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 4th Sep 2014 05:05
i havent actualy played with networking in v2 yet....just in the v1 but i didnt think anything was changed since then.

if anything has its probably only minor changes.

The new compiler is amazing in v2 and i would recomend jumping on the band wagon sooner then later! Its helped me find allot of errors within my code that agkv1 didnt notice and ran anyways.

Login to post a reply

Server time is: 2024-11-25 09:25:21
Your offset time is: 2024-11-25 09:25:21