Android 消息收发

处理用户消息的收发。消息发送由 MessageService 服务类提供,消息的接收由客户端实现 MessageListener来被动接收。

获取 MessageService

UserAgentProxy proxy = UserAgentProxy.getInstance();
......
MessageService messageService = proxy.getMessageService();

注册 MessageListener

MessageListener 实现用于接收消息, MessageListener 接口说明

public class MessageService {
    public synchronized void setMessageListener(MessageListener listener) {}
}

发送文本消息

发送给个人

public class MessageService {
    public boolean sendTextMessageToUser(String peerUserID, String content, String msg_uuid, boolean bReSendFlag){}
}

发送给群组

public class MessageService {
    public boolean sendTextMessageToGroup(String groupID, String content, String msg_uuid, boolean bReSendFlag, int extraType){}
}

图片、语音、视频消息的文件处理

V5视讯云提供了文件上传下载服务,详见 客户端 RSET 相关接口;也可以自己实现.

发送图片消息

发送给个人

public class MessageService {
    public boolean sendImageUrlToUser(String peerUserID, String url, String msg_uuid, boolean bReSendFlag) {}
}

发送给群组

public class MessageService {
    public boolean sendImageUrlToGroup(String peerUserID, String url, String msg_uuid, boolean bReSendFlag, int extraType) {}
}

发送音频消息

发送给个人

public class MessageService {
    public boolean sendAudioMessageToUser(String peerUserID, String url, String msg_uuid, boolean bReSendFlag) {}
}

发送给群组

public class MessageService {
    public boolean sendAudioMessageToGroup(String groupID, String url, String msg_uuid, boolean bReSendFlag, int extraType) {}
}

发送视频消息

发送给个人

public class MessageService {
    public boolean sendVideoMessageToUser(String peerUserID, String describe, String shortUrl, String videoUrl, String msg_uuid, boolean bReSendFlag) {}
}

发送给群组

public class MessageService {
    public boolean sendVideoMessageToGroup(String groupID, String describe, String shortUrl, String videoUrl, String msg_uuid, boolean bReSendFlag, int extraType) {}
}

回复消息已收到

public class MessageService {
    public boolean messageReceived(long uuid) {}
}

回复消息已阅读

public class MessageService {
    public boolean messageRead(long uuid) {}
}