Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : Re: TIDCmdTCPServer
| Subject: | Re: TIDCmdTCPServer |
| Posted by: | "Roberto Colpani" (roberto.colpa..@vetrariafratellicolpani.it) |
| Date: | Wed, 14 Jun 2006 15:48:25 |
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> ha scritto nel messaggio
news:448ef2c7@newsgroups.borland.com...
>
> "Roberto Colpani" <roberto.colpani@vetrariafratellicolpani.it> wrote in
> message news:448ee354@newsgroups.borland.com...
>
>> it show the normareply.text of the first commandhandler. Why?
>
> Please show your actual server code and setup. You probably are not
> handling the replies properly on the server side.
>
>
> Gambit
>
>
This is my code:
object MainForm: TMainForm
Left = 0
Top = 0
Caption = 'MainForm'
ClientHeight = 280
ClientWidth = 426
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnDestroy = FormDestroy
PixelsPerInch = 120
TextHeight = 16
object TrayIcon1: TTrayIcon
PopupMenu = PopupMenu1
Visible = True
Left = 8
Top = 8
end
object PopupMenu1: TPopupMenu
Left = 40
Top = 8
object Showconnecteduser1: TMenuItem
Caption = 'Show connected user'
OnClick = Showconnecteduser1Click
end
object Exit1: TMenuItem
Caption = '&Exit'
OnClick = Exit1Click
end
end
object ServerTango: TIdCmdTCPServer
Active = True
Bindings = <>
DefaultPort = 1050
CommandHandlers = <
item
CmdDelimiter = ';'
Command = 'RegisterUser'
Disconnect = False
Name = 'TIdCommandHandler0'
NormalReply.Code = '200'
NormalReply.Text.Strings = (
'')
ParamDelimiter = ' '
Tag = 0
OnCommand = IdCmdTCPServer1CommandHandlers0Command
end
item
CmdDelimiter = ';'
Command = 'UnRegisterUser'
Disconnect = False
Name = 'TIdCommandHandler1'
NormalReply.Code = '200'
ParamDelimiter = ' '
Tag = 0
OnCommand = IdCmdTCPServer1CommandHandlers1Command
end
item
CmdDelimiter = ';'
Command = 'Prova'
Disconnect = False
Name = 'TIdCommandHandler2'
NormalReply.Code = '300'
NormalReply.Text.Strings = (
'questa '#232' una prova')
ParamDelimiter = ' '
Tag = 0
OnCommand = IdCmdTCPServer1CommandHandlers2Command
end>
ExceptionReply.Code = '500'
ExceptionReply.Text.Strings = (
'Unknown Internal Error')
Greeting.Code = '200'
Greeting.Text.Strings = (
'')
HelpReply.Code = '100'
HelpReply.Text.Strings = (
'')
MaxConnectionReply.Code = '300'
MaxConnectionReply.Text.Strings = (
'Too many connections. Try again later.')
ReplyTexts = <>
ReplyUnknownCommand.Code = '400'
ReplyUnknownCommand.Text.Strings = (
'Unknown Command')
Left = 72
Top = 8
end
end
procedure TMainForm.Exit1Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
UserList := TObjectList.Create(True);
end;
procedure TMainForm.FormDestroy(Sender: TObject);
begin
UserList.Free;
end;
procedure TMainForm.IdCmdTCPServer1CommandHandlers0Command(ASender:
TIdCommand);
Var
AUser: TConnectedUser;
begin
{ Command: 'RegisterUser;UserName ComputerName'}
if Assigned(ASender.Params) then
begin
AUser := TConnectedUser.Create(ASender.Params[0], ASender.Params[1]);
UserList.Add(AUser);
end;
end;
procedure TMainForm.IdCmdTCPServer1CommandHandlers1Command(ASender:
TIdCommand);
Var
Counter, Index: Integer;
AUser: TConnectedUser;
begin
{ Command: 'UnRegisterUser;UserName ComputerName'}
Index := 0;
for Counter := 0 to UserList.Count - 1 do
begin
AUser := TConnectedUser(UserList[Counter]);
if (AUser.UserName = ASender.Params[0]) and (AUser.ComputerName =
ASender.Params[1]) then
begin
UserList.Remove(AUser);
Break;
end;
Index := Index + 1;
end;
end;
procedure TMainForm.IdCmdTCPServer1CommandHandlers2Command(ASender:
TIdCommand);
begin
ASender.SendReply;
end;
procedure TMainForm.Showconnecteduser1Click(Sender: TObject);
Var
Counter: Integer;
AUser: TConnectedUser;
begin
if UserList.Count = 0 then
begin
showmessage('Nessun utente connesso');
end
else
begin
for counter := 0 to UserList.Count - 1 do
begin
AUser := TConnectedUser(UserList[Counter]);
showmessage(AUser.UserName + '; ' + AUser.ComputerName);
end;
end;
end;
end.
My goal is:
User A send to the TIDTCPServer a notification that is going to do
something; the TIDTCPServer replay to User A that it have receives the
notification and sent to the other user that User A is going to do this
operation; when User A is finish to do the operation send a notification to
the server that send a message that it have receive the notification and
send to the other user connected that User A has finish.
I thought that with sendreply method I could do this thing but now I am