📄 chatserver.java~9~
字号:
package rmichat;
import java.rmi.*;
import java.rmi.server.*;
import java.util.HashMap;
public class ChatServer extends UnicastRemoteObject implements Chat {
private HashMap userList = new HashMap();
private StringBuffer msg = new StringBuffer();
/*构造方法是一定要的*/
public ChatServer() throws RemoteException {
}
/**
* getMsg
*
* @return String
* @todo Implement this rmichat.Chat method
*/
public String getMsg() {
return "";
}
/**
* login
*
* @param name String
* @return boolean
* @todo Implement this rmichat.Chat method
*/
public boolean login(String name) {
return false;
}
/**
* logout
*
* @todo Implement this rmichat.Chat method
*/
public void logout(String name) {
msg.append("["+name+"] 退出聊天室");
}
/**
* sendMsg
*
* @param msg String
* @todo Implement this rmichat.Chat method
*/
public void sendMsg(String msg) {
}
public static void main(String[] args) throws Exception {
System.setSecurityManager(new RMISecurityManager());
Chat instance = new ChatServer();
Naming.rebind("rmi://localhost/Chat", instance);
System.out.println("Server has been bound!");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -