my code logic and for current iam talking only about grabbing lists of client for each channel
what i think about my code in old days i loop through the all connections to grab there current channel id and then send the list to each connection who have the similar channel id
Kod: Tümünü seç
for Index_Room := 0 to Connections.Count -1 do
begin
Break;
end;
for I := 0 to Connections.Count - 1 do
begin
Connection := TConnection(Connections.Items[I]);
if {(Connection.UniqueID <> UniqueID) and} (Connection.Channel = TConnection(Connections[Index_Room]).Channel) then
SL.Add(Connection.Name + Sep + IntToStr(Connection.UniqueID) + Sep);
end;
Kod: Tümünü seç
for I := 0 to Connections.Count - 1 do
begin
Connection := TConnection(Connections.Items[I]);
if (SL.Count > 0) then
begin
MS := TMemoryStream.Create;
try
SL.SaveToStream(MS);
MS.Position := 0;
SendCommandAndStream(Connection, 'GETLIST', MS);
// SendStream(TheConnection, Ms);
finally
MS.Free;
end;
end;
end;
finally
SL.Free;
end;
end;
and before i show example photo here is my handler on client side for channel change
Kod: Tümünü seç
if Command = 'Channel' then
begin
mMessage.Lines.Add(Params[1] + ' Change to Channel : ' + Params[2]);
SendCommand(TCPClient, 'GETLIST');
end;
