Skip to content

Commit

Permalink
Merge pull request #13 from AgoraIO-Community/dev/1.0.0
Browse files Browse the repository at this point in the history
feat: add backend callapi
  • Loading branch information
tamworth authored Jan 29, 2024
2 parents 7dcca04 + f5dd82b commit 0aff009
Show file tree
Hide file tree
Showing 30 changed files with 5,930 additions and 4 deletions.
26 changes: 26 additions & 0 deletions Backend/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile_dev"
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
13 changes: 13 additions & 0 deletions Backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.idea
logs
target
.vscode

# RTM
agora_rtm_cache.db
agorartmdns.dat
agorartmreport.dat
core
crash_context_v1
hs_err*
xdump_config
Binary file added Backend/.mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions Backend/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
35 changes: 35 additions & 0 deletions Backend/Dockerfile_dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM --platform=linux/amd64 ubuntu:20.04

ENV JAVA_HOME=/usr/lib/jvm/default-java

# Change apt repository to a China network friendly site.
# RUN sed -i s@/archive.ubuntu.com/@/mirrors.tuna.tsinghua.edu.cn/@g /etc/apt/sources.list
# RUN sed -i s@/security.ubuntu.com/@/mirrors.tuna.tsinghua.edu.cn/@g /etc/apt/sources.list

RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN sed -i s@/security.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list

RUN apt-get clean
RUN apt-get update

RUN apt-get install -y --no-install-recommends
RUN apt-get install -y apt-utils
RUN apt-get install -y software-properties-common
RUN apt-get install -y lsb-release
RUN apt-get install -y wget
RUN apt-get install -y curl
RUN apt-get install -y libssl-dev
RUN apt-get install -y libcrypto++-dev
RUN apt-get install -y libc++-dev

# Install java
RUN apt-get -y install default-jdk

# Install maven
RUN apt-get -y install maven

# Maven aliyun
COPY mvn_settings.xml /root/.m2/settings.xml

# Copy dynamic library
COPY src/main/resources/lib/*.so /usr/lib/
15 changes: 15 additions & 0 deletions Backend/HELP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Read Me First
The following was discovered as part of building this project:

* The JVM level was changed from '11' to '17', review the [JDK Version Range](https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-Versions#jdk-version-range) on the wiki for more details.

# Getting Started

### Reference Documentation
For further reference, please consider the following sections:

* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.0.2/maven-plugin/reference/html/)
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.0.2/maven-plugin/reference/html/#build-image)
* [Spring Boot DevTools](https://docs.spring.io/spring-boot/docs/3.0.2/reference/htmlsingle/#using.devtools)

61 changes: 61 additions & 0 deletions Backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 场景化API, 1v1匹配玩法后端服务JDK

提供后端 CallApi JDK, 具体集成使用可参考 1v1匹配玩法后端服务演示Demo

## 环境准备
* 需要在声网 [Console 平台](https://console.shengwang.cn/)申请 App ID 和 App Certificate
* 本地具备 Docker 环境
* 运行在 Ubuntu 环境, 本地调试可使用 Visual Studio Code 编辑器, 安装 Dev Containers 容器开发插件

## 接口说明
* 主要提供以下 4 个接口, 参考接口定义文件 src/main/java/io/agora/scenarioapi/ICallApi.java
* initialize - 初始化
* deinitialize - 销毁/重置
* call - 用户呼叫
* renewToken - 刷新 Token

## 示例文件
* 可参考以下示例
```
src/main/java/io/agora/scenarioapi/sample/CallApiSample.java (自动生成 Rtm Client 对象)
src/main/java/io/agora/scenarioapi/sample/CallApiRtmClientSample.java (外部提供 Rtm Client 对象)
```

## 本地运行
* Visual Studio Code 编辑器打开项目源码, 进入容器开发模式, 安装 Extension Pack for Java 插件
* 运行 src/main/java/io/agora/scenarioapi/sample/CallApiSample.java 或 src/main/java/io/agora/scenarioapi/sample/CallApiRtmClientSample.java 文件

这里需要确保已启动1v1匹配玩法前端 App Demo, 用户 userIdA 和 userIdB 已启动成功
运行前修改 appId 和 rtmToken
* 运行成功后, 可根据输出的日志查看结果, 通过1v1匹配玩法前端 App Demo 观看效果

## 目录说明
```
├── src
│ ├── main
│ │ ├── java
│ │ │ └── io
│ │ │ └── agora
│ │ │ └── scenarioapi
│ │ │ ├── CallApiConfig.java CallApi JDK 配置类
│ │ │ ├── CallApiImpl.java CallApi JDK 实现类
│ │ │ ├── ICallApi.java CallApi JDK 接口
│ │ │ ├── sample CallApi Sample示例
│ │ │ │ ├── CallApiRtmClientSample.java
│ │ │ │ └── CallApiSample.java
│ │ └── resources
│ │ ├── lib RTM依赖文件
│ │ │ ├── agora-rtm-sdk.jar
│ │ │ ├── include
│ │ │ │ ├── AgoraRtmBase.h
│ │ │ │ ├── IAgoraRtmClient.h
│ │ │ │ ├── IAgoraRtmLock.h
│ │ │ │ ├── IAgoraRtmPresence.h
│ │ │ │ ├── IAgoraRtmService.h
│ │ │ │ ├── IAgoraRtmStorage.h
│ │ │ │ ├── IAgoraService.h
│ │ │ │ └── IAgoraStreamChannel.h
│ │ │ ├── libagora-rtm-sdk-jni.so
│ │ │ └── libagora-rtm-sdk.so
│ │ └── logback-spring.xml 日志配置
```
12 changes: 12 additions & 0 deletions Backend/mvn_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>maven-aliyun-com</id>
<name>Maven Aliyun Mirror</name>
<url>https://maven.aliyun.com/repository/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings>
Loading

0 comments on commit 0aff009

Please sign in to comment.