From 70b8b623cfd8e8af320053a2da75430f5e14158f Mon Sep 17 00:00:00 2001 From: "SmallChi(Koike)" <564952747@qq.com> Date: Mon, 14 Sep 2020 14:15:03 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=AE=8C=E5=96=84webapi=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=87=E6=A1=A3=202.=E4=BF=AE=E6=94=B9readme=E6=96=87?= =?UTF-8?q?=E6=A1=A3=203.=E5=8F=91=E5=B8=831.0.2-pre1=EF=BC=88=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=8A=9F=E8=83=BD=E6=9C=AA=E5=AE=9E=E7=8E=B0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 30 +- api/README.md | 235 +----- api/README_DotNetty.md | 294 +++++++ api/README_Pipeline.md | 301 ++++++++ publish.gateway.bat | 2 +- .../JT808.Gateway.Abstractions.xml | 726 +++--------------- ...pl.cs => JT808CustomMessageHandlerImpl.cs} | 35 +- .../JT808.Gateway.NormalHosting.csproj | 1 - .../JT808.Gateway.NormalHosting/Program.cs | 11 +- .../appsettings.json | 1 + .../JT808.Gateway.NormalHosting/startup.ini | 3 + src/JT808.Gateway/JT808GatewayExtensions.cs | 17 +- src/Version.props | 2 +- 13 files changed, 770 insertions(+), 888 deletions(-) create mode 100644 api/README_DotNetty.md create mode 100644 api/README_Pipeline.md rename src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/{JT808NormalReplyMessageHandlerImpl.cs => JT808CustomMessageHandlerImpl.cs} (63%) create mode 100644 src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/startup.ini diff --git a/README.md b/README.md index 9c59246..8de544d 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,9 @@ 通过继承JT808.DotNetty.Core.Handlers.JT808MsgIdHttpHandlerBase去实现自定义的WebApi接口服务。 -## 基于GRPC的消息业务处理程序 +通过继承JT808.Gateway.Handlers.JT808MsgIdDefaultWebApiHandler去实现自定义的WebApi接口服务。 -[GRPC消息业务处理协议](https://github.com/SmallChi/JT808Gateway/blob/master/src/JT808.Gateway.Abstractions/Protos/JT808Gateway.proto) +[接口文档](https://github.com/SmallChi/JT808Gateway/tree/master/api) ## 基于core 3.1 Pipeline @@ -70,18 +70,19 @@ Pipeline分为两种方式使用,一种是使用队列的方式,一种是网 ### Pipeline的NuGet安装 -| Package Name | 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/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/dt/JT808.Gateway.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/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/dt/JT808.Gateway.Kafka.svg) | -| Install-Package JT808.Gateway.Transmit | ![JT808.Gateway.Transmit](https://img.shields.io/nuget/v/JT808.Gateway.Transmit.svg) | ![JT808.Gateway.Transmit](https://img.shields.io/nuget/dt/JT808.Gateway.Transmit.svg) | -| Install-Package JT808.Gateway.Traffic | ![JT808.Gateway.Traffic](https://img.shields.io/nuget/v/JT808.Gateway.Traffic.svg) | ![JT808.Gateway.Traffic](https://img.shields.io/nuget/dt/JT808.Gateway.Traffic.svg)| -| Install-Package JT808.Gateway.SessionNotice | ![JT808.Gateway.SessionNotice](https://img.shields.io/nuget/v/JT808.Gateway.SessionNotice.svg) | ![JT808.Gateway.SessionNotice](https://img.shields.io/nuget/dt/JT808.Gateway.SessionNotice.svg)| -| Install-Package JT808.Gateway.ReplyMessage | ![JT808.Gateway.ReplyMessage](https://img.shields.io/nuget/v/JT808.Gateway.ReplyMessage.svg) | ![JT808.Gateway.ReplyMessage](https://img.shields.io/nuget/dt/JT808.Gateway.ReplyMessage.svg)| -| Install-Package JT808.Gateway.MsgLogging | ![JT808.Gateway.MsgLogging](https://img.shields.io/nuget/v/JT808.Gateway.MsgLogging.svg) | ![JT808.Gateway.MsgLogging](https://img.shields.io/nuget/dt/JT808.Gateway.MsgLogging.svg)| -| Install-Package JT808.Gateway.MsgIdHandler | ![JT808.Gateway.MsgIdHandler](https://img.shields.io/nuget/v/JT808.Gateway.MsgIdHandler.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.Kafka](https://img.shields.io/nuget/dt/JT808.Gateway.Kafka.svg) | +| Install-Package JT808.Gateway.Transmit | ![JT808.Gateway.Transmit](https://img.shields.io/nuget/v/JT808.Gateway.Transmit.svg) |![JT808.Gateway.Transmit](https://img.shields.io/nuget/vpre/JT808.Gateway.Transmit.svg)| ![JT808.Gateway.Transmit](https://img.shields.io/nuget/dt/JT808.Gateway.Transmit.svg) | +| Install-Package JT808.Gateway.Traffic | ![JT808.Gateway.Traffic](https://img.shields.io/nuget/v/JT808.Gateway.Traffic.svg) | ![JT808.Gateway.Traffic](https://img.shields.io/nuget/vpre/JT808.Gateway.Traffic.svg)|![JT808.Gateway.Traffic](https://img.shields.io/nuget/dt/JT808.Gateway.Traffic.svg)| +| Install-Package JT808.Gateway.SessionNotice | ![JT808.Gateway.SessionNotice](https://img.shields.io/nuget/v/JT808.Gateway.SessionNotice.svg) |![JT808.Gateway.SessionNotice](https://img.shields.io/nuget/vpre/JT808.Gateway.SessionNotice.svg)| ![JT808.Gateway.SessionNotice](https://img.shields.io/nuget/dt/JT808.Gateway.SessionNotice.svg)| +| Install-Package JT808.Gateway.ReplyMessage | ![JT808.Gateway.ReplyMessage](https://img.shields.io/nuget/v/JT808.Gateway.ReplyMessage.svg) |![JT808.Gateway.ReplyMessage](https://img.shields.io/nuget/vpre/JT808.Gateway.ReplyMessage.svg) | ![JT808.Gateway.ReplyMessage](https://img.shields.io/nuget/dt/JT808.Gateway.ReplyMessage.svg)| +| Install-Package JT808.Gateway.MsgLogging | ![JT808.Gateway.MsgLogging](https://img.shields.io/nuget/v/JT808.Gateway.MsgLogging.svg) | ![JT808.Gateway.MsgLogging](https://img.shields.io/nuget/vpre/JT808.Gateway.MsgLogging.svg)|![JT808.Gateway.MsgLogging](https://img.shields.io/nuget/dt/JT808.Gateway.MsgLogging.svg)| +| Install-Package JT808.Gateway.MsgIdHandler | ![JT808.Gateway.MsgIdHandler](https://img.shields.io/nuget/v/JT808.Gateway.MsgIdHandler.svg) |![JT808.Gateway.MsgIdHandler](https://img.shields.io/nuget/vpre/JT808.Gateway.MsgIdHandler.svg)| ![JT808.Gateway.MsgIdHandler](https://img.shields.io/nuget/dt/JT808.Gateway.MsgIdHandler.svg)| ## 基于DotNetty @@ -103,7 +104,6 @@ Pipeline分为两种方式使用,一种是使用队列的方式,一种是网 | Install-Package JT808.DotNetty.MsgLogging | ![JT808.DotNetty.MsgLogging](https://img.shields.io/nuget/v/JT808.DotNetty.MsgLogging.svg) | ![JT808.DotNetty.MsgLogging](https://img.shields.io/nuget/dt/JT808.DotNetty.MsgLogging.svg)| | Install-Package JT808.DotNetty.MsgIdHandler | ![JT808.DotNetty.MsgIdHandler](https://img.shields.io/nuget/v/JT808.DotNetty.MsgIdHandler.svg) | ![JT808.DotNetty.MsgIdHandler](https://img.shields.io/nuget/dt/JT808.DotNetty.MsgIdHandler.svg)| | Install-Package JT808.DotNetty.Kafka | ![JT808.DotNetty.Kafka](https://img.shields.io/nuget/v/JT808.DotNetty.Kafka.svg) | ![JT808.DotNetty.Kafka](https://img.shields.io/nuget/dt/JT808.DotNetty.Kafka.svg) | -| Install-Package JT808.DotNetty.RabbitMQ | ![JT808.DotNetty.RabbitMQ](https://img.shields.io/nuget/v/JT808.DotNetty.RabbitMQ.svg) | ![JT808.DotNetty.RabbitMQ](https://img.shields.io/nuget/dt/JT808.DotNetty.RabbitMQ.svg) | ## 举个栗子 diff --git a/api/README.md b/api/README.md index c7b2c43..e827127 100644 --- a/api/README.md +++ b/api/README.md @@ -1,234 +1,5 @@ -# JT808 WebApi服务 +# JT808 WebApi 接口文档 -基地址:127.0.0.1:828/jt808api/ +[基于JT808Gateway WebApi接口文档](https://github.com/SmallChi/JT808Gateway/tree/master/api/README_Pipeline.md) -> 注意url格式 - -数据格式:只支持Json格式 - -默认端口:828 - -## 1.统一下发设备消息服务 - -[统一下发设备消息服务](#send) - -## 2.管理会话服务 - -[基于Tcp管理会话服务](#tcp_session) - -[基于Udp管理会话服务](#udp_session) - -## 接口请求对照表 - -### 公共接口请求 - -|请求Url|请求方式|说明| -|:------|:------|:------| -| 127.0.0.1:828/jt808api/UnificationSend| POST| 统一下发设备消息服务| - -### 基于Tcp接口请求 - -|请求Url|请求方式|说明| -|:------|:------|:------| -| 127.0.0.1:828/jt808api/Tcp/Session/GetAll| GET| 基于Tcp管理会话服务-获取会话集合| -| 127.0.0.1:828/jt808api/Tcp/Session/QueryTcpSessionByTerminalPhoneNo| POST| 基于Tcp管理会话服务-通过设备终端号查询对应会话| -| 127.0.0.1:828/jt808api/Tcp/Session/RemoveByTerminalPhoneNo| POST| 基于Tcp管理会话服务-通过设备终端号移除对应会话| - -### 基于Udp接口请求 - -|请求Url|请求方式|说明| -|:------|:------|:------| -| 127.0.0.1:828/jt808api/Udp/Session/GetAll| GET| 基于Udp管理会话服务-获取会话集合| -| 127.0.0.1:828/jt808api/Udp/Session/RemoveByTerminalPhoneNo| POST| 基于Udp管理会话服务-通过设备终端号移除对应会话| - -### 统一对象返回 JT808ResultDto\ - -|属性|数据类型|参数说明| -|:------:|:------:|:------| -| Message| string| 消息描述| -| Code| int| 状态码| -| Data| T(泛型)| 数据| - -返回Code[状态码]说明: - -|状态码|说明| -|:------:|:------:| -| 200 | 返回成功 | -| 201 | 内容为空 | -| 404 | 没有该服务 | -| 500 | 服务内部错误 | - -### 基于Tcp统一下发设备消息服务 - -请求地址:/UnificationSend - -请求方式:POST - -请求参数: - -|属性|数据类型|参数说明| -|------|:------:|:------| -| TerminalPhoneNo| string| 设备终端号| -| Data| byte[]| JT808 byte[]数组| - -返回数据: - -|属性|数据类型|参数说明| -|:------:|:------:|:------| -| Data| bool| 是否成功| - -返回结果: - -``` result1 -{ - "Message":"", - "Code":200, - "Data":true -} -``` - -### 基于Tcp管理会话服务 - -#### 统一会话信息对象返回 JT808TcpSessionInfoDto - -|属性|数据类型|参数说明| -|------|------|------| -| LastActiveTime| DateTime| 最后上线时间| -| StartTime| DateTime| 上线时间| -| TerminalPhoneNo|string| 终端手机号| -| RemoteAddressIP| string| 远程ip地址| - -#### 1.获取会话集合 - -请求地址:Tcp/Session/GetAll - -请求方式:GET - -返回数据: - -|属性|数据类型|参数说明| -|:------:|:------:|:------| -| Data| List\ | 实际会话信息集合 | - -返回结果: - -``` session1 -{ - "Message":"", - "Code":200, - "Data":[ - { - "LastActiveTime":"2018-11-27 20:00:00", - "StartTime":"2018-11-25 20:00:00", - "TerminalPhoneNo":"123456789012", - "RemoteAddressIP":"127.0.0.1:11808" - },{ - "LastActiveTime":"2018-11-27 20:00:00", - "StartTime":"2018-11-25 20:00:00", - "TerminalPhoneNo":"123456789013", - "RemoteAddressIP":"127.0.0.1:11808" - } - ] -} -``` - -#### 2.通过设备终端号移除对应会话 - -请求地址:Tcp/Session/RemoveByTerminalPhoneNo - -请求方式:POST - -请求参数: - -|属性|数据类型|参数说明| -|:------:|:------:|:------| -| terminalPhoneNo| string| 设备终端号| - -返回数据: - -|属性|数据类型|参数说明| -|:------:|:------:|:------| -| Data| bool | 是否成功 - -返回结果: - -``` session3 -{ - "Message":"", - "Code":200, - "Data":true -} -``` - -### 基于Udp管理会话服务 - -#### 统一会话信息对象返回 JT808UdpSessionInfoDto - -|属性|数据类型|参数说明| -|------|------|------| -| LastActiveTime| DateTime| 最后上线时间| -| StartTime| DateTime| 上线时间| -| TerminalPhoneNo|string| 终端手机号| -| RemoteAddressIP| string| 远程ip地址| - -#### 1.获取会话集合 - -请求地址:Udp/Session/GetAll - -请求方式:GET - -返回数据: - -|属性|数据类型|参数说明| -|:------:|:------:|:------| -| Data| List\ | 实际会话信息集合 | - -返回结果: - -``` session1 -{ - "Message":"", - "Code":200, - "Data":[ - { - "LastActiveTime":"2018-11-27 20:00:00", - "StartTime":"2018-11-25 20:00:00", - "TerminalPhoneNo":"123456789012", - "RemoteAddressIP":"127.0.0.1:11808" - },{ - "LastActiveTime":"2018-11-27 20:00:00", - "StartTime":"2018-11-25 20:00:00", - "TerminalPhoneNo":"123456789013", - "RemoteAddressIP":"127.0.0.1:11808" - } - ] -} -``` - -#### 2.通过设备终端号移除对应会话 - -请求地址:Udp/Session/RemoveByTerminalPhoneNo - -请求方式:POST - -请求参数: - -|属性|数据类型|参数说明| -|:------:|:------:|:------| -| terminalPhoneNo| string| 设备终端号| - -返回数据: - -|属性|数据类型|参数说明| -|:------:|:------:|:------| -| Data| bool | 是否成功 - -返回结果: - -``` session3 -{ - "Message":"", - "Code":200, - "Data":true -} -``` +[基于JT808DotNetty WebApi接口文档](https://github.com/SmallChi/JT808Gateway/tree/master/api/README_DotNetty.md) diff --git a/api/README_DotNetty.md b/api/README_DotNetty.md new file mode 100644 index 0000000..7125579 --- /dev/null +++ b/api/README_DotNetty.md @@ -0,0 +1,294 @@ +# 基于JT808DotNetty WebApi 接口文档 + +基地址:127.0.0.1:828/jt808api/ + +> 注意url格式 + +数据格式:只支持Json格式 + +默认端口:828 + +## 1.统一下发设备消息服务 + +[统一下发设备消息服务](#send) + +## 2.管理会话服务 + +[基于Tcp管理会话服务](#tcp_session) + +[基于Udp管理会话服务](#udp_session) + +## 4.消息包计数服务 + +[基于Tcp消息包计数服务](#tcp_counter) + +[基于Udp消息包计数服务](#udp_counter) + +## 接口请求对照表 + +### 公共接口请求 + +|请求Url|请求方式|说明| +|:------|:------|:------| +| 127.0.0.1:828/jt808api/UnificationSend| POST| 统一下发设备消息服务| + +### 基于Tcp接口请求 + +|请求Url|请求方式|说明| +|:------|:------|:------| +| 127.0.0.1:828/jt808api/Tcp/Session/GetAll| GET| 基于Tcp管理会话服务-获取会话集合| +| 127.0.0.1:828/jt808api/Tcp/Session/QueryTcpSessionByTerminalPhoneNo| POST| 基于Tcp管理会话服务-通过设备终端号查询对应会话| +| 127.0.0.1:828/jt808api/Tcp/Session/RemoveByTerminalPhoneNo| POST| 基于Tcp管理会话服务-通过设备终端号移除对应会话| +| 127.0.0.1:828/jt808api/Tcp/GetAtomicCounter| GET| 基于Tcp消息包计数服务| + +### 基于Udp接口请求 + +|请求Url|请求方式|说明| +|:------|:------|:------| +| 127.0.0.1:828/jt808api/Udp/Session/GetAll| GET| 基于Udp管理会话服务-获取会话集合| +| 127.0.0.1:828/jt808api/Udp/Session/RemoveByTerminalPhoneNo| POST| 基于Udp管理会话服务-通过设备终端号移除对应会话| +| 127.0.0.1:828/jt808api/Udp/GetAtomicCounter| GET| 基于Udp消息包计数服务| + +### 统一对象返回 JT808ResultDto\ + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Message| string| 消息描述| +| Code| int| 状态码| +| Data| T(泛型)| 数据| + +返回Code[状态码]说明: + +|状态码|说明| +|:------:|:------:| +| 200 | 返回成功 | +| 201 | 内容为空 | +| 404 | 没有该服务 | +| 500 | 服务内部错误 | + +### 基于Tcp统一下发设备消息服务 + +请求地址:/UnificationSend + +请求方式:POST + +请求参数: + +|属性|数据类型|参数说明| +|------|:------:|:------| +| TerminalPhoneNo| string| 设备终端号| +| Data| byte[]| JT808 byte[]数组| + +返回数据: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Data| bool| 是否成功| + +返回结果: + +``` result1 +{ + "Message":"", + "Code":200, + "Data":true +} +``` + +### 基于Tcp管理会话服务 + +#### 统一会话信息对象返回 JT808TcpSessionInfoDto + +|属性|数据类型|参数说明| +|------|------|------| +| LastActiveTime| DateTime| 最后上线时间| +| StartTime| DateTime| 上线时间| +| TerminalPhoneNo|string| 终端手机号| +| RemoteAddressIP| string| 远程ip地址| + +#### 1.获取会话集合 + +请求地址:Tcp/Session/GetAll + +请求方式:GET + +返回数据: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Data| List\ | 实际会话信息集合 | + +返回结果: + +``` session1 +{ + "Message":"", + "Code":200, + "Data":[ + { + "LastActiveTime":"2018-11-27 20:00:00", + "StartTime":"2018-11-25 20:00:00", + "TerminalPhoneNo":"123456789012", + "RemoteAddressIP":"127.0.0.1:11808" + },{ + "LastActiveTime":"2018-11-27 20:00:00", + "StartTime":"2018-11-25 20:00:00", + "TerminalPhoneNo":"123456789013", + "RemoteAddressIP":"127.0.0.1:11808" + } + ] +} +``` + +#### 2.通过设备终端号移除对应会话 + +请求地址:Tcp/Session/RemoveByTerminalPhoneNo + +请求方式:POST + +请求参数: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| terminalPhoneNo| string| 设备终端号| + +返回数据: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Data| bool | 是否成功 + +返回结果: + +``` session3 +{ + "Message":"", + "Code":200, + "Data":true +} +``` + +### 基于Udp管理会话服务 + +#### 统一会话信息对象返回 JT808UdpSessionInfoDto + +|属性|数据类型|参数说明| +|------|------|------| +| LastActiveTime| DateTime| 最后上线时间| +| StartTime| DateTime| 上线时间| +| TerminalPhoneNo|string| 终端手机号| +| RemoteAddressIP| string| 远程ip地址| + +#### 1.获取会话集合 + +请求地址:Udp/Session/GetAll + +请求方式:GET + +返回数据: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Data| List\ | 实际会话信息集合 | + +返回结果: + +``` session1 +{ + "Message":"", + "Code":200, + "Data":[ + { + "LastActiveTime":"2018-11-27 20:00:00", + "StartTime":"2018-11-25 20:00:00", + "TerminalPhoneNo":"123456789012", + "RemoteAddressIP":"127.0.0.1:11808" + },{ + "LastActiveTime":"2018-11-27 20:00:00", + "StartTime":"2018-11-25 20:00:00", + "TerminalPhoneNo":"123456789013", + "RemoteAddressIP":"127.0.0.1:11808" + } + ] +} +``` + +#### 2.通过设备终端号移除对应会话 + +请求地址:Udp/Session/RemoveByTerminalPhoneNo + +请求方式:POST + +请求参数: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| terminalPhoneNo| string| 设备终端号| + +返回数据: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Data| bool | 是否成功 + +返回结果: + +``` session3 +{ + "Message":"", + "Code":200, + "Data":true +} +``` + +### 基于Tcp消息包计数服务 + +请求地址:Tcp/GetAtomicCounter + +请求方式:GET + +返回数据: + +|属性|数据类型|参数说明| +|------|:------:|:------| +| MsgSuccessCount| long| 消息包成功数| +| MsgFailCount| long| 消息包失败数| + +返回结果: + +``` counter +{ + "Message":"", + "Code":200, + "Data":{ + "MsgSuccessCount":10000, + "MsgFailCount":0 + } +} +``` + +### 基于Udp消息包计数服务 + +请求地址:Udp/GetAtomicCounter + +请求方式:GET + +返回数据: + +|属性|数据类型|参数说明| +|------|:------:|:------| +| MsgSuccessCount| long| 消息包成功数| +| MsgFailCount| long| 消息包失败数| + +返回结果: + +``` counter +{ + "Message":"", + "Code":200, + "Data":{ + "MsgSuccessCount":1000, + "MsgFailCount":0 + } +} +``` diff --git a/api/README_Pipeline.md b/api/README_Pipeline.md new file mode 100644 index 0000000..3ef8112 --- /dev/null +++ b/api/README_Pipeline.md @@ -0,0 +1,301 @@ +# 基于JT808Gateway WebApi 接口文档 + +基地址:127.0.0.1:828/jt808api/ + +> 注意url格式 + +数据格式:只支持Json格式 + +默认端口:828 + +## 1.统一下发设备消息服务 + +[统一下发设备消息服务](#send) + +## 2.管理会话服务 + +[基于Tcp管理会话服务](#tcp_session) + +[基于Udp管理会话服务](#udp_session) + +## 接口请求对照表 + +### 公共接口请求 + +|请求Url|请求方式|说明| +|:------|:------|:------| +| 127.0.0.1:828/jt808api/UnificationSend| POST| 统一下发设备消息服务| + +### 基于Tcp接口请求 + +|请求Url|请求方式|说明| +|:------|:------|:------| +| 127.0.0.1:828/jt808api/Tcp/Session/GetAll| GET| 基于Tcp管理会话服务-获取会话集合| +| 127.0.0.1:828/jt808api/Tcp/Session/QueryTcpSessionByTerminalPhoneNo| POST| 基于Tcp管理会话服务-通过设备终端号查询对应会话| +| 127.0.0.1:828/jt808api/Tcp/Session/RemoveByTerminalPhoneNo| POST| 基于Tcp管理会话服务-通过设备终端号移除对应会话| + +### 基于Udp接口请求 + +|请求Url|请求方式|说明| +|:------|:------|:------| +| 127.0.0.1:828/jt808api/Udp/Session/GetAll| GET| 基于Udp管理会话服务-获取会话集合| +| 127.0.0.1:828/jt808api/Udp/Session/QueryUdpSessionByTerminalPhoneNo| POST| 基于Udp管理会话服务-通过设备终端号查询对应会话| +| 127.0.0.1:828/jt808api/Udp/Session/RemoveUdpByTerminalPhoneNo| POST| 基于Udp管理会话服务-通过设备终端号移除对应会话| + +### 统一对象返回 JT808ResultDto\ + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Message| string| 消息描述| +| Code| int| 状态码| +| Data| T(泛型)| 数据| + +返回Code[状态码]说明: + +|状态码|说明| +|:------:|:------:| +| 200 | 返回成功 | +| 201 | 内容为空 | +| 404 | 没有该服务 | +| 500 | 服务内部错误 | + +### 基于Tcp统一下发设备消息服务 + +请求地址:/UnificationSend + +请求方式:POST + +请求参数: + +|属性|数据类型|参数说明| +|------|:------:|:------| +| TerminalPhoneNo| string| 设备终端号| +| HexData| string| JT808 Hex String JT808数据包字符串| + +返回数据: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Data| bool| 是否成功| + +返回结果: + +``` result1 +{ + "Message":"", + "Code":200, + "Data":true +} +``` + +### 基于Tcp管理会话服务 + +#### 统一会话信息对象返回 JT808TcpSessionInfoDto + +|属性|数据类型|参数说明| +|------|------|------| +| LastActiveTime| DateTime| 最后上线时间| +| StartTime| DateTime| 上线时间| +| TerminalPhoneNo|string| 终端手机号| +| RemoteAddressIP| string| 远程ip地址| + +#### 1.获取会话集合 + +请求地址:Tcp/Session/GetAll + +请求方式:GET + +返回数据: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Data| List\ | 实际会话信息集合 | + +返回结果: + +``` session1 +{ + "Message":"", + "Code":200, + "Data":[ + { + "LastActiveTime":"2018-11-27 20:00:00", + "StartTime":"2018-11-25 20:00:00", + "TerminalPhoneNo":"123456789012", + "RemoteAddressIP":"127.0.0.1:11808" + },{ + "LastActiveTime":"2018-11-27 20:00:00", + "StartTime":"2018-11-25 20:00:00", + "TerminalPhoneNo":"123456789013", + "RemoteAddressIP":"127.0.0.1:11808" + } + ] +} +``` + +#### 2.通过设备终端号查询对应会话 + +请求地址:Tcp/Session/QueryTcpSessionByTerminalPhoneNo + +请求方式:POST + +请求参数: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| terminalPhoneNo| string| 设备终端号| + +返回数据: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Data| JT808TcpSessionInfoDto对象 | 统一会话信息对象返回 | + +返回结果: + +``` session2 +{ + "Message":"", + "Code":200, + "Data": { + "LastActiveTime":"2018-11-27 20:00:00", + "StartTime":"2018-11-25 20:00:00", + "TerminalPhoneNo":"123456789012", + "RemoteAddressIP":"127.0.0.1:11808" + } +} +``` + +#### 3.通过设备终端号移除对应会话 + +请求地址:Tcp/Session/RemoveByTerminalPhoneNo + +请求方式:POST + +请求参数: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| terminalPhoneNo| string| 设备终端号| + +返回数据: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Data| bool | 是否成功 + +返回结果: + +``` session3 +{ + "Message":"", + "Code":200, + "Data":true +} +``` + +### 基于Udp管理会话服务 + +#### 统一会话信息对象返回 JT808UdpSessionInfoDto + +|属性|数据类型|参数说明| +|------|------|------| +| LastActiveTime| DateTime| 最后上线时间| +| StartTime| DateTime| 上线时间| +| TerminalPhoneNo|string| 终端手机号| +| RemoteAddressIP| string| 远程ip地址| + +#### 1.获取会话集合 + +请求地址:Udp/Session/GetAll + +请求方式:GET + +返回数据: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Data| List\ | 实际会话信息集合 | + +返回结果: + +``` session1 +{ + "Message":"", + "Code":200, + "Data":[ + { + "LastActiveTime":"2018-11-27 20:00:00", + "StartTime":"2018-11-25 20:00:00", + "TerminalPhoneNo":"123456789012", + "RemoteAddressIP":"127.0.0.1:11808" + },{ + "LastActiveTime":"2018-11-27 20:00:00", + "StartTime":"2018-11-25 20:00:00", + "TerminalPhoneNo":"123456789013", + "RemoteAddressIP":"127.0.0.1:11808" + } + ] +} +``` + +#### 2.通过设备终端号查询对应会话 + +请求地址:Udp/Session/QueryUdpSessionByTerminalPhoneNo + +请求方式:POST + +请求参数: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| terminalPhoneNo| string| 设备终端号| + +返回数据: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Data| JT808UdpSessionInfoDto对象 | 统一会话信息对象返回 | + +返回结果: + +``` session2 +{ + "Message":"", + "Code":200, + "Data":{ + "LastActiveTime":"2018-11-27 20:00:00", + "StartTime":"2018-11-25 20:00:00", + "TerminalPhoneNo":"123456789012", + "RemoteAddressIP":"127.0.0.1:11808" + } +} +``` + +#### 3.通过设备终端号移除对应会话 + +请求地址:Udp/Session/RemoveByTerminalPhoneNo + +请求方式:POST + +请求参数: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| terminalPhoneNo| string| 设备终端号| + +返回数据: + +|属性|数据类型|参数说明| +|:------:|:------:|:------| +| Data| bool | 是否成功 + +返回结果: + +``` session3 +{ + "Message":"", + "Code":200, + "Data":true +} +``` diff --git a/publish.gateway.bat b/publish.gateway.bat index 5b6be19..1484e64 100644 --- a/publish.gateway.bat +++ b/publish.gateway.bat @@ -2,6 +2,7 @@ dotnet pack .\src\JT808.Gateway\JT808.Gateway.csproj -c Release --output nupkgs dotnet pack .\src\JT808.Gateway.Kafka\JT808.Gateway.Kafka.csproj -c Release --output nupkgs dotnet pack .\src\JT808.Gateway.Abstractions\JT808.Gateway.Abstractions.csproj -c Release --output nupkgs dotnet pack .\src\JT808.Gateway.Client\JT808.Gateway.Client.csproj -c Release --output nupkgs +dotnet pack .\src\JT808.Gateway.WebApiClientTool\JT808.Gateway.WebApiClientTool.csproj -c Release --output nupkgs echo 'push service pacakge...' dotnet pack .\src\JT808.Gateway.Services\JT808.Gateway.MsgIdHandler\JT808.Gateway.MsgIdHandler.csproj -c Release --output nupkgs @@ -10,5 +11,4 @@ dotnet pack .\src\JT808.Gateway.Services\JT808.Gateway.ReplyMessage\JT808.Gatewa dotnet pack .\src\JT808.Gateway.Services\JT808.Gateway.SessionNotice\JT808.Gateway.SessionNotice.csproj -c Release --output nupkgs dotnet pack .\src\JT808.Gateway.Services\JT808.Gateway.Traffic\JT808.Gateway.Traffic.csproj -c Release --output nupkgs dotnet pack .\src\JT808.Gateway.Services\JT808.Gateway.Transmit\JT808.Gateway.Transmit.csproj -c Release --output nupkgs - pause \ No newline at end of file diff --git a/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.xml b/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.xml index b4a374d..8f06faa 100644 --- a/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.xml +++ b/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.xml @@ -4,226 +4,172 @@ JT808.Gateway.Abstractions - + - 传输协议类型 + WebApi 默认token 123456 - + - + Tcp读超时 + 默认10分钟检查一次 - 设备终端号 - 808 hex data - + - + Tcp 60s检查一次 - 设备终端号 - 808 hex data - + - 终端手机号 + Udp读超时 - + - 会话通知(在线/离线) + Udp 60s检查一次 - + - 会话通知(在线/离线) + 网关不做消息业务处理,往队列发送 - + - + 最后上线时间 - 请求数据 - 当前会话 - 应答消息数据 - + - 终端通用应答 - 平台无需回复 - 实现自己的业务 + 上线时间 - - - + - 平台通用应答 + 终端手机号 - - - + - 终端心跳 + 远程ip地址 - - - + - 查询服务器时间 - 2019版本 + 最后上线时间 - - - - + - 服务器补传分包请求 + 上线时间 - - - - + - 终端补传分包请求 + 终端手机号 - - - - + - 终端注册 + 远程ip地址 - - - - + - 终端注销 + 统一下发请求参数 - - - - + - 终端鉴权 + 传输协议类型 - - - - + - 查询终端参数应答 + - - - + 设备终端号 + 808 hex data - + - 查询终端属性应答 + - - - + 设备终端号 + 808 hex data - + - 终端升级结果应答 + - - - + 设备终端号 + 808 hex data - + - 位置信息汇报 + 终端手机号 - - - - + - 位置信息查询应答 + 会话通知(在线/离线) - - - - + - 链路检测 - 2019版本 + 会话通知(在线/离线) - - - - + - 车辆控制应答 + 基于Tcp的会话服务集合 - - - - + - 定位数据批量上传 + 会话服务-通过设备终端号移除对应会话 - - - - + - CAN总线数据上传 + 会话服务-通过设备终端号查询对应会话 - - - - + - 多媒体事件信息上传 + 统一下发信息 - - - - + - 多媒体数据上传 + 基于Udp的虚拟会话服务集合 - - - - + - 摄像头立即拍摄命令 + 会话服务-通过设备终端号移除对应会话 - - - - + - 数据上行透传 + 会话服务-通过设备终端号查询对应会话 - - - - + + + 通用消息处理程序 + + + + + 消息处理 + + 请求数据 + 当前会话 + 应答消息数据 + + 终端通用应答 平台无需回复 @@ -232,29 +178,30 @@ - + 平台通用应答 - + 终端心跳 - + 查询服务器时间 2019版本 + - + 服务器补传分包请求 @@ -262,56 +209,63 @@ - + 终端补传分包请求 + - + 终端注册 + - + 终端注销 + - + 终端鉴权 + - + 查询终端参数应答 + - + 查询终端属性应答 + - + 终端升级结果应答 + - + 位置信息汇报 @@ -319,525 +273,83 @@ - + 位置信息查询应答 + - + 链路检测 2019版本 + - + 车辆控制应答 + - + 定位数据批量上传 + - + CAN总线数据上传 + - + 多媒体事件信息上传 + - + 多媒体数据上传 + - + 摄像头立即拍摄命令 + - + 数据上行透传 + - + - 使用正常方式 + 初始化消息处理业务 - - - 使用队列方式 - - - - Holder for reflection information generated from Protos/JT808Gateway.proto - - - File descriptor for Protos/JT808Gateway.proto - - - Field number for the "TcpSessions" field. - - - Field number for the "TerminalPhoneNo" field. - - - Field number for the "Count" field. - - - Field number for the "UdpSessions" field. - - - Field number for the "StartTime" field. - - - Field number for the "LastActiveTime" field. - - - Field number for the "TerminalPhoneNo" field. - - - Field number for the "RemoteAddressIP" field. - - - Field number for the "TerminalPhoneNo" field. - - - Field number for the "Success" field. - - - Field number for the "TerminalPhoneNo" field. - - - Field number for the "Data" field. - - - Field number for the "Success" field. - - - Field number for the "MsgSuccessCount" field. - - - Field number for the "MsgFailCount" field. - - - Field number for the "MsgSuccessCount" field. - - - Field number for the "MsgFailCount" field. - - - Service descriptor - - - Base class for server-side implementations of JT808Gateway - - - - 会话服务-获取会话服务集合 - - The request received from the client. - The context of the server-side call handler being invoked. - The response to send back to the client (wrapped by a task). - - - - 会话服务-获取会话总数 - - The request received from the client. - The context of the server-side call handler being invoked. - The response to send back to the client (wrapped by a task). - - - - 会话服务-通过设备终端号获取当前会话信息 - - The request received from the client. - The context of the server-side call handler being invoked. - The response to send back to the client (wrapped by a task). - - - - 会话服务-通过设备终端号移除对应会话 - - The request received from the client. - The context of the server-side call handler being invoked. - The response to send back to the client (wrapped by a task). - - - - 统一下发信息 - - The request received from the client. - The context of the server-side call handler being invoked. - The response to send back to the client (wrapped by a task). - - - - 获取Tcp包计数器 - - The request received from the client. - The context of the server-side call handler being invoked. - The response to send back to the client (wrapped by a task). - - - - 会话服务-获取会话服务集合 - - The request received from the client. - The context of the server-side call handler being invoked. - The response to send back to the client (wrapped by a task). - - - - 获取Udp包计数器 - - The request received from the client. - The context of the server-side call handler being invoked. - The response to send back to the client (wrapped by a task). - - - Client for JT808Gateway - - - Creates a new client for JT808Gateway - The channel to use to make remote calls. - - - Creates a new client for JT808Gateway that uses a custom CallInvoker. - The callInvoker to use to make remote calls. - - - Protected parameterless constructor to allow creation of test doubles. - - - Protected constructor to allow creation of configured clients. - The client configuration. - - - - 会话服务-获取会话服务集合 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The response received from the server. - - - - 会话服务-获取会话服务集合 - - The request to send to the server. - The options for the call. - The response received from the server. - - - - 会话服务-获取会话服务集合 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The call object. - - - - 会话服务-获取会话服务集合 - - The request to send to the server. - The options for the call. - The call object. - - - - 会话服务-获取会话总数 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The response received from the server. - - - - 会话服务-获取会话总数 - - The request to send to the server. - The options for the call. - The response received from the server. - - - - 会话服务-获取会话总数 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The call object. - - - - 会话服务-获取会话总数 - - The request to send to the server. - The options for the call. - The call object. - - - - 会话服务-通过设备终端号获取当前会话信息 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The response received from the server. - - - - 会话服务-通过设备终端号获取当前会话信息 - - The request to send to the server. - The options for the call. - The response received from the server. - - - - 会话服务-通过设备终端号获取当前会话信息 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The call object. - - - - 会话服务-通过设备终端号获取当前会话信息 - - The request to send to the server. - The options for the call. - The call object. - - - - 会话服务-通过设备终端号移除对应会话 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The response received from the server. - - - - 会话服务-通过设备终端号移除对应会话 - - The request to send to the server. - The options for the call. - The response received from the server. - - - - 会话服务-通过设备终端号移除对应会话 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The call object. - - - - 会话服务-通过设备终端号移除对应会话 - - The request to send to the server. - The options for the call. - The call object. - - - - 统一下发信息 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The response received from the server. - - - - 统一下发信息 - - The request to send to the server. - The options for the call. - The response received from the server. - - - - 统一下发信息 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The call object. - - - - 统一下发信息 - - The request to send to the server. - The options for the call. - The call object. - - - - 获取Tcp包计数器 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The response received from the server. - - - - 获取Tcp包计数器 - - The request to send to the server. - The options for the call. - The response received from the server. - - - - 获取Tcp包计数器 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The call object. - - - - 获取Tcp包计数器 - - The request to send to the server. - The options for the call. - The call object. - - - - 会话服务-获取会话服务集合 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The response received from the server. - - - - 会话服务-获取会话服务集合 - - The request to send to the server. - The options for the call. - The response received from the server. - - - - 会话服务-获取会话服务集合 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The call object. - - - - 会话服务-获取会话服务集合 - - The request to send to the server. - The options for the call. - The call object. - - - - 获取Udp包计数器 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The response received from the server. - - - - 获取Udp包计数器 - - The request to send to the server. - The options for the call. - The response received from the server. - - - - 获取Udp包计数器 - - The request to send to the server. - The initial metadata to send with the call. This parameter is optional. - An optional deadline for the call. The call will be cancelled if deadline is hit. - An optional token for canceling the call. - The call object. - - - - 获取Udp包计数器 - - The request to send to the server. - The options for the call. - The call object. - - - Creates a new instance of client from given ClientBaseConfiguration. - - - Creates service definition that can be registered with a server - An object implementing the server-side handling logic. - - - Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. - Note: this method is part of an experimental API that can change or be removed without any prior notice. - Service methods will be bound by calling AddMethod on this object. - An object implementing the server-side handling logic. - diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808NormalReplyMessageHandlerImpl.cs b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808CustomMessageHandlerImpl.cs similarity index 63% rename from src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808NormalReplyMessageHandlerImpl.cs rename to src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808CustomMessageHandlerImpl.cs index 33f58ad..0492392 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808NormalReplyMessageHandlerImpl.cs +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808CustomMessageHandlerImpl.cs @@ -1,32 +1,35 @@ using JT808.Gateway.Abstractions; +using JT808.Gateway.Abstractions.Configurations; using JT808.Gateway.MsgLogging; using JT808.Gateway.Traffic; using JT808.Gateway.Transmit; using JT808.Protocol; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.Text; namespace JT808.Gateway.NormalHosting.Impl { - public class JT808NormalReplyMessageHandlerImpl : JT808NormalReplyMessageHandler + public class JT808CustomMessageHandlerImpl : JT808MessageHandler { private readonly ILogger logger; - private readonly IJT808Traffic jT808Traffic; + //private readonly IJT808Traffic jT808Traffic; private readonly IJT808MsgLogging jT808MsgLogging; - private readonly JT808TransmitService jT808TransmitService; - public JT808NormalReplyMessageHandlerImpl( - JT808TransmitService jT808TransmitService, + //private readonly JT808TransmitService jT808TransmitService; + public JT808CustomMessageHandlerImpl( + IOptionsMonitor jT808ConfigurationOptionsMonitor, + //JT808TransmitService jT808TransmitService, IJT808MsgLogging jT808MsgLogging, - IJT808Traffic jT808Traffic, + //IJT808Traffic jT808Traffic, ILoggerFactory loggerFactory, - IJT808Config jT808Config) : base(jT808Config) + IJT808Config jT808Config) : base(jT808ConfigurationOptionsMonitor, jT808Config) { - this.jT808TransmitService = jT808TransmitService; - this.jT808Traffic = jT808Traffic; + //this.jT808TransmitService = jT808TransmitService; + //this.jT808Traffic = jT808Traffic; this.jT808MsgLogging = jT808MsgLogging; - logger =loggerFactory.CreateLogger("JT808NormalReplyMessageHandlerImpl"); + logger =loggerFactory.CreateLogger(); //添加自定义消息 HandlerDict.Add(0x9999, Msg0x9999); } @@ -45,14 +48,14 @@ namespace JT808.Gateway.NormalHosting.Impl //AOP 可以自定义添加一些东西:上下行日志、 logger.LogDebug("可以自定义添加一些东西:上下行日志、数据转发"); //流量 - jT808Traffic.Increment(request.Header.TerminalPhoneNo, DateTime.Now.ToString("yyyyMMdd"), request.OriginalData.Length); + //jT808Traffic.Increment(request.Header.TerminalPhoneNo, DateTime.Now.ToString("yyyyMMdd"), request.OriginalData.Length); var parameter = (request.Header.TerminalPhoneNo, request.OriginalData.ToArray()); - //上行日志(可同步也可以使用队列进行异步) - jT808MsgLogging.Processor(parameter, JT808MsgLoggingType.up); - //下行日志(可同步也可以使用队列进行异步) + ////上行日志(可同步也可以使用队列进行异步) + //jT808MsgLogging.Processor(parameter, JT808MsgLoggingType.up); + ////下行日志(可同步也可以使用队列进行异步) jT808MsgLogging.Processor((request.Header.TerminalPhoneNo, down), JT808MsgLoggingType.down); - //转发数据(可同步也可以使用队列进行异步) - jT808TransmitService.SendAsync(parameter); + ////转发数据(可同步也可以使用队列进行异步) + //jT808TransmitService.SendAsync(parameter); } catch (Exception) { diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj index 623e7c3..d338923 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj @@ -6,7 +6,6 @@ - diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs index 4e58ef3..a408a52 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs @@ -46,15 +46,10 @@ namespace JT808.Gateway.NormalHosting services.AddSingleton(); services.AddJT808Configure() //添加客户端工具 - .AddClient() - //.AddNormalGateway(options => - ////{ - //// options.TcpPort = 808; - //// options.UdpPort = 808; - ////}) + //.AddClient() .AddGateway(hostContext.Configuration) - //.ReplaceNormalReplyMessageHandler() - //.AddMsgLogging() + .ReplaceMessageHandler() + .AddMsgLogging() //.AddTraffic() //.AddSessionNotice() //.AddTransmit(hostContext.Configuration) diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/appsettings.json b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/appsettings.json index 5f11142..97d513e 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/appsettings.json +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/appsettings.json @@ -2,6 +2,7 @@ "JT808Configuration": { "TcpPort": 808, "UdpPort": 808, + "WebApiPort": 828, "MiniNumBufferSize": 51200, "SoBacklog": 65535 }, diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/startup.ini b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/startup.ini new file mode 100644 index 0000000..a6a81a6 --- /dev/null +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/startup.ini @@ -0,0 +1,3 @@ +pm2 start "dotnet JT808.Gateway.NormalHosting.dll ASPNETCORE_ENVIRONMENT=Production" --max-restarts=1 -n "JT808.Gateway.NormalHosting" -o "/data/pm2Logs/JT808.Gateway.NormalHosting/out.log" -e "/data/pm2Logs/JT808.Gateway.NormalHosting/error.log" + +pm2 start "dotnet JT808.Gateway.NormalHosting.dll ASPNETCORE_ENVIRONMENT=Development" --max-restarts=1 -n "JT808.Gateway.NormalHosting.Dev" -o "/data/pm2Logs/JT808.Gateway.NormalHosting.Dev/out.log" -e "/data/pm2Logs/JT808.Gateway.NormalHosting.Dev/error.log" diff --git a/src/JT808.Gateway/JT808GatewayExtensions.cs b/src/JT808.Gateway/JT808GatewayExtensions.cs index 289207b..ac7971f 100644 --- a/src/JT808.Gateway/JT808GatewayExtensions.cs +++ b/src/JT808.Gateway/JT808GatewayExtensions.cs @@ -54,12 +54,7 @@ namespace JT808.Gateway // return server; //} - //public static IJT808NormalGatewayBuilder ReplaceNormalReplyMessageHandler(this IJT808NormalGatewayBuilder config) - // where TJT808NormalReplyMessageHandler : JT808NormalReplyMessageHandler - //{ - // config.JT808Builder.Services.Replace(new ServiceDescriptor(typeof(JT808NormalReplyMessageHandler),typeof(TJT808NormalReplyMessageHandler), ServiceLifetime.Singleton)); - // return config; - //} + public static IJT808GatewayBuilder AddGateway(this IJT808Builder jT808Builder, Action config) { @@ -77,6 +72,13 @@ namespace JT808.Gateway return jT808GatewayBuilderDefault; } + public static IJT808GatewayBuilder ReplaceMessageHandler(this IJT808GatewayBuilder config) + where TJT808MessageHandler : JT808MessageHandler + { + config.JT808Builder.Services.Replace(new ServiceDescriptor(typeof(JT808MessageHandler), typeof(TJT808MessageHandler), ServiceLifetime.Singleton)); + return config; + } + public static IJT808GatewayBuilder AddTcp(this IJT808GatewayBuilder config) { config.JT808Builder.Services.AddHostedService(); @@ -110,7 +112,8 @@ namespace JT808.Gateway private static IJT808GatewayBuilder AddJT808Core(this IJT808GatewayBuilder config) { - config.JT808Builder.Services.TryAddSingleton(); + config.JT808Builder.Services.AddSingleton(); + config.JT808Builder.Services.AddSingleton(); return config; } } diff --git a/src/Version.props b/src/Version.props index de259bb..2d7bdef 100644 --- a/src/Version.props +++ b/src/Version.props @@ -1,6 +1,6 @@  2.3.2 - 1.0.1 + 1.0.2-preview1 \ No newline at end of file