synopse / mORMot

Synopse mORMot 1 ORM/SOA/MVC framework - Please upgrade to mORMot 2 !
https://synopse.info
785 stars 323 forks source link

THttpApiWebSocketConnection.PrivateData Property value cannot be set. #438

Closed ysair closed 1 year ago

ysair commented 1 year ago
procedure TForm1.OnDisconnect(const Conn: THttpApiWebSocketConnection;
  aStatus: WEB_SOCKET_CLOSE_STATUS; aBuffer: Pointer; aBufferSize: Cardinal);
begin
  if Assigned(Conn.PrivateData) then
  begin
    //Conn.PrivateData  :=  nil;  //compile error: E2064 Left side cannot be assigned to
    PHttpApiWebSocketConnection(@Conn).PrivateData  :=  nil;
  end;
  TSynLog.Add.Log(sllInfo, '% - disconnect', [Conn.Index]);
end;

Can I change it to

THttpApiWebSocketConnection = record ... property PrivateData: pointer read fPrivateData write fPrivateData; // write SetPrivateData?

synopse commented 1 year ago

Since it is defined as "const" it does not seem very correct to change its content.

I will fix the callbacks signature to use "var".

ysair commented 1 year ago

nice, this code works