1 9 package org.ozoneDB.DxLib.net; 10 11 import java.net.*; 12 import java.io.*; 13 import org.ozoneDB.DxLib.*; 14 15 16 24 public class DxMultiServerClient extends DxClient implements Runnable { 25 26 boolean stop; 27 28 DxMultiServer server; 29 30 Thread thread; 31 32 33 public DxMultiServerClient( Socket socket, DxMultiServer dms ) throws IOException{ 34 super( socket ); 35 stop = false; 36 server = dms; 37 thread = dms.newThread( this ); 38 } 39 40 41 public void run() { 42 try { 43 while (!stop) { 44 server.handleClientEvent( this, receive() ); 45 } 46 super.close(); 47 } catch (Exception e) { 48 server.handleClientException( this, e ); 49 } 50 } 51 52 53 public synchronized void listen() { 54 if (!thread.isAlive()) { 55 thread.start(); 56 } 57 } 58 59 60 public synchronized void close() { 61 stop = true; 62 } 63 64 65 public Thread thread() { 66 return thread; 67 } 68 } 69 | Popular Tags |