-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatMessage.java
More file actions
34 lines (30 loc) · 1.07 KB
/
Copy pathChatMessage.java
File metadata and controls
34 lines (30 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// CSD 2013, Pablo Galdámez
import java.rmi.*;
import java.rmi.server.*;
//
// Simple ChatMessage implementation
//
public class ChatMessage
extends UnicastRemoteObject
implements IChatMessage
{
private String str = "";
private IChatUser src = null; // sender
private Remote dst = null; // Actual class depends on wheter the message is private or public
public ChatMessage (IChatUser src, IChatChannel dst, String str) throws RemoteException
{
super (ChatConfiguration.the().getMyPort());
this.src = src; this.dst = dst; this.str = str;
}
public ChatMessage (IChatUser src, IChatUser dst, String str) throws RemoteException {
super (ChatConfiguration.the().getMyPort());
this.src = src; this.dst = dst; this.str = str;
}
//
// ISA IChatMessage
//
public String getText () throws RemoteException {return str;}
public IChatUser getSender () throws RemoteException {return src;}
public Remote getDestination () throws RemoteException {return dst;}
public boolean isPrivate() {return dst instanceof IChatUser;}
}