⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rmichatserverimpl.java

📁 简单的RMI应用 对初学者了解rmi有很大的帮助
💻 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 + -