Broadcast a message using ICS

i dont know if i do it right but here what i am doing


type
  TMyClient = class(TWSocketClient)
  private
    Connected: TDateTime;
    UniqueID: DWORD;
    procedure ConnectionDataAvailable(Sender: TObject; ErrCode: Word);

  public
    constructor Create(AOwner : TComponent); override;
    destructor Destroy; override;
    procedure Display(Msg: String);
  end;


procedure TMyClient.BroadcastMessage(const message : string);
var
Client : TMyclient;
Server : TWSocketServer;
I : integer;
begin
Server := mainserver.server;
for I := 0 to server.ClientCount -1 do
begin
  Client := TMyclient(server.Client[I]);
//do send
end;

end;

Open in new window


is my broadcast is correct ? i think its totally wrong because i use Server := mainserver.server; i dont feel good about this i am new to ics where to access the context list same way in indy with connection class ?
dolphin KingAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joan LewisBusiness Analyst FinanceCommented:
Hello Dolphin King,

Just go with this source it might help you to in right way: http://www.w3eoc.org/usingics213
0
Sinisa VukSoftware architectCommented:
Joan,
ICS (in a Delphi world) stands for Internet Component Suite.

Dolphin K.,
broadcast message can be done using server which holds all connected clients through open channel ...
procedure TMyClient.BroadcastMessage(const message : string);
var
Client : TMyclient;
Server : TWSocketServer;
I : integer;
begin
  Server := mainserver.server;
  for i:=1 to Server.ClientCount do
      begin
        try
          Client := TMyclient(Server.Client[i-1]);
          if (Client.State in [wsConnected]) then
            Client.SendStr(message);
        except
        end;
      end;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.