diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..78ad9d3 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,37 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/simples/JT808.Gateway.SimpleServer/bin/Debug/net8.0/JT808.Gateway.SimpleServer.dll", + "args": [], + "cwd": "${workspaceFolder}/simples/JT808.Gateway.SimpleServer", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + }, + "console": "internalConsole" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..e2316e2 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,73 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "group": { + "kind": "build", + "isDefault": true + }, + "args": [ + "build", + "${workspaceFolder}/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj", + "/p:Configuration=Release", + "/p:PublishDir=${workspaceFolder}/.output/linux-x64", + "/p:RuntimeIdentifier=linux-x64", + "/p:PublishSingleFile=true", + "/p:PublishTrimmed=true", + "/p:IncludeNativeLibrariesForSelfExtract=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "build docker", + "command": "dotnet", + "hide": true, + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj", + "/p:Configuration=Release", + "/p:PublishDir=${workspaceFolder}/.output/docker", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "build docker image", + "detail": "打包示例网关镜像", + "type": "shell", + "command": "docker compose build --no-cache", + "dependsOn": ["build docker"], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..627ebcb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 +WORKDIR /app +COPY .output/docker/ . +EXPOSE 80 808 +ENV LANG=en_US.UTF-8 TZ=Asia/Shanghai +ENTRYPOINT ["dotnet", "JT808.Gateway.SimpleServer.dll"] \ No newline at end of file diff --git a/README.md b/README.md index cd7d933..63789da 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,14 @@ ## 集成接口功能 -| 接口名称 | 接口说明 | 使用场景 | -| :--------------------------- | :-------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- | -| IJT808SessionProducer | 会话通知(在线/离线)数据生产接口 | 有些超长待机的设备,不会实时保持连接,那么通过平台下发的命令是无法到达的,这时候就需要设备一上线,就即时通知服务去处理,然后在即时的下发消息到设备。 | -| IJT808SessionConsumer | 会话通知(在线/离线)数据消费接口 | - | -| IJT808MsgProducer | 数据生产接口 | 网关将接收到的数据发送到队列 | -| IJT808MsgConsumer | 数据消费接口 | 将数据进行对应的消息业务处理(例:设备流量统计、第三方平台数据转发、消息日志等) | -| IJT808MsgReplyProducer | 应答数据生产接口 | 将生产的数据解析为对应的消息Id应答发送到队列 | -| IJT808MsgReplyConsumer | 应答数据消费接口 | 将接收到的应答数据下发给设备 | +| 接口名称 | 接口说明 | 使用场景 | +| :---------------------------- | :-------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- | +| IJT808SessionProducer | 会话通知(在线/离线)数据生产接口 | 有些超长待机的设备,不会实时保持连接,那么通过平台下发的命令是无法到达的,这时候就需要设备一上线,就即时通知服务去处理,然后在即时的下发消息到设备。 | +| IJT808SessionConsumer | 会话通知(在线/离线)数据消费接口 | - | +| IJT808MsgProducer | 数据生产接口 | 网关将接收到的数据发送到队列 | +| IJT808MsgConsumer | 数据消费接口 | 将数据进行对应的消息业务处理(例:设备流量统计、第三方平台数据转发、消息日志等) | +| IJT808MsgReplyProducer | 应答数据生产接口 | 将生产的数据解析为对应的消息Id应答发送到队列 | +| IJT808MsgReplyConsumer | 应答数据消费接口 | 将接收到的应答数据下发给设备 | | IJT808MsgReplyLoggingProducer | 网关应答数据日志生产接口 | 将网关能解析到直接能下发的数据发送到队列 | | IJT808MsgReplyLoggingConsumer | 网关应答数据日志消费接口 | 将网关能解析到直接能下发的数据发送到日志系统 | @@ -36,13 +36,13 @@ Pipeline分为两种方式使用,一种是使用队列的方式,一种是网 ### Pipeline的NuGet安装 -| Package Name | Version | Preview Version | Downloads | -| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | -| Install-Package JT808.Gateway.Abstractions | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/v/JT808.Gateway.Abstractions.svg) | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/vpre/JT808.Gateway.Abstractions.svg) | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/dt/JT808.Gateway.Abstractions.svg) | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/dt/JT808.Gateway.Abstractions.svg) | -| Install-Package JT808.Gateway | ![JT808.Gateway](https://img.shields.io/nuget/v/JT808.Gateway.svg) | ![JT808.Gateway](https://img.shields.io/nuget/vpre/JT808.Gateway.svg) | ![JT808.Gateway](https://img.shields.io/nuget/dt/JT808.Gateway.svg) | -| Install-Package JT808.Gateway.WebApiClientTool | ![JT808.Gateway.WebApiClientTool](https://img.shields.io/nuget/v/JT808.Gateway.WebApiClientTool.svg) | ![JT808.Gateway.WebApiClientTool](https://img.shields.io/nuget/vpre/JT808.Gateway.WebApiClientTool.svg) | ![JT808.Gateway.WebApiClientTool](https://img.shields.io/nuget/dt/JT808.Gateway.WebApiClientTool.svg) | -| Install-Package JT808.Gateway.Client | ![JT808.Gateway.Client](https://img.shields.io/nuget/v/JT808.Gateway.Client.svg) | ![JT808.Gateway.Client](https://img.shields.io/nuget/vpre/JT808.Gateway.Client.svg) | ![JT808.Gateway.Client](https://img.shields.io/nuget/dt/JT808.Gateway.Client.svg) | -| Install-Package JT808.Gateway.Kafka | ![JT808.Gateway.Kafka](https://img.shields.io/nuget/v/JT808.Gateway.Kafka.svg) | ![JT808.Gateway.Kafka](https://img.shields.io/nuget/vpre/JT808.Gateway.Kafka.svg) | ![JT808.Gateway.MsgIdHandler](https://img.shields.io/nuget/dt/JT808.Gateway.MsgIdHandler.svg) | +| Package Name | Version | Preview Version | Downloads | +| ---------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | +| Install-Package JT808.Gateway.Abstractions | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/v/JT808.Gateway.Abstractions.svg) | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/vpre/JT808.Gateway.Abstractions.svg) | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/dt/JT808.Gateway.Abstractions.svg) | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/dt/JT808.Gateway.Abstractions.svg) | +| Install-Package JT808.Gateway | ![JT808.Gateway](https://img.shields.io/nuget/v/JT808.Gateway.svg) | ![JT808.Gateway](https://img.shields.io/nuget/vpre/JT808.Gateway.svg) | ![JT808.Gateway](https://img.shields.io/nuget/dt/JT808.Gateway.svg) | +| Install-Package JT808.Gateway.WebApiClientTool | ![JT808.Gateway.WebApiClientTool](https://img.shields.io/nuget/v/JT808.Gateway.WebApiClientTool.svg) | ![JT808.Gateway.WebApiClientTool](https://img.shields.io/nuget/vpre/JT808.Gateway.WebApiClientTool.svg) | ![JT808.Gateway.WebApiClientTool](https://img.shields.io/nuget/dt/JT808.Gateway.WebApiClientTool.svg) | +| Install-Package JT808.Gateway.Client | ![JT808.Gateway.Client](https://img.shields.io/nuget/v/JT808.Gateway.Client.svg) | ![JT808.Gateway.Client](https://img.shields.io/nuget/vpre/JT808.Gateway.Client.svg) | ![JT808.Gateway.Client](https://img.shields.io/nuget/dt/JT808.Gateway.Client.svg) | +| Install-Package JT808.Gateway.Kafka | ![JT808.Gateway.Kafka](https://img.shields.io/nuget/v/JT808.Gateway.Kafka.svg) | ![JT808.Gateway.Kafka](https://img.shields.io/nuget/vpre/JT808.Gateway.Kafka.svg) | ![JT808.Gateway.MsgIdHandler](https://img.shields.io/nuget/dt/JT808.Gateway.MsgIdHandler.svg) | ## 举个栗子 @@ -57,7 +57,7 @@ Pipeline分为两种方式使用,一种是使用队列的方式,一种是网 3.进入JT808.Gateway.SimpleClient项目下的Debug目录运行客户端 如图所示: -![demo3](https://github.com/SmallChi/JT808Gateway/blob/master/doc/img/demo3.png) +![demo3](doc/img/demo3.png) #### 使用队列方式 @@ -75,7 +75,24 @@ Pipeline分为两种方式使用,一种是使用队列的方式,一种是网 > 注意:需要安装kafka和zookeeper 如图所示: -![demo4](https://github.com/SmallChi/JT808Gateway/blob/master/doc/img/demo4.png) +![demo4](doc/img/demo4.png) + +## Docker + +此处以`vscode`为例,使用`vscode`打开当前文件夹 + +打包镜像 + +>当前仅打包[`simples/JT808.Gateway.SimpleServer`](simples/JT808.Gateway.SimpleServer),可根据需求自行更改 + +- 按下`F1`按键 +- 选择运行任务 +- 选择打包示例网关镜像 + +运行容器 +- 运行`docker compose up` + +使用tcp工具或本项目中的示例项目测试本地`808`端口, ## 常见问题 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ee1d477 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +services: + gateway: + image: gateway-simple + build: + context: . + dockerfile: Dockerfile + privileged: true + container_name: gateway-simple + ports: + - 5000:80 + - 808:808 + logging: + driver: "json-file" + options: + max-size: "50m" diff --git a/simples/pipeline.props b/simples/pipeline.props index 087f616..240541f 100644 --- a/simples/pipeline.props +++ b/simples/pipeline.props @@ -1,8 +1,4 @@  - - none - false -