📄 rmichatserverimpl.java
字号:
import java.rmi.server.*;import java.rmi.*;import java.util.*;public class RMIChatServerImpl extends UnicastRemoteObject implements RMIChatServer { Vector clientList; public RMIChatServerImpl() throws RemoteException { super(); clientList = new Vector(); } public synchronized void register(RMIChatClient client, String name) throws RemoteException { clientList.addElement(client); broadcast(name + "丛捞 涝厘窍继嚼聪促."); } public void broadcast(String msg) throws RemoteException { synchronized(clientList) { Enumeration e = clientList.elements(); while(e.hasMoreElements()) { RMIChatClient c = (RMIChatClient) e.nextElement(); c.setMessage(msg); } } } public synchronized void unregister(RMIChatClient client, String name) throws RemoteException { clientList.removeElement(client); broadcast(name + "丛捞 硼厘窍继嚼聪促."); } public static void main(String args[]) { try { RMIChatServerImpl c = new RMIChatServerImpl(); Naming.rebind("rmi://localhost/chat", c); System.out.println("RMI Chat Server is ready."); } catch(Exception ex) { System.out.println(ex); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -