Skip to content

Commit bafb801

Browse files
committed
完善文档和示例代码
1 parent 5a51d81 commit bafb801

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

_doc/img/3.jpg

-9.41 KB
Loading

_doc/readme.pptx

27 Bytes
Binary file not shown.

readme.md

+7-11
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ clientIds:
4242
- user2
4343

4444
```
45-
(注1:作为快速演示,这里的type选择了最简单的post类型,此场景下最佳性能的协议为websocket,如需使用请参考:[websocket代理内网端口]
45+
(注1:作为快速演示,这里的type选择了最简单的post类型,此场景下最佳性能的协议为websocket,或是有独立端口的话可以配置hppt协议,ws、hppt版的说明奋力码字中。。)
46+
4647
(注2:实际应用中,为了确保安全,建议把clientId设置得更复杂一些)
4748

4849
执行如下命令运行服务端的hppt
@@ -90,7 +91,7 @@ post:
9091
# 人为设置的延迟(毫秒),一般填0即可,如果传文件等数据量大、延迟要求低的场景,可以设一个几百毫秒的延迟来降低post请求发送频率
9192
sendSleepTime: 0
9293
forwards:
93-
# 把192.168.0.2的22端口代理到本机的10022端口
94+
# 把192.168.0.2的22端口代理到本机的10022端口
9495
- localPort: 10022
9596
remoteHost: "192.168.0.2"
9697
remotePort: 22
@@ -140,7 +141,7 @@ rhppt:
140141
port: 20871
141142

142143
forwards:
143-
# 把192.168.0.2的22端口代理到本机的10022端口
144+
# 把192.168.0.2的22端口代理到本机的10022端口
144145
- localPort: 10022
145146
remoteHost: "192.168.0.2"
146147
remotePort: 22
@@ -203,13 +204,14 @@ cd hppt
203204

204205
首先clone本项目到本地,然后`mvn clean install`把本项目安装到maven。
205206

206-
然后新建一个java工程,引入maven依赖
207+
然后新建一个java工程,引入hppt-run以及kafka等maven依赖
207208
```xml
208209
<dependency>
209210
<groupId>org.wowtools.hppt</groupId>
210211
<artifactId>run</artifactId>
211212
<version>1.0-SNAPSHOT</version>
212213
</dependency>
214+
<!--继续添加其他依赖-->
213215
```
214216
然后就可以编写代码了:
215217

@@ -223,24 +225,20 @@ public class ServerDemo extends ServerSessionService<T> {
223225

224226
//初始化时需要做什么
225227
public void init(SsConfig ssConfig) throws Exception {
226-
227228
}
228229

229230
//怎样发送字节到客户端
230231
protected void sendBytesToClient(T ctx, byte[] bytes) {
231-
232232
}
233233

234234
//收到客户端的字节时,主动去调用receiveClientBytes(CTX ctx, byte[] bytes)
235235

236236
//当客户端断开时需要做什么
237237
protected void closeCtx(T ctx) throws Exception {
238-
239238
}
240239

241240
//当本服务端关闭后,在此释放掉连接池等资源
242241
protected void doClose() throws Exception {
243-
244242
}
245243
}
246244
```
@@ -256,12 +254,10 @@ public class ClientDemo extends ClientSessionService {
256254

257255
//怎样连接到服务端
258256
protected void connectToServer(ScConfig config, Cb cb) throws Exception {
259-
260257
}
261258

262259
//怎样发送字节到服务端
263260
protected void sendBytesToServer(byte[] bytes) {
264-
265261
}
266262

267263
//收到客户端的字节时,主动去调用receiveServerBytes(byte[] bytes)
@@ -275,7 +271,7 @@ public class ClientDemo extends ClientSessionService {
275271

276272
## 性能如何?
277273

278-
使用hppt或websocket等长连接协议的话,本项目只是做了个转发和加解密等操作,性能损耗在%5以内,以下是示例2中scp命令拷贝一个186m的文件,连接原始端口和代理端口的耗时对比:
274+
使用hppt或websocket等长连接协议的话,本项目只是做了个转发和加解密等操作,性能损耗在5%以内,以下是示例2中scp命令拷贝一个186m的文件,连接原始端口和代理端口的耗时对比:
279275

280276
```shell
281277
# 直连

0 commit comments

Comments
 (0)