Browse Source

fcl-web: comments

mattias 3 years ago
parent
commit
0b24d5f92e
1 changed files with 20 additions and 21 deletions
  1. 20 21
      packages/fcl-web/src/websocket/fpcustwsserver.pp

+ 20 - 21
packages/fcl-web/src/websocket/fpcustwsserver.pp

@@ -102,7 +102,7 @@ Type
     procedure ConnectionDone(Sender: TObject);
     procedure ConnectionDone(Sender: TObject);
   public
   public
     Type
     Type
-        { TWSConnectionThread }
+      { TWSConnectionThread }
       TWSConnectionThread = Class(TThread)
       TWSConnectionThread = Class(TThread)
       private
       private
         FConnection: TWSServerConnection;
         FConnection: TWSServerConnection;
@@ -248,7 +248,7 @@ Type
     Property OnAllow : TWSAllowConnectionEvent Read FOnAllow Write FOnAllow;
     Property OnAllow : TWSAllowConnectionEvent Read FOnAllow Write FOnAllow;
     // Called when a text message is received.
     // Called when a text message is received.
     property OnMessageReceived: TWSMessageEvent read FOnMessageReceived write FOnMessageReceived;
     property OnMessageReceived: TWSMessageEvent read FOnMessageReceived write FOnMessageReceived;
-    // Called when a connection is disconnected. Sender is Self
+    // Called when a connection is disconnected. Sender is TWSServerConnection
     property OnDisconnect: TNotifyEvent read FOnDisconnect write FOnDisconnect;
     property OnDisconnect: TNotifyEvent read FOnDisconnect write FOnDisconnect;
     // Called when a control message is received.
     // Called when a control message is received.
     property OnControlReceived: TWSControlEvent read FOnControl write FOnControl;
     property OnControlReceived: TWSControlEvent read FOnControl write FOnControl;
@@ -611,24 +611,6 @@ begin
     Raise EWebsocketServer.Create(SErrServerActive);
     Raise EWebsocketServer.Create(SErrServerActive);
 end;
 end;
 
 
-
-{ TWSThreadedConnectionHandler }
-
-procedure TWSThreadedConnectionHandler.CheckIncomingMessages;
-begin
-  // Do nothing
-end;
-
-procedure TWSThreadedConnectionHandler.ConnectionDone(Sender: TObject);
-begin
-  RemoveConnection(Sender as TWSServerConnection);
-end;
-
-procedure TWSThreadedConnectionHandler.HandleConnection(aConnection: TWSServerConnection; DoHandshake: Boolean);
-begin
-  TWSConnectionThread.CreateConnection(aConnection,@ConnectionDone,DoHandShake);
-end;
-
 { TWSServerConnectionHandler }
 { TWSServerConnectionHandler }
 
 
 function TWSServerConnectionHandler.GetList: TWSConnectionList;
 function TWSServerConnectionHandler.GetList: TWSConnectionList;
@@ -686,7 +668,7 @@ end;
 procedure TWSSimpleConnectionHandler.HandleConnection(aConnection: TWSServerConnection; DoHandshake : Boolean);
 procedure TWSSimpleConnectionHandler.HandleConnection(aConnection: TWSServerConnection; DoHandshake : Boolean);
 begin
 begin
   if DoHandShake then
   if DoHandShake then
-     aConnection.PerformHandShake;
+    aConnection.PerformHandShake;
   aConnection.CheckIncoming(WaitTime);
   aConnection.CheckIncoming(WaitTime);
 end;
 end;
 
 
@@ -729,6 +711,23 @@ begin
     FOnDone(Connection);
     FOnDone(Connection);
 end;
 end;
 
 
+{ TWSThreadedConnectionHandler }
+
+procedure TWSThreadedConnectionHandler.CheckIncomingMessages;
+begin
+  // Do nothing
+end;
+
+procedure TWSThreadedConnectionHandler.ConnectionDone(Sender: TObject);
+begin
+  RemoveConnection(Sender as TWSServerConnection);
+end;
+
+procedure TWSThreadedConnectionHandler.HandleConnection(aConnection: TWSServerConnection; DoHandshake: Boolean);
+begin
+  TWSConnectionThread.CreateConnection(aConnection,@ConnectionDone,DoHandShake);
+end;
+
 { TWSPooledConnectionHandler.THandleRequestTask }
 { TWSPooledConnectionHandler.THandleRequestTask }
 
 
 constructor TWSPooledConnectionHandler.THandleRequestTask.Create(aConnection: TWSServerConnection; aOnConnectionDone: TNotifyEvent; aOnError: TErrorHandler; aDoHandshake : Boolean);
 constructor TWSPooledConnectionHandler.THandleRequestTask.Create(aConnection: TWSServerConnection; aOnConnectionDone: TNotifyEvent; aOnError: TErrorHandler; aDoHandshake : Boolean);