mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 15:55:54 +01:00
This commit is contained in:
parent
ade6685eaa
commit
fbb7315114
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user