Browse Source

automatically close client socket.

Nicolas Cannasse 19 years ago
parent
commit
98cb5d6a0d
1 changed files with 7 additions and 3 deletions
  1. 7 3
      std/neko/net/ThreadServer.hx

+ 7 - 3
std/neko/net/ThreadServer.hx

@@ -115,7 +115,7 @@ class ThreadServer<Client,Message> {
 					t.socks.remove(s);
 					if( !Std.is(e,neko.io.Eof) && !Std.is(e,neko.io.Error) )
 						logError(e);
-					work(callback(clientDisconnected,s,infos.client));
+					work(callback(doClientDisconnected,s,infos.client));
 				}
 			}
 		while( true ) {
@@ -126,6 +126,11 @@ class ThreadServer<Client,Message> {
 		}
 	}
 
+	function doClientDisconnected(s,c) {
+		try s.close() catch( e : Dynamic ) {};
+		clientDisconnected(c);
+	}
+
 	function runWorker() {
 		while( true ) {
 			var f = neko.vm.Thread.readMessage(true);
@@ -220,8 +225,7 @@ class ThreadServer<Client,Message> {
 		return null;
 	}
 
-	public function clientDisconnected( s : neko.net.Socket, c : Client ) {
-		try s.close() catch( e : Dynamic ) {};
+	public function clientDisconnected( c : Client ) {
 	}
 
 	public function readClientMessage( c : Client, buf : String, pos : Int, len : Int ) : { msg : Message, bytes : Int } {