1
edit
Changes
→Create Java Classes Required
}
}
SimpleChatSystem.java
import java.util.ArrayList;
import cs.dps914.osgi.lab.chatinterface.IChatClient;
import cs.dps914.osgi.lab.chatinterface.IChatSystem;
import cs.dps914.osgi.lab.chatinterface.IMessage;
public class SimpleChatSystem implements IChatSystem {
public static ArrayList<IChatClient> clientList=new ArrayList<IChatClient>();
public static ArrayList<IMessage> messageList=new ArrayList<IMessage>();
public void registerClient(IChatClient client) {
clientList.add(client);
}
public ArrayList<IMessage> appendMessage(String src, String msg) {
IMessage newMsg=new SimpleMessage(src,msg);
messageList.add(newMsg);
for (IChatClient client:clientList) {
client.receiveMessage(newMsg);
}
return messageList;
}
}
lalala