Forum > Networking and Web Programming

How to do Warfley simple websocket server sample on a form not in console

<< < (2/3) > >>

TRon:

--- Quote from: KodeZwerg on February 14, 2023, 01:54:47 am ---What is "Warfley simple websocket server sample" ?

--- End quote ---
Uhm... when I initially read the topic I got a very strange thought in my head that was about some form/appearance of user Warfley as a webserver socket  %)  :)

Mongkey:

--- Quote from: TRon on February 14, 2023, 06:45:13 am ---
--- Quote from: KodeZwerg on February 14, 2023, 01:54:47 am ---What is "Warfley simple websocket server sample" ?

--- End quote ---
Uhm... when I initially read the topic I got a very strange thought in my head that was about some form/appearance of user Warfley as a webserver socket  %)  :)

--- End quote ---

 :D :D

PierceNg:
Attached is a quick and dirty port of (half of) Warfley's console chat server example to LCL. Half because the console chat server does readln in a loop and sends what it reads from console to the connected client, but this LCL port only receives and never sends.

Built with Lazarus 2.2.0 with FPC 3.2.2 on Ubuntu 20.04. Tested with the console and web browser chat clients. It works on my computer.TM

Note: I changed the server port to 8080. Either change it back to 9080, or modify the clients' source to match.

I also made slight change to TWebSocketServer constructors to set socket to SO_REUSEADDR and SO_REUSEPORT. Let me know if you want the patch.

Mongkey:

--- Quote from: PierceNg on February 14, 2023, 01:05:45 pm ---Attached is a quick and dirty port of (half of) Warfley's console chat server example to LCL. Half because the console chat server does readln in a loop and sends what it reads from console to the connected client, but this LCL port only receives and never sends.

Built with Lazarus 2.2.0 with FPC 3.2.2 on Ubuntu 20.04. Tested with the console and web browser chat clients. It works on my computer.TM

Note: I changed the server port to 8080. Either change it back to 9080, or modify the clients' source to match.

I also made slight change to TWebSocketServer constructors to set socket to SO_REUSEADDR and SO_REUSEPORT. Let me know if you want the patch.

--- End quote ---

Thank you! pierceNg  8), this should be inside warfley websocket github sample.

Warfley:
As my name is in the titel, I feel as if I should also answer to this thread.

The thing about the examples is, they are not production ready code, not in the slightest. They are as minimal as possible to just show the basic functionality, but for creating a real server there is much more to it.

Also, the library was made to be as simple as possible in terms of architecture and it's own code (I originally tried to keep it under 1k lines of code, now it's already twice that because I keep adding features, but still quite slim), on the other hand this means that you need to do a lot yourself.
One of those things you need to handle yourself is thread synchronization and LCL integration.
The threading implementation is extremely basic, meaning if you choose to use the threaded handler (which I originally did not even intend to include, as everyone should make their own architecture), it will be executed in it's own thread, but any synchronization, e.g. with the LCL through syncronize or TThread.Queue must be done by the programmer themselves.

I intend on building a non blocking single threaded variant one day (which could then be for example used with a TTimer in an LCL application), but it's just one thing on an ever growing lists of ideas for the future

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version