#1 Re: mORMot 1 » mORmot2 TSimpleHttpClient problem » 2022-03-27 05:08:33

Successfully used Lazarus win10 x64 TCurlhttp post data

#3 mORMot 1 » mORmot2 TSimpleHttpClient problem » 2022-03-26 02:47:22

touchvip
Replies: 3

When using TSimpleHttpClient post data, the last two characters will be sent less

#5 mORMot 1 » websocket under deepin linux » 2022-03-11 14:54:14

touchvip
Replies: 2

Use mORmot 2.0

unit uMainServer;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  mormot.net.relay,
  mormot.net.ws.core,
  mormot.net.server,
  mormot.net.ws.async,
  mormot.net.ws.server;

type

  { TWebSocketProtocolEcho }

  TWebSocketProtocolEcho = class(TWebSocketProtocolChat)
  protected
    procedure EchoFrame(Sender: TWebCrtSocketProcess; const Frame: TWebSocketFrame);
  end;

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    FServer:TWebSocketServer;
    procedure AddLog(sLog:String);

  public

  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TWebSocketProtocolEcho }

procedure TWebSocketProtocolEcho.EchoFrame(Sender: TWebCrtSocketProcess;
  const Frame: TWebSocketFrame);
begin
  case Frame.opcode of
    focContinuation:
        Form1.AddLog('Connected');
    focConnectionClose:
      Form1.AddLog('Disconnected');
    focText,focBinary:
      begin
       Form1.AddLog('Echoing: '+IntToStr(length(Frame.payload))+' bytes');
       SendFrame(Sender,Frame);
    end;
  end;

end;

{ TForm1 }

procedure TForm1.Button3Click(Sender: TObject);
begin
  Close;
end;

procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  FServer.Suspended:=False;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  FServer.Suspended:=True;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  protocol: TWebSocketProtocolEcho;
begin
  FServer := TWebSocketServer.Create('8888',nil,nil,'test',2,90000000 );
  protocol := TWebSocketProtocolEcho.Create('meow','');
  protocol.OnIncomingFrame := @protocol.EchoFrame;
  FServer.WebSocketProtocols.Add(protocol);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin

end;

procedure TForm1.AddLog(sLog: String);
begin
  Memo1.Lines.Add(sLog);
end;



end.
            

The above code is no problem to use under windows, and the server stops after sending a few messages under deepin linux.

Board footer

Powered by FluxBB