1 14 15 package org.quickserver.net.server; 16 17 import java.net.Socket ; 18 import java.nio.channels.SocketChannel ; 19 20 25 public class TheClient { 26 private String timeoutMsg; 27 private String maxAuthTryMsg; 28 private int maxAuthTry; 29 private Socket socket; 30 private Authenticator authenticator; 31 private ClientAuthenticationHandler clientAuthenticationHandler; private ClientEventHandler eventHandler; private ClientExtendedEventHandler extendedEventHandler; private ClientCommandHandler commandHandler; 35 private ClientObjectHandler objectHandler; private ClientBinaryHandler binaryHandler; private QuickServer quickServer; 38 private ClientData clientData; 39 private boolean trusted = false; 41 private boolean communicationLogging = true; 42 private int socketTimeout; 44 private String maxConnectionMsg; 45 private ClientEvent event = ClientEvent.RUN_BLOCKING; 46 private SocketChannel socketChannel; 47 private ClientWriteHandler writeHandler; 48 49 53 public void setServer(QuickServer server) { 54 this.quickServer=server; 55 } 56 60 public QuickServer getServer() { 61 return quickServer; 62 } 63 64 65 public void setSocket(Socket socket) { 66 this.socket = socket; 67 } 68 69 public Socket getSocket() { 70 return socket; 71 } 72 73 81 public void setAuthenticator(Authenticator authenticator) { 82 this.authenticator=authenticator; 83 } 84 91 public Authenticator getAuthenticator() { 92 return authenticator; 93 } 94 95 102 public void setClientAuthenticationHandler(ClientAuthenticationHandler clientAuthenticationHandler) { 103 this.clientAuthenticationHandler = clientAuthenticationHandler; 104 } 105 111 public ClientAuthenticationHandler getClientAuthenticationHandler() { 112 return clientAuthenticationHandler; 113 } 114 115 121 public void setClientData(ClientData data) { 122 this.clientData=data; 123 } 124 129 public ClientData getClientData() { 130 return clientData; 131 } 132 133 137 public void setMaxAuthTry(int authTry) { 138 maxAuthTry = authTry; 139 } 140 144 public int getMaxAuthTry() { 145 return maxAuthTry; 146 } 147 148 149 public void setMaxAuthTryMsg(String msg) { 150 maxAuthTryMsg = msg; 151 } 152 156 public String getMaxAuthTryMsg() { 157 return maxAuthTryMsg; 158 } 159 160 161 public void setTimeoutMsg(String msg) { 162 timeoutMsg = msg; 163 } 164 165 public String getTimeoutMsg() { 166 return timeoutMsg; 167 } 168 169 177 public void setClientEventHandler(ClientEventHandler handler) { 178 this.eventHandler = handler; 179 } 180 186 public ClientEventHandler getClientEventHandler() { 187 return eventHandler; 188 } 189 190 198 public void setClientExtendedEventHandler(ClientExtendedEventHandler handler) { 199 this.extendedEventHandler = handler; 200 } 201 207 public ClientExtendedEventHandler getClientExtendedEventHandler() { 208 return extendedEventHandler; 209 } 210 211 218 public void setClientCommandHandler(ClientCommandHandler handler) { 219 this.commandHandler = handler; 220 } 221 226 public ClientCommandHandler getClientCommandHandler() { 227 return commandHandler; 228 } 229 230 238 public void setClientObjectHandler(ClientObjectHandler handler) { 239 this.objectHandler = handler; 240 } 241 247 public ClientObjectHandler getClientObjectHandler() { 248 return objectHandler; 249 } 250 251 255 public boolean getTrusted() { 256 return trusted; 257 } 258 262 public void setTrusted(boolean flag) { 263 trusted = flag; 264 } 265 266 271 public void setCommunicationLogging(boolean communicationLogging) { 272 this.communicationLogging = communicationLogging; 273 } 274 279 public boolean getCommunicationLogging() { 280 return communicationLogging; 281 } 282 283 291 public void setClientBinaryHandler(ClientBinaryHandler handler) { 292 this.binaryHandler = handler; 293 } 294 300 public ClientBinaryHandler getClientBinaryHandler() { 301 return binaryHandler; 302 } 303 304 310 public void setTimeout(int time) { 311 socketTimeout = time; 312 } 313 318 public int getTimeout() { 319 return socketTimeout; 320 } 321 322 326 public void setClientEvent(ClientEvent event) { 327 this.event = event; 328 } 329 333 public ClientEvent getClientEvent() { 334 return event; 335 } 336 337 341 public void setMaxConnectionMsg(String msg) { 342 maxConnectionMsg = msg; 343 } 344 349 public String getMaxConnectionMsg() { 350 return maxConnectionMsg; 351 } 352 353 357 public void setSocketChannel(SocketChannel socketChannel) { 358 this.socketChannel = socketChannel; 359 } 360 364 public SocketChannel getSocketChannel() { 365 return socketChannel; 366 } 367 368 376 public void setClientWriteHandler(ClientWriteHandler handler) { 377 this.writeHandler = handler; 378 } 379 385 public ClientWriteHandler getClientWriteHandler() { 386 return writeHandler; 387 } 388 389 393 public String toString() { 394 StringBuffer sb = new StringBuffer (); 395 sb.append("{TheClient "); 396 if(socket!=null) 397 sb.append(socket); 398 else 399 sb.append("no socket"); 400 sb.append(", Event: "+event); 401 sb.append('}'); 402 return sb.toString(); 403 } 404 } 405 | Popular Tags |