Oo yea i totally forgot about it angus man I been doing soo many late nights I dont no if am coming or going I not had any sleep today ill add debugging right now is there anyway I can contact you in real time ?

-----Original Message----- From: Simon Lewis
Sent: Friday, February 12, 2016 7:48 PM
To: Tw
Subject: Re: Generating userlist loop makes fake uers :(

List is generated for each room user is not disconnected from server only
redirected to a new room so the disconnect/connect would only work if person
left server fully but way system is designed users connect and then move
freely to many lobby's and rooms.

using Client[i].room OR client[i].lobby custom code added to socket and when
user joins/leave a lobby or a room it will rebuild list with there name in
or remove name but problem am having if a person leaves/disconnects due to
internet the list is not built correctly so has ClientSocket0002 as name its
a pain.

-----Original Message----- From: Simon Lewis
Sent: Wednesday, February 10, 2016 5:28 PM
To: Tw
Subject: Generating userlist loop makes fake uers :(

Hello All, Ok I got a problem with my code below it generates a userlist for
my chat system now the problem am having when it generates list and some one
is logging in or out while generating the list it will do fake names that
don't exist

function GetLobbyUsers(const aLobbyID: string): string;
     i: Integer;
     HostID: string;
     Result := '';
     for i := 0 to (SocketServer.ClientCount -1) do
       if (CompareText(SocketServer.Client[i].Lobby, aLobbyID) = 0) then
         HostID := '';
         HostID :=
SocketServer.Client[i].Name) = 0));
         SocketServer.Client[i].HasHighLatancy := False;
         SocketServer.Client[i].HasLowLatancy := False;
         SocketServer.Client[i].IsCheckingLatancy := True;
         Result := Result + 'š11œ' + aLobbyID + 'œ'
           + SocketServer.Client[i].Name + 'œ'
           + SocketServer.Client[i].Rank + 'œ'
           + SocketServer.Client[i].IconNumber + 'œ'
           + SocketServer.Client[i].BIconNumber + 'œ'
           + MBoolToStr(SocketServer.Client[i].IsAFK) + 'œ'
           + HostID + 'œ'
           + SocketServer.Client[i].HasTrophy + 'œ'
           + MBoolToStr(SocketServer.Client[i].IsDownloading) + 'œ'
           + MBoolToStr(SocketServer.Client[i].HasHighLatancy) + 'œ'
           + MBoolToStr(SocketServer.Client[i].HasLowLatancy) + 'œ'
           + MBoolToStr(SocketServer.Client[i].IsCheckingLatancy) + 'œ'
           + MBoolToStr(SocketServer.Client[i].IsBlocked) + 'œ';

I looked this up and it maybe this issue here, Being a chat system and
assuming SocketServer.Client is the list of connected users, is it possible
that users are connecting and disconnecting while you are still iterating
the list of users? If so, then SocketServer.ClientCount could be modified
while you are still iterating which would be very bad. This might explain
why you get fake users (i.e. disconnected while iterating) or missing users
(connected while still iterating). If this is the case, then you might need
to lock SocketServer.Client while you are iterating it i.e. prevent adding
or removing items from the list. Or maybe create a copy of
SocketServer.Client and iterate the copy. Regardless, performance is
critical so you need to iterate the list of users very quickly.

anyone got any advice or can help me recode to better solution thanks alot
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to