Giter Club home page Giter Club logo

easemob-im-server-sdk's Introduction

Easemob IM Java SDK build codecov

Easemob IM Java SDK 是对环信IM 服务端API 的封装。

提供用户、群组等资源的操作管理能力。

依赖

  • Java 1.8
  • Reactor(io.projectreactor:reactor-bom:2020.0.4)

安装

如果你的项目使用Maven构建并且spring boot是2.4.3以上版本,在pom.xml中添加下面代码即可:

<dependency>
    <groupId>com.easemob.im</groupId>
    <artifactId>im-sdk-core</artifactId>
    <version>0.3.0</version>
</dependency>

如果你使用的spring-boot是2.4.3以下版本的,则还需要在pom.xml中添加:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-bom</artifactId>
            <version>4.1.59.Final</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-bom</artifactId>
            <version>2020.0.4</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

如果你的项目使用Gradle构建,可以在build.grade中添加下面代码:

implementation 'com.easemob.im:im-sdk-core:0.3.0'

准备

使用Server SDK的前提需要您准备appkey相关信息:

如果您有环信管理后台账号并创建过应用,请进入 这里 进行登录。 图片

如图点击查看后,可以看到自己的appkey、Client ID、ClientSecret,用于SDK的初始化。

如果您没有环信管理后台账号,请进入 这里 进行注册账号,注册成功后请进行登录。 图片

如图先添加应用(也就是创建appkey,自动生成Client ID、ClientSecret),添加成功后在应用列表中可以看到应用信息,点击查看可以看到自己的appkey、Client ID、ClientSecret,用于SDK的初始化。

使用

EMService 是所有API的入口,可以这样初始化:

EMProperties properties = EMProperties.builder()
        .setAppkey(cliProperties.getAppkey())
        .setClientId(cliProperties.getClientId())
        .setClientSecret(cliProperties.getClientSecret())
        .build();

EMService service = new EMService(properties);

根据业务资源,API分为:

每个业务资源对应一个方法,例如,用户相关的API,都可以在.user()找到。

举个例子,我们要注册一个用户,就可以这样写:

EMService service;
service.user().create(username, password).block();

API的返回值是响应式的,如果希望阻塞,可以使用上面例子中的block()。

DEMO

可以参考im-sdk-cli ,这是一个使用该SDK构建的CLI程序。

参考

SDK的api文档在这里

easemob-im-server-sdk's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.