Skip to content

Commit 855b712

Browse files
author
Hiram
committed
modify read me
1 parent f8975e0 commit 855b712

File tree

2 files changed

+49
-33
lines changed

2 files changed

+49
-33
lines changed

README.md

+25-16
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,26 @@ It is a lightweight socket solution, you can used it in Unity3d or C# project
99

1010
### How to use
1111
You can choose use dll or source code, add it to your project.
12-
- Dll: You can download HiSocket dll from here: [HiSocket_xx.zip](https://github.com/hiramtan/HiSocket/releases)
13-
- Source code: source code is in "HiSocket/visual" folder.
14-
 (ps. there also a "HiSocket.Test" unit test project contains some example in source code)
12+
- Dll: [HiSocket_xx.zip](https://github.com/hiramtan/HiSocket/releases)
13+
- Source code: [Source code](https://github.com/hiramtan/HiSocket/tree/master/visual)
1514

1615
Quick Start:
1716
```csharp
18-
private IPackage _package = new PackageExample();
19-
private TcpConnection _tcp;
17+
//tcp example
18+
private IPackage package = new PackageExample();
19+
private TcpConnection tcp;
2020
void Init()
2121
{
22-
_tcp = new TcpConnection(_package);
23-
_tcp.OnConnected += OnConnected;
24-
_tcp.OnReceive += OnReceive;
22+
tcp = new TcpConnection(package);
23+
tcp.OnConnected += OnConnected;
24+
tcp.OnReceive += OnReceive;
2525
//...
2626
//...
2727
}
2828
void OnConnected()
2929
{
3030
//connect success
31-
_tcp.Send(new byte[10]);//send message
32-
_tcp.DisConnect();//disconnect
31+
tcp.Send(new byte[10]);//send message
3332
}
3433

3534
void OnReceive(byte[] bytes)
@@ -38,6 +37,10 @@ You can choose use dll or source code, add it to your project.
3837
}
3938
```
4039

40+
More example:
41+
- C# project example:[Example](https://github.com/hiramtan/HiSocket/tree/master/visual/HiSocket.Example)
42+
- Unity project example:[Example](https://github.com/hiramtan/HiSocket/tree/master/unity)
43+
4144
-----
4245

4346
### General
@@ -76,6 +79,17 @@ This project contains:
7679
- Ping: there is a ping plugin you can used, but if you are used in unity3d because of the bug of mono, it will throw an error on .net2.0(.net 4.6 will be fine, also you can use unity's api to get ping time)
7780

7881

82+
### Advanced
83+
- If you are clear about socket, you also can use TcpSocket(UdpSocket) to achieve your logic, anyway the recommend is TcpConnection(UdpConnection).
84+
- You can use API get socket and do extra logic, for example modify time out time
85+
- You can use API get send and receive buffer, for example when disconnect should send all send buffer's data to server? or when reconnect how to process send buffer's data
86+
- OnSocketReceive and OnReceive are diffrent, for example OnSocketReceive size is 100 byte, if user do nothing when uppack OnReceive size is 100. but when user do some zip/unzip(encription.etc) OnReceive size is not 100 anymore.
87+
- You can add many different plugins based on TcpConnection(UdpConnection) to achieve different functions.
88+
- There are a message register base class help user to quick register id and callback(based on reflection)
89+
- Byte block buffer reuse block when some block is free.
90+
- .etc
91+
92+
7993
### Instructions
8094
- Tcp
8195
[Transmission Control Protocol](https://en.wikipedia.org/wiki/Transmission_Control_Protocol)
@@ -123,12 +137,7 @@ If use Udp connection shold define send and receive's buffer size.
123137
- Bytes message
124138
- Encription
125139

126-
### Advanced
127-
- If you are clear about socket, you also can use TcpSocket(UdpSocket) to achieve your logic, anyway the recommend is TcpConnection(UdpConnection).
128-
- You can add many different plugins based on TcpConnection(UdpConnection) to achieve different functions.
129-
- There are a message register base class help user to quick register id and callback(based on reflection)
130-
- Byte block buffer use linked list and reuse block when some block is free.
131-
- .etc
140+
132141
---------
133142

134143
### Example

README_zh.md

+24-17
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,37 @@
88

99
### 如何使用
1010
可以选择使用dll或者使用源码,把它添加到自己的工程中即可使用.
11-
- Dll: 可以从此下载 HiSocket dll: [HiSocket_xx.zip](https://github.com/hiramtan/HiSocket/releases)
12-
- 源码: 源码在此文件夹中"HiSocket/visual"
13-
(ps. 源码的单元测试项目HiSocket.Test包含一些示例代码)
11+
- Dll: [HiSocket_xx.zip](https://github.com/hiramtan/HiSocket/releases)
12+
- 源码: [源码](https://github.com/hiramtan/HiSocket/tree/master/visual)
1413

1514

1615
快速开始:
1716
```csharp
18-
private IPackage _package = new PackageExample();
19-
private TcpConnection _tcp;
17+
//tcp example
18+
private IPackage package = new PackageExample();
19+
private TcpConnection tcp;
2020
void Init()
2121
{
22-
_tcp = new TcpConnection(_package);
23-
_tcp.OnConnected += OnConnected;
24-
_tcp.OnReceive += OnReceive;
22+
tcp = new TcpConnection(package);
23+
tcp.OnConnected += OnConnected;
24+
tcp.OnReceive += OnReceive;
2525
//...
2626
//...
2727
}
2828
void OnConnected()
2929
{
3030
//connect success
31-
_tcp.Send(new byte[10]);//send message
32-
_tcp.DisConnect();//disconnect
31+
tcp.Send(new byte[10]);//send message
3332
}
3433

3534
void OnReceive(byte[] bytes)
3635
{
3736
//get message from server
3837
}
3938
```
39+
更多示例:
40+
- C#项目示例:[示例](https://github.com/hiramtan/HiSocket/tree/master/visual/HiSocket.Example)
41+
- Unity项目示例:[示例](https://github.com/hiramtan/HiSocket/tree/master/unity)
4042

4143
-----
4244

@@ -74,6 +76,17 @@
7476
- 如果使用Udp协议需要声明缓冲区大小.
7577
- Ping: 源码包含一个Ping插件可以使用,但是如果用在unity3d工程中会报错(因为mono的问题,在.net2.0会报错.net4.6可以正常使用)
7678

79+
### 高级功能
80+
- 如果对Socket很熟悉,也可以使用TcpSocket(UdpSocket)来实现功能,但是还是推荐使用TcpConnection(UdpConnection)的方式.
81+
- 通过接口可以访问底层Socket对象扩展逻辑,比如修改超时时间.
82+
- 通过接口可以获得发送接收缓冲区,比如断开连接时是否要将发送缓冲区数据全部发出?重连后怎样处理发送缓冲区的数据.
83+
- OnSocketReceive和OnReceive是不同的,比如当OnSocketReceive接受大小是100字节,当用户解包时不做操作,OnReceive大小是100字节,当用户解包时做解压缩(解密等)操作后,OnReceive大小不再是100.
84+
- 可以向TcpConnection(UdpConnection)添加不同的插件完成所需的功能,
85+
- 注册基类可以方便快速注册消息(基于反射)
86+
- Byte block buffer 采用有序链表实现,当有区块空闲时会重用区块.
87+
- .etc
88+
---------
89+
7790

7891
### 介绍
7992
- Tcp
@@ -122,13 +135,7 @@ Udp协议提供不可靠的报文消息,用户无法知道当前连接状态,但
122135
- 字节消息
123136
- 加密
124137

125-
### 高级功能
126-
- 如果对Socket很熟悉,也可以使用TcpSocket(UdpSocket)来实现功能,但是还是推荐使用TcpConnection(UdpConnection)的方式.
127-
- 可以向TcpConnection(UdpConnection)添加不同的插件完成所需的功能,
128-
- 注册基类可以方便快速注册消息(基于反射)
129-
- Byte block buffer 采用有序链表实现,当有区块空闲时会重用区块.
130-
- .etc
131-
---------
138+
132139

133140
### Example
134141
**HiSocketExample****HiSocket.unitypackage**有很多示例, 其中有一些如下:

0 commit comments

Comments
 (0)