KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sellwin > domain > ChatPacket


1 package sellwin.domain;
2
3 // SellWin http://sourceforge.net/projects/sellwincrm
4
//Contact support@open-app.com for commercial help with SellWin
5
//This software is provided "AS IS", without a warranty of any kind.
6

7
8 import java.io.*;
9 import java.util.*;
10
11 /**
12  * the chat message structure that gets send and received
13  * by chat clients and server
14  */

15 public class ChatPacket implements Serializable {
16     // 0 - normal send
17
// 1 - return all online users
18
public static final int SEND_MSG = 0;
19     public static final int QUERY_USERS = 1;
20     public static final int LOGON = 2;
21     public int action;
22
23     //only filled when the action is '0'
24
public ArrayList sendToList;
25
26     //only filled when the action is '1'
27
public ArrayList onlineUsers;
28
29     public String JavaDoc message;
30     public String JavaDoc sender;
31
32     public ChatPacket() {
33     }
34
35     public void print() {
36         if (action == 0) {
37             System.out.println("message: " + action + ":" + message + " from " + sender);
38             System.out.println("list of recipients...");
39             for (int j=0;j<sendToList.size();j++) {
40                 System.out.println("user:" + (String JavaDoc)sendToList.get(j));
41             }
42         } else {
43             System.out.println("list of online users....");
44             for (int i=0;i<onlineUsers.size();i++) {
45                 System.out.println("user:" + (String JavaDoc)onlineUsers.get(i));
46             }
47         }
48     }
49
50     public void setAction(int action) {
51         this.action = action;
52     }
53     public int getAction() { return action; }
54
55     public void setToList(ArrayList toList) {
56         this.sendToList = toList;
57     }
58     public ArrayList getToList() { return sendToList; }
59
60
61     public void setOnlineUsers(ArrayList users) {
62         this.onlineUsers = users;
63     }
64     public ArrayList getOnlineUsers() { return onlineUsers; }
65
66     public void setMessage(String JavaDoc message) {
67         this.message = message;
68     }
69     public String JavaDoc getMessage() { return message; }
70
71     public void setSender(String JavaDoc sender) {
72         this.sender = sender;
73     }
74
75     public String JavaDoc getSender() { return sender; }
76 }
77
Popular Tags