From fbb73151142991c96504898533a793b8fc6a757a Mon Sep 17 00:00:00 2001 From: dgaspary Date: Thu, 2 Dec 2010 23:16:39 +0000 Subject: [PATCH] --- .../GlobalDemoLazarus/ReceiverForm.lfm | 2 +- .../GlobalDemoLazarus/ReceiverForm.lrs | 2 +- .../GlobalDemoLazarus/ReceiverForm.pas | 211 +++++++++--------- 3 files changed, 107 insertions(+), 108 deletions(-) diff --git a/examples/GlobalDemo/GlobalDemoLazarus/ReceiverForm.lfm b/examples/GlobalDemo/GlobalDemoLazarus/ReceiverForm.lfm index d2d8ce94..19bd1dab 100644 --- a/examples/GlobalDemo/GlobalDemoLazarus/ReceiverForm.lfm +++ b/examples/GlobalDemo/GlobalDemoLazarus/ReceiverForm.lfm @@ -16,7 +16,7 @@ object Form1: TForm1 Visible = True object Edit1: TEdit Left = 8 - Height = 23 + Height = 25 Top = 22 Width = 144 Font.Height = -13 diff --git a/examples/GlobalDemo/GlobalDemoLazarus/ReceiverForm.lrs b/examples/GlobalDemo/GlobalDemoLazarus/ReceiverForm.lrs index bd378dcb..b1f420f6 100644 --- a/examples/GlobalDemo/GlobalDemoLazarus/ReceiverForm.lrs +++ b/examples/GlobalDemo/GlobalDemoLazarus/ReceiverForm.lrs @@ -6,7 +6,7 @@ LazarusResources.Add('TForm1','FORMDATA',[ +'nu'#0#7'Caption'#6#13'Receiver Form'#12'ClientHeight'#3'+'#1#11'ClientWidth' +#3#238#2#11'Font.Height'#2#245#9'Font.Name'#6#6'Tahoma'#7'OnClose'#7#9'FormC' +'lose'#8'OnCreate'#7#10'FormCreate'#10'LCLVersion'#6#6'0.9.29'#7'Visible'#9#0 - +#5'TEdit'#5'Edit1'#4'Left'#2#8#6'Height'#2#23#3'Top'#2#22#5'Width'#3#144#0#11 + +#5'TEdit'#5'Edit1'#4'Left'#2#8#6'Height'#2#25#3'Top'#2#22#5'Width'#3#144#0#11 +'Font.Height'#2#243#9'Font.Name'#6#6'Tahoma'#10'Font.Style'#11#6'fsBold'#0#10 +'ParentFont'#8#8'TabOrder'#2#0#4'Text'#6#14'/topic/mytopic'#0#0#7'TButton'#7 +'Button1'#4'Left'#3#8#1#6'Height'#2#25#3'Top'#2#22#5'Width'#2'\'#7'Caption'#6 diff --git a/examples/GlobalDemo/GlobalDemoLazarus/ReceiverForm.pas b/examples/GlobalDemo/GlobalDemoLazarus/ReceiverForm.pas index 988d585f..06889da0 100644 --- a/examples/GlobalDemo/GlobalDemoLazarus/ReceiverForm.pas +++ b/examples/GlobalDemo/GlobalDemoLazarus/ReceiverForm.pas @@ -1,111 +1,110 @@ unit ReceiverForm; -{$MODE Delphi} - -interface - -uses - {Windows,} - Messages, - SysUtils, - Classes, - Graphics, - Controls, - Forms, - Dialogs, - StdCtrls, - StompClient, - StompTypes, - ExtCtrls, LResources; - -type - TForm1 = class(TForm, IStompClientListener) - Edit1: TEdit; - Button1: TButton; - Button5: TButton; - Memo1: TMemo; - Button3: TButton; - Button4: TButton; - Button6: TButton; - procedure FormClose(Sender: TObject; var Action: TCloseAction); - procedure Button1Click(Sender: TObject); - procedure Button5Click(Sender: TObject); - procedure Button4Click(Sender: TObject); - procedure Button3Click(Sender: TObject); - procedure Button6Click(Sender: TObject); - procedure FormCreate(Sender: TObject); - - private - stomp: IStompClient; - th: TStompClientListener; - - public - procedure OnMessage(StompFrame: IStompFrame); - end; - -var - Form1: TForm1; - -implementation - -uses - DateUtils; - -procedure TForm1.Button1Click(Sender: TObject); -begin - stomp.Subscribe(Edit1.Text); -end; - -procedure TForm1.Button3Click(Sender: TObject); -begin - stomp.Unsubscribe(Edit1.Text); -end; - -procedure TForm1.Button4Click(Sender: TObject); -begin - th.StopListening; - FreeAndNil(th); - stomp.Disconnect; -end; - -procedure TForm1.Button5Click(Sender: TObject); -begin - stomp.Subscribe(Edit1.Text, amAuto, StompUtils.NewHeaders.Add(TStompHeaders.NewDurableSubscriptionHeader('pippo'))); -end; - -procedure TForm1.Button6Click(Sender: TObject); -begin - stomp.Connect('localhost', 61613, 'myclientid'); - th := TStompClientListener.Create(stomp, Self); -end; - -procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); -begin - if assigned(stomp) then - begin - if assigned(th) then - begin - th.StopListening; - th.Free; - end; - stomp.Disconnect; - stomp := nil; - end; -end; - -procedure TForm1.FormCreate(Sender: TObject); -begin - stomp := TStompClient.Create; -end; - -procedure TForm1.OnMessage(StompFrame: IStompFrame); -begin - Caption := DateTimeToStr(StompUtils.TimestampAsDateTime(StompFrame.GetHeaders.Value('timestamp'))); - Memo1.Lines.Add(StompFrame.GetBody); -end; - +{$MODE Delphi} + +interface + +uses + {Windows,} + Messages, + SysUtils, + Classes, + Graphics, + Controls, + Forms, + Dialogs, + StdCtrls, + StompClient, + StompTypes, + ExtCtrls, LResources; + +type + TForm1 = class(TForm, IStompClientListener) + Edit1: TEdit; + Button1: TButton; + Button5: TButton; + Memo1: TMemo; + Button3: TButton; + Button4: TButton; + Button6: TButton; + procedure FormClose(Sender: TObject; var Action: TCloseAction); + procedure Button1Click(Sender: TObject); + procedure Button5Click(Sender: TObject); + procedure Button4Click(Sender: TObject); + procedure Button3Click(Sender: TObject); + procedure Button6Click(Sender: TObject); + procedure FormCreate(Sender: TObject); + + private + stomp: IStompClient; + th: TStompClientListener; + + public + procedure OnMessage(StompFrame: IStompFrame); + end; + +var + Form1: TForm1; + +implementation + +uses + DateUtils; + +procedure TForm1.Button1Click(Sender: TObject); +begin + stomp.Subscribe(Edit1.Text); +end; + +procedure TForm1.Button3Click(Sender: TObject); +begin + stomp.Unsubscribe(Edit1.Text); +end; + +procedure TForm1.Button4Click(Sender: TObject); +begin + th.StopListening; + FreeAndNil(th); + stomp.Disconnect; +end; + +procedure TForm1.Button5Click(Sender: TObject); +begin + stomp.Subscribe(Edit1.Text, amAuto, StompUtils.NewHeaders.Add(TStompHeaders.NewDurableSubscriptionHeader('pippo'))); +end; + +procedure TForm1.Button6Click(Sender: TObject); +begin + stomp.Connect('localhost', 61613, 'myclientid'); + th := TStompClientListener.Create(stomp, Self); +end; + +procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); +begin + if assigned(stomp) then + begin + if assigned(th) then + begin + th.StopListening; + th.Free; + end; + stomp.Disconnect; + stomp := nil; + end; +end; + +procedure TForm1.FormCreate(Sender: TObject); +begin + stomp := TStompClient.Create; +end; + +procedure TForm1.OnMessage(StompFrame: IStompFrame); +begin + Caption := DateTimeToStr(StompUtils.TimestampAsDateTime(StompFrame.GetHeaders.Value('timestamp'))); + Memo1.Lines.Add(StompFrame.GetBody); +end; + initialization {$i ReceiverForm.lrs} - {$i ReceiverForm.lrs} -end. +end.