关于java:基于RMI和Socket的Java聊天软件

9次阅读

共计 2891 个字符,预计需要花费 8 分钟才能阅读完成。

RMI 定义近程办法提供给客户端调用
定义的接口:(须要实现
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.sql.SQLException;
import java.util.ArrayList;
public interface ServerMethod extends Remote {

/**
 *RMI 办法
 * 登录 登录胜利返回 true 否则返回 false
 * @param   UID  用户 UID
 * @param   Password 用户明码
 * @see boolean
 */
public boolean Login(String UID,String Password) throws RemoteException, SQLException;// 登录
/**
 *RMI 办法
 * 注册 注册胜利返回 true 否则返回 false
 * @param   UID  用户 UID
 * @param   Password 用户明码
 * @param Nickname 昵称
 * @see boolean
 */
public boolean Register(String UID ,String Password,String Nickname)throws SQLException,RemoteException;// 注册
/**
 *RMI 办法
 * 获取存在数据库的未读音讯
 * @param   UID  用户 UID
 * @see ArrayList
 */
public ArrayList<String> getDBMessage(String UID) throws SQLException,RemoteException;// 获取存储在数据库的音讯
/**
 *RMI 办法
 * 获取好友列表
 * @param   UID  用户 UID
 * @see ArrayList
 */
public ArrayList<String> getAllFriends(String UID) throws SQLException,RemoteException;// 获取好友列表 格局:UID:Nickname
/**
 *RMI 办法
 * 发送音讯
 * @param   UID  发送者 UID
 * @param Nickname 昵称
 * @param  ReceiveID 接收者 ID
 * @param content  内容
 * @see ArrayList
 */
public boolean SendMessage(String UID,String Nickname,String ReceiveID,String content) throws SQLException,RemoteException;// 对方还不是好友,则发送失败
/**
 *RMI 办法
 * 获取实时音讯
 * @param   UID  用户 UID
 * @see ArrayList
 */
public  ArrayList<String> GetMessage(String UID) throws Exception;// 实时音讯获取
/**
 *RMI 办法
 * 发送群聊音讯 [Skrill 下载](https://www.gendan5.com/wallet/Skrill.html)发送胜利返回 true
 * @param   UID  发送者 UID
 * @param   Nickname 昵称
 * @param   GroupUID 群组 UID
 * @param   content 内容
 * @see boolean
 */
public boolean SendMessageToGroup(String UID,String Nickname,String GroupUID,String content)throws SQLException,RemoteException;// 向群聊发送音讯
/**
 *RMI 办法
 * 发送群聊音讯 发送胜利返回 true
 * @param   SendUID  发送者 UID
 * @param   Nickname 昵称
 * @param   ReceiveUID 接收者 UID
 * @param   content 内容
 * @see boolean
 */
public boolean AddFriendsRequest(String SendUID,String ReceiveUID,String Nickname,String content)throws SQLException,RemoteException;// 发送增加好友申请
/**
 *RMI 办法
 * 删除关系
 * @param   ID1 ID2
 * @param   ID2 ID1
 */
public void DeleteFriend(String ID1,String ID2)throws SQLException,RemoteException;// 删除关系
/**
 *RMI 办法
 * 新建群聊
 * @param   SendUID ID2
 * @param   GID ID1
 */
public boolean NewGroup(String SendUID,String GID)throws SQLException,RemoteException;// 新建群聊
/**
 *RMI 办法
 * 增加群聊
 * @param   UID 用户 ID
 * @param   GID 群聊 ID
 */
public void AddGroup(String UID,String GID)throws SQLException,RemoteException;// 增加群聊 无需验证
/**
 *RMI 办法
 * 批改昵称
 * @param   UID 用户 ID
 * @param   newNickname 新用户昵称
 * @see     boolean
 */
public boolean ChangeNickname(String UID,String newNickname)throws SQLException,RemoteException;// 批改昵称
/**
 *RMI 办法
 * 批改明码
 * @param   UID 用户 ID
 * @param   newPassword 新密码
 * @see     boolean
 */
public boolean ChangePassword(String UID,String newPassword)throws SQLException,RemoteException;// 批改明码
/**
 *RMI 办法
 * 获取用户音讯
 * @param   UID 用户 ID
 */
public String getUserInfo(String UID)throws SQLException,RemoteException;// 获取用户信息 若为群组返回 G:GID 若为用户返回 U:UID:Nickname
/**
 *RMI 办法
 * 批准增加好友
 * @param   SendUID 发送者 ID
 * @param   ReceiveUID 接收者 UID
 */
public  void AgreeAddFriendRequest(String SendUID,String ReceiveUID)throws SQLException,RemoteException;
/**
 *RMI 办法
 * 回绝增加好友
 * @param   SendUID 发送者 ID
 * @param   ReceiveUID 接收者 UID
 */
public  void RefuseAddFriendRequest(String SendUID,String ReceiveUID)throws SQLException,RemoteException;

}

正文完
 0