Source Code Cross Referenced for ClientEventHandler.java in  » Net » QuickServer » org » quickserver » net » server » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » QuickServer » org.quickserver.net.server 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of the QuickServer library 
003:         * Copyright (C) 2003-2005 QuickServer.org
004:         *
005:         * Use, modification, copying and distribution of this software is subject to
006:         * the terms and conditions of the GNU Lesser General Public License. 
007:         * You should have received a copy of the GNU LGP License along with this 
008:         * library; if not, you can download a copy from <http://www.quickserver.org/>.
009:         *
010:         * For questions, suggestions, bug-reports, enhancement-requests etc.
011:         * visit http://www.quickserver.org
012:         *
013:         */
014:
015:        package org.quickserver.net.server;
016:
017:        import java.io.*;
018:        import java.net.SocketTimeoutException;
019:
020:        /**
021:         * This interface defines the methods that should be implemented by any 
022:         * class that wants to handle client events.
023:         * 
024:         * <p>
025:         * Recommendations to be followed when implementing ClientEventHandler
026:         * <ul>
027:         * <li>Should have a default constructor. 
028:         * <li>Should be thread safe.
029:         * <li>It should not store any data that may is associated with a particular client. 
030:         * <li>If any client data is need to be saved from the client session,  
031:         * it should be saved to a {@link ClientData} class, which can be retrieved 
032:         * using handler.getClientData() method.
033:         * </ul>
034:         * </p>
035:         * <p>If not ClientEventHandler is set for QuickServer then a 
036:         * default implementation {@link org.quickserver.net.server.impl.DefaultClientEventHandler} is used.
037:         * </p>
038:         * <p>
039:         * Ex:
040:         * <code><BLOCKQUOTE><pre>
041:         package echoserver;
042:
043:         import java.net.*;
044:         import java.io.*;
045:         import org.quickserver.net.server.ClientEventHandler;
046:         import org.quickserver.net.server.ClientHandler;
047:
048:         public class EchoEventHandler implements ClientEventHandler {
049:
050:         public void gotConnected(ClientHandler handler)
051:         throws SocketTimeoutException, IOException {
052:         handler.sendSystemMsg("Connection opened : "+
053:         handler.getSocket().getInetAddress());
054:
055:         handler.sendClientMsg("Welcome to EchoServer v1.0 ");
056:         handler.sendClientMsg("Note: Password = Username");
057:         handler.sendClientMsg("Send 'Quit' to exit");
058:         }
059:
060:         public void lostConnection(ClientHandler handler) 
061:         throws IOException {
062:         handler.sendSystemMsg("Connection lost : " + 
063:         handler.getSocket().getInetAddress());
064:         }
065:         public void closingConnection(ClientHandler handler) 
066:         throws IOException {
067:         handler.sendSystemMsg("Connection closing : " + 
068:         handler.getSocket().getInetAddress());
069:         }
070:         }
071:         </pre></BLOCKQUOTE></code></p>
072:         * @since 1.4.5
073:         * @author Akshathkumar Shetty
074:         */
075:        public interface ClientEventHandler {
076:
077:            /**
078:             * Method called when there is a new client connects
079:             * to the QuickServer.
080:             * Can be used to send welcome message to the client and logging.
081:             * @exception java.net.SocketTimeoutException if socket times out
082:             * @exception java.io.IOException if io error in socket
083:             */
084:            public void gotConnected(ClientHandler handler)
085:                    throws SocketTimeoutException, IOException;
086:
087:            /**
088:             * Method called when client connection is lost.
089:             * Don't write to the connection in this method.
090:             * Its just information, to be used at the Server end.
091:             * It can be caused due to network errors.
092:             * @exception java.io.IOException if io error in socket
093:             */
094:            public void lostConnection(ClientHandler handler)
095:                    throws IOException;
096:
097:            /**
098:             * Method called when client connection is closed.
099:             * Don't write to the connection in this method.
100:             * Its just information, you can use to log time and ip of client closing connection.
101:             * @exception java.io.IOException if io error in socket
102:             */
103:            public void closingConnection(ClientHandler handler)
104:                    throws IOException;
105:
106:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.