网络聊天室(NetChatRoom)3

·方法声明

Chatter

package chat;

import java.rmi.RemoteException;

public interface Chatter extends java.rmi.Remote {
    /**
     * 通知用户加入
     */
    public void receiveEnter(String name, Chatter chatter, boolean hasEntered) throws RemoteException;
    
    /**
     * 通知用户离开聊天室
     */
    public void receiveExit(String name) throws RemoteException;
    
    /**
     * 用户发言
     */
    public void receiveChat(String name, String message) throws RemoteException;
    
    /**
     * 私聊
     */
    public void receiveWhisper(String name, String message) throws RemoteException;
    
    /**
     * 通知服务器停止
     */
    public void serverStop() throws RemoteException;
}

 

ChatServer

package chat;

import java.rmi.RemoteException;

// 聊天服务器接口
public interface ChatServer extends java.rmi.Remote {
    /**
     * 注册新的聊天用户
     */
    public void login(String name, Chatter chatter) throws RemoteException;
    
    /**
     * 用户退出
     */
    public void logout(String name) throws RemoteException;
    
    /**
     * 用户调用此函数将消息发给所有用户
     */
    public void chat(String name, String message) throws RemoteException;
}

 

posted @ 2021-07-09 17:17  他乡一故知  阅读(64)  评论(0编辑  收藏  举报