#1 2019-05-05 03:27:06

Bianco
Member
From: Brasil
Registered: 2018-03-05
Posts: 3

Simple WebSocket sample 31 - Wrong number of parameters???

Hello everyone!

I am having trouble compiling Project31SimpleEchoServer.

...
  Server := TWebSocketServer.Create('8888',nil,nil,'test');
  try
    protocol := TWebSocketProtocolEcho.Create('meow','');
==> protocol.OnIncomingFrame := protocol.EchoFrame;
    Server.WebSocketProtocols.Add(protocol);
    TextColor(ccLightGreen);
    writeln('WebSockets Chat Server running on localhost:8888'#13#10);
    TextColor(ccWhite);
    writeln('Please load Project31SimpleEchoServer.html in your browser'#13#10);
    TextColor(ccLightGray);
    writeln('Press [Enter] to quit'#13#10);
    TextColor(ccCyan);
    readln;
  finally
    Server.Free;
  end;
...

Errors:

  • Project31SimpleEchoServer.dpr(46,44) Error: Wrong number of parameters specified for call to "EchoFrame"Project31SimpleEchoServer.dpr(19,34) Error: Found declaration:   

  • EchoFrame(THttpServerResp;const TWebSocketFrame);


Could anyone tell me the reason? as
"procedure TWebSocketProtocolEcho.EchoFrame (Sender: THttpServerResp; const Frame: TWebSocketFrame);"
is compatible with the type
TOnWebSocketProtocolChatIncomingFrame = procedure (Sender: THttpServerResp; const Frame: TWebSocketFrame) of object;

I use Lazarus 2.1.0 FPC 3.3.1 I386-linux (32bits)

Offline

#2 2019-05-05 13:55:34

Bianco
Member
From: Brasil
Registered: 2018-03-05
Posts: 3

Re: Simple WebSocket sample 31 - Wrong number of parameters???

Hello, I already remembered how to contour this in fpc/Linux, kkk ...

    protocol.OnIncomingFrame := @protocol.EchoFrame;

had already used this in another project, here is a better explanation on how this works:
https://lazarus-ccr.sourceforge.io/fpcd … 10001.2.75

Last edited by Bianco (2019-05-05 14:20:25)

Offline

#3 2019-05-05 17:12:03

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,544
Website

Re: Simple WebSocket sample 31 - Wrong number of parameters???

This project is created for Delphi. The simplest way to compile it using Lazarus is to switch syntax mode to -MDelphi (project-options-compiler options-parsing-syntax mode).
After this you do not need any changes in sources

Offline

#4 2019-05-05 17:25:26

Bianco
Member
From: Brasil
Registered: 2018-03-05
Posts: 3

Re: Simple WebSocket sample 31 - Wrong number of parameters???

mpv wrote:

This project is created for Delphi. The simplest way to compile it using Lazarus is to switch syntax mode to -MDelphi (project-options-compiler options-parsing-syntax mode).
After this you do not need any changes in sources

I had already tested this project in Delphi with windows, I did not know that this option "-MDelphi" solves this in FPC / Lazarus good to know.
I will use it this way, Thank you very much @mpv!

Last edited by Bianco (2019-05-05 17:25:51)

Offline

Board footer

Powered by FluxBB