<dependency>
<groupId>com.easemob.im</groupId>
<artifactId>im-sdk-core</artifactId>
<version>0.4.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.14</version>
</dependency>
import com.easemob.im.server.EMProperties;
import com.easemob.im.server.EMService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author : zanglikun
* @date : 2021/11/19 17:25
* @Version: 1.0
* @Desc : https://docs-im.easemob.com/im/server/ready/sdk#%E5%87%86%E5%A4%87
*/
@Configuration
public class EmConfig {
@Bean
public EMService service() {
EMProperties properties = EMProperties.builder()
.setAppkey("AppKey")
.setClientId("ClientID")
.setClientSecret("ClientSecret")
.build();
return new EMService(properties);
}
}
EMTextMessage emMessage = new EMTextMessage();
emMessage.text("您因:" + quickchatBanRecord.getBanReason() + ",被系统封停,封停至:" + new DateTime(quickchatBanRecord.getUnsealTime()) + " 如有疑问,请联系官方客服QQ:1834571998");
HashSet<String> hashSet = new HashSet();
hashSet.add(account);
MessageApi message = emService.message();
HashSet<EMKeyValue> ext = new HashSet<>();
EMKeyValue emKeyValue = EMKeyValue.of("ban", true);
EMKeyValue time = EMKeyValue.of("time", (quickchatBanRecord.getUnsealTime() - System.currentTimeMillis()) / 86400000);
ext.add(emKeyValue);
ext.add(time);
EMSentMessageIds users = message.send("6666", "users", hashSet, emMessage, ext).block(Duration.ofSeconds(3));
特殊说明: 解决问题的光鲜,藏着磕Bug的痛苦。 万物皆入轮回,谁也躲不掉! 以上文章,均是我实际操作,写出来的笔记资料,不会出现全文盗用别人文章!烦请各位,请勿直接盗用!