1 package rero.dcc; 2 3 import java.io.*; 4 import java.net.*; 5 6 import rero.ircfw.*; 7 8 public abstract class GenericDCC implements Runnable 9 { 10 protected ProtocolDCC impl; 11 protected ChatFramework fw; 12 13 public void announceFramework(ChatFramework f) 14 { 15 fw = f; 16 } 17 18 public void setImplementation(ProtocolDCC _impl) 19 { 20 impl = _impl; 21 22 impl.announceFramework(fw); 23 } 24 25 public String getNickname() 26 { 27 return getImplementation().getNickname(); 28 } 29 30 public int getTypeOfDCC() 31 { 32 return getImplementation().getTypeOfDCC(); 33 } 34 35 public int getState() 36 { 37 return getImplementation().getState(); 38 } 39 40 public ProtocolDCC getImplementation() 41 { 42 return impl; 43 } 44 45 public void connect() 46 { 47 Thread fred = new Thread (this); 48 fred.start(); 49 } 50 51 public abstract Socket establishConnection(); 52 53 public void run() 54 { 55 Socket sock = establishConnection(); 56 57 try { sock.setKeepAlive(true); } catch (Exception ex) { } 58 59 impl.setDCCSocket( sock ); 60 impl.run(); 61 if (impl.isConnected()) 62 impl.close(); 63 } 64 } 65 | Popular Tags |