I have a small problem with my code below when making my userlist when i connect a user it doubles the user name in list and am unable to find out why i posted my user list code below i be grateful if sumone can help me
when i login my names appear like so
Simon
Simon
function TMainServer.GetUsers(const RoomID: string): string;
var
i: Integer;
begin
Result := '';
for i := 0 to AudioComServer.Socket.ActiveConnections - 1 do
if LowerCase(AudioComServer.Socket.Connections[i].Room) = LowerCase(RoomID) then begin
Result := Result + 'šIDJœ'
+ RoomID + 'œ'
+ AudioComServer.Socket.Connections[i].Name + 'œ';
end;
end;
procedure TMainServer.JoinRoom(const RoomID, UserID: string; rSocket: TCustomWinSocket);
var
s, s1, s2: string;
i: Integer;
begin
rSocket.Name := UserID;
for i := 0 to AudioComServer.Socket.ActiveConnections - 1 do
if LowerCase(AudioComServer.Socket.Connections[i].Name) = LowerCase(UserID)
then begin
// add my id to list!
s2 := AudioComServer.Socket.Connections[i].Name;
s := 'šIDJœ' + RoomID + 'œ' + s2 + 'œ';
SendCommand(RoomID, s);
SendCommand(RoomID,'šjoinednoticeœ' + RoomID + 'œ' + UserID + 'œ');
end;
// get full room list!
s1 := 'šJoinRoomœ' + RoomID + 'œ' + GetUsers(RoomID);
rSocket.Room := RoomID;
SocketSendCodedString(rSocket, s1);
end;
thanks alot