Broadcast a message using ICS

dolphin King
dolphin King used Ask the Experts™
on
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 ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Joan LewisBusiness Analyst Finance

Commented:
Hello Dolphin King,

Just go with this source it might help you to in right way: http://www.w3eoc.org/usingics213
Software architect
Top Expert 2012
Commented:
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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial