-
RMI 채팅프로그램(Swing)Study/Java 2020. 6. 17. 22:08
Class Server
1234567891011121314151617181920212223242526public class ChatServer {private static Logger LOGGER = LogManager.getLogger(ChatServer.class);public ChatServer() {try {initRmi();} catch (Exception e) {LOGGER.error(e.getMessage(), e);}}private void initRmi() throws Exception {LOGGER.debug("+++ initRmi");ChatImpl chatImpl = new ChatImpl();// 내부에 rmi registry를 생성한다.Registry registry = LocateRegistry.createRegistry(1099);registry.bind("chat", chatImpl);LOGGER.debug("--- initRmi");}public static void main(String[] args) {new ChatServer();}}cs
interface ChatInterface
1234567891011import java.rmi.Remote;import java.rmi.RemoteException;import com.barunsw.imj.day12.chat.client.ChatRecvInterface;public interface ChatInterface extends Remote {public int login(String userId, ChatRecvInterface chatRecvIf) throws RemoteException;public int logout(String userId) throws RemoteException;public int message(String message) throws RemoteException;}cs RMI을 사용하기 위해서는 interface에서 Remote를 상속 받아야함
throse RemoteExeption을 안쓰면 java.lang.IllegalArgumentException 발생
'Study > Java' 카테고리의 다른 글
[Class] Thread (0) 2020.06.18 [Class] Graphics/Graphics2D (0) 2020.06.18 this / super 키워드 (0) 2020.06.17 [Class String] String 클래스 정리 (0) 2020.06.16 단축키 모음 (0) 2020.06.16