public static void main(String[] args) {
AVIMConversation conversation = null;
//初始化
AVOSCloud.initialize("xxxxxx", "xxxxx","xxxxxx");
//开启调试日志
AVOSCloud.setLogLevel(AVLogger.Level.DEBUG);
//用户Tom
AVIMClient tom = AVIMClient.getInstance("Tom");
tom.open(new AVIMClientCallback() {
@Override
public void done(AVIMClient client, AVIMException e) {
if (e == null) {
// 成功打开连接
System.out.println("连接成功");
}else{
}
}
});
tom.createConversation(Arrays.asList("Jerry"), "Tom & Jerry", null, false, true,
new AVIMConversationCreatedCallback() {
@Override
public void done(AVIMConversation conversation, AVIMException e) {
if(e == null) {
conversation = conversation;
}
}
});
AVIMTextMessage msg = new AVIMTextMessage();
msg.setText("Jerry,起床了!");
// 发送消息
if(conversation == null)
return ;
conversation.sendMessage(msg, new AVIMConversationCallback() {
@Override
public void done(AVIMException e) {
if (e == null) {
System.out.println("Tom & Jerry,发送成功!");
}
}
});
}
结果:
一月 02, 2020 4:12:38 下午 cn.leancloud.logging.SimpleLogger internalWriteLog
详细: openClient...
一月 02, 2020 4:12:38 下午 cn.leancloud.logging.SimpleLogger internalWriteLog
详细: add request cache. client=Tom, conv=null, request=-65535
一月 02, 2020 4:12:38 下午 cn.leancloud.logging.SimpleLogger internalWriteLog
严重: session error:java.lang.IllegalStateException: Connection Lost
一月 02, 2020 4:12:38 下午 cn.leancloud.logging.SimpleLogger internalWriteLog
严重: session error:java.lang.IllegalStateException: Connection Lost
一月 02, 2020 4:12:38 下午 cn.leancloud.logging.SimpleLogger internalWriteLog
详细: enter onOperationCompleted with clientId=Tom, convId=null, requestId=-65535, operation=CLIENT_OPEN
一月 02, 2020 4:12:38 下午 cn.leancloud.logging.SimpleLogger internalWriteLog
详细: createConversation...
一月 02, 2020 4:12:38 下午 cn.leancloud.logging.SimpleLogger internalWriteLog
详细: add request cache. client=Tom, conv=null, request=-65534
一月 02, 2020 4:12:38 下午 cn.leancloud.logging.SimpleLogger internalWriteLog
严重: session error:java.lang.RuntimeException: Connection Lost
一月 02, 2020 4:12:38 下午 cn.leancloud.logging.SimpleLogger internalWriteLog
严重: session error:java.lang.RuntimeException: Connection Lost
一月 02, 2020 4:12:38 下午 cn.leancloud.logging.SimpleLogger internalWriteLog
详细: enter onOperationCompleted with clientId=Tom, convId=null, requestId=-65534, operation=CONVERSATION_CREATION
有没有大佬知道