KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > chatserver > ChatServer


1 /*
2  * This file is part of the QuickServer library
3  * Copyright (C) 2003-2005 QuickServer.org
4  *
5  * Use, modification, copying and distribution of this software is subject to
6  * the terms and conditions of the GNU Lesser General Public License.
7  * You should have received a copy of the GNU LGP License along with this
8  * library; if not, you can download a copy from <http://www.quickserver.org/>.
9  *
10  * For questions, suggestions, bug-reports, enhancement-requests etc.
11  * visit http://www.quickserver.org
12  *
13  */

14
15 package chatserver;
16
17 /*
18   Server Messages
19   ------------------
20     Id format
21         user1 <- user in any room
22         user1@home <- user in room
23         @home <- to room
24
25     {user.info:<id>} <type> <- Gives info about users
26         Where <type> can be
27         LoggedIn
28         LoggedOut
29     {user.msg:<fromid>:<toid>} <-Message from user
30     {user.list} <id> <- system is giving list of users in room
31
32
33     {system.error} <type> <- Error at server
34         Where <type> can be
35         MessageNotSent
36         BadCommand
37         AuthFailed
38         BadParam
39     {system.debug} <- Debug info from server
40     {system.msg} <- Message from server
41     {system.help} <- Help from server
42     {system.data} <- Server is waiting for data
43     {system.ok} <- Success
44
45 */

46
47 import org.quickserver.net.*;
48 import org.quickserver.net.server.*;
49
50 import java.io.*;
51 import java.util.logging.*;
52 import org.quickserver.util.logging.*;
53
54 /**
55  * Main class of ChatServer
56  * Demonstrates how to find another client connected and
57  * send String to it.
58  * @author Akshathkumar Shetty
59  */

60 public class ChatServer {
61     public static String JavaDoc VER = "2.0";
62     public static void main(String JavaDoc s[]) {
63         QuickServer chatServer = new QuickServer();
64         
65         String JavaDoc confFile = "conf"+File.separator+"ChatServer.xml";
66         Object JavaDoc config[] = new Object JavaDoc[] {confFile};
67         
68         try {
69             if(chatServer.initService(config) == true) {
70                 chatServer.startServer();
71                 chatServer.startQSAdminServer();
72             }
73         } catch(AppException e) {
74             System.out.println("Error in server : "+e);
75             e.printStackTrace();
76         }
77     }
78 }
79
80
81
Popular Tags