Class TClientThread (unit mtsrv2) |
Constructors |
Functions |
Properties |
Events |
Variables |
Constructors |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} { Create a new thread in the blocked state. This allow the user to register } { the client thread before it actually start working.
Functions |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} { Destroy the thread. Destroy the ClientWSocket if needed.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} { This method will be called by the main server thread to terminated a } { client thread.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} { This is the main thread routine. There is not much to do because TWSocket } { is event drive. So everythong to do is done inside an event handler, } { mostly the OnDataAvailable event handler which is triggered each time } { the client send something to the server.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} { This event handler is called when the client has sent some data to the } { server. It is here that we must place the client requests execution } { probably by assembling data in lines, parsing those lines for commands } { and executing the commands. Here for simplicity, we just echo back the } { data sent by the user, without doing anything serious. } { To demonstrate that blocking a thread do not block the others, when a '*' } { is received, we go to Sleep for a few seconds, effectively blocking the } { the client. But as we are multi-threaded, this do not block any other } { client. } { Do not forget to call the Synchronize method if you need to update the } { user interface. Only the main thread can do it (VCL is not thread safe).
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} { This event handler is called when the client connection is closed.
Properties |
Events |
Variables |