Skip to content

Commit 7201613

Browse files
committed
Add Unity3D readme, and reformat cs files
1 parent 2243ee5 commit 7201613

14 files changed

+4153
-3937
lines changed

Unity3D/ConcurrentDictionary.cs

+1,818-1,662
Large diffs are not rendered by default.

Unity3D/PocoManager.cs

+302-297
Large diffs are not rendered by default.

Unity3D/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Unity3D Integration Guide
2+
3+
PocoSDK supports Unity3D version 4 & 5 and above, ngui & ugui & fairygui, C# only for now.
4+
5+
1. Clone source code from [poco-sdk](https://github.com/AirtestProject/Poco-SDK) repo.
6+
7+
2. Copy the `Unity3D` folder to your unity project script folder.
8+
9+
3.
10+
- If you are using ngui, just delete the sub folder `Unity3D/ugui` and `Unity3D/fairygui`.
11+
- If you are using ugui, just delete the sub folder `Unity3D/ngui` and `Unity3D/fairygui`.
12+
- If you are using fairygui, please refer [fairygui guide](https://github.com/AirtestProject/Poco-SDK/tree/master/Unity3D/fairygui)
13+
14+
4. Add `Unity3D/PocoManager.cs` as script component on any GameObject, generally on main camera.

Unity3D/TcpClientConnectedEventArgs.cs

+20-20
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33

44
namespace TcpServer
55
{
6-
/// <summary>
7-
/// 与客户端的连接已建立事件参数
8-
/// </summary>
9-
public class TcpClientConnectedEventArgs : EventArgs
10-
{
11-
/// <summary>
12-
/// 与客户端的连接已建立事件参数
13-
/// </summary>
14-
/// <param name="tcpClient">客户端</param>
15-
public TcpClientConnectedEventArgs (TcpClient tcpClient)
16-
{
17-
if (tcpClient == null)
18-
throw new ArgumentNullException ("tcpClient");
6+
/// <summary>
7+
/// 与客户端的连接已建立事件参数
8+
/// </summary>
9+
public class TcpClientConnectedEventArgs : EventArgs
10+
{
11+
/// <summary>
12+
/// 与客户端的连接已建立事件参数
13+
/// </summary>
14+
/// <param name="tcpClient">客户端</param>
15+
public TcpClientConnectedEventArgs(TcpClient tcpClient)
16+
{
17+
if (tcpClient == null)
18+
throw new ArgumentNullException("tcpClient");
1919

20-
this.TcpClient = tcpClient;
21-
}
20+
this.TcpClient = tcpClient;
21+
}
2222

23-
/// <summary>
24-
/// 客户端
25-
/// </summary>
26-
public TcpClient TcpClient { get; private set; }
27-
}
23+
/// <summary>
24+
/// 客户端
25+
/// </summary>
26+
public TcpClient TcpClient { get; private set; }
27+
}
2828
}

Unity3D/TcpClientDisconnectedEventArgs.cs

+20-20
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33

44
namespace TcpServer
55
{
6-
/// <summary>
7-
/// 与客户端的连接已断开事件参数
8-
/// </summary>
9-
public class TcpClientDisconnectedEventArgs : EventArgs
10-
{
11-
/// <summary>
12-
/// 与客户端的连接已断开事件参数
13-
/// </summary>
14-
/// <param name="tcpClient">客户端状态</param>
15-
public TcpClientDisconnectedEventArgs (TcpClient tcpClient)
16-
{
17-
if (tcpClient == null)
18-
throw new ArgumentNullException ("tcpClient");
6+
/// <summary>
7+
/// 与客户端的连接已断开事件参数
8+
/// </summary>
9+
public class TcpClientDisconnectedEventArgs : EventArgs
10+
{
11+
/// <summary>
12+
/// 与客户端的连接已断开事件参数
13+
/// </summary>
14+
/// <param name="tcpClient">客户端状态</param>
15+
public TcpClientDisconnectedEventArgs(TcpClient tcpClient)
16+
{
17+
if (tcpClient == null)
18+
throw new ArgumentNullException("tcpClient");
1919

20-
this.TcpClient = tcpClient;
21-
}
20+
this.TcpClient = tcpClient;
21+
}
2222

23-
/// <summary>
24-
/// 客户端
25-
/// </summary>
26-
public TcpClient TcpClient { get; private set; }
27-
}
23+
/// <summary>
24+
/// 客户端
25+
/// </summary>
26+
public TcpClient TcpClient { get; private set; }
27+
}
2828
}

Unity3D/TcpClientState.cs

+45-43
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,54 @@
33

44
namespace TcpServer
55
{
6-
/// <summary>
7-
/// Internal class to join the TCP client and buffer together
8-
/// for easy management in the server
9-
/// </summary>
10-
public class TcpClientState
11-
{
12-
/// <summary>
13-
/// Constructor for a new Client
14-
/// </summary>
15-
/// <param name="tcpClient">The TCP client</param>
16-
/// <param name="buffer">The byte array buffer</param>
17-
/// <param name="prot">The protocol filter</param>
18-
public TcpClientState (TcpClient tcpClient, byte[] buffer, ProtoFilter prot)
19-
{
20-
if (tcpClient == null)
21-
throw new ArgumentNullException ("tcpClient");
22-
if (buffer == null)
23-
throw new ArgumentNullException ("buffer");
24-
if (prot == null)
25-
throw new ArgumentNullException ("prot");
6+
/// <summary>
7+
/// Internal class to join the TCP client and buffer together
8+
/// for easy management in the server
9+
/// </summary>
10+
public class TcpClientState
11+
{
12+
/// <summary>
13+
/// Constructor for a new Client
14+
/// </summary>
15+
/// <param name="tcpClient">The TCP client</param>
16+
/// <param name="buffer">The byte array buffer</param>
17+
/// <param name="prot">The protocol filter</param>
18+
public TcpClientState(TcpClient tcpClient, byte[] buffer, ProtoFilter prot)
19+
{
20+
if (tcpClient == null)
21+
throw new ArgumentNullException("tcpClient");
22+
if (buffer == null)
23+
throw new ArgumentNullException("buffer");
24+
if (prot == null)
25+
throw new ArgumentNullException("prot");
2626

27-
this.TcpClient = tcpClient;
28-
this.Buffer = buffer;
29-
this.Prot = prot;
30-
// this.NetworkStream = tcpClient.GetStream ();
31-
}
27+
this.TcpClient = tcpClient;
28+
this.Buffer = buffer;
29+
this.Prot = prot;
30+
// this.NetworkStream = tcpClient.GetStream ();
31+
}
3232

33-
/// <summary>
34-
/// Gets the TCP Client
35-
/// </summary>
36-
public TcpClient TcpClient { get; private set; }
33+
/// <summary>
34+
/// Gets the TCP Client
35+
/// </summary>
36+
public TcpClient TcpClient { get; private set; }
3737

38-
/// <summary>
39-
/// Gets the Buffer.
40-
/// </summary>
41-
public byte[] Buffer { get; private set; }
38+
/// <summary>
39+
/// Gets the Buffer.
40+
/// </summary>
41+
public byte[] Buffer { get; private set; }
4242

43-
public ProtoFilter Prot { get; private set; }
43+
public ProtoFilter Prot { get; private set; }
4444

45-
/// <summary>
46-
/// Gets the network stream
47-
/// </summary>
48-
public NetworkStream NetworkStream {
49-
get {
50-
return TcpClient.GetStream ();
51-
}
52-
}
53-
}
45+
/// <summary>
46+
/// Gets the network stream
47+
/// </summary>
48+
public NetworkStream NetworkStream
49+
{
50+
get
51+
{
52+
return TcpClient.GetStream();
53+
}
54+
}
55+
}
5456
}

Unity3D/TcpDatagramReceivedEventArgs.cs

+30-30
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@
33

44
namespace TcpServer
55
{
6-
/// <summary>
7-
/// 接收到数据报文事件参数
8-
/// </summary>
9-
/// <typeparam name="T">报文类型</typeparam>
10-
public class TcpDatagramReceivedEventArgs<T> : EventArgs
11-
{
12-
/// <summary>
13-
/// 接收到数据报文事件参数
14-
/// </summary>
15-
/// <param name="tcpClientState">客户端状态</param>
16-
/// <param name="datagram">报文</param>
17-
public TcpDatagramReceivedEventArgs (TcpClientState tcpClientState, T datagram)
18-
{
19-
this.Client = tcpClientState;
20-
this.TcpClient = tcpClientState.TcpClient;
21-
this.Datagram = datagram;
22-
}
6+
/// <summary>
7+
/// 接收到数据报文事件参数
8+
/// </summary>
9+
/// <typeparam name="T">报文类型</typeparam>
10+
public class TcpDatagramReceivedEventArgs<T> : EventArgs
11+
{
12+
/// <summary>
13+
/// 接收到数据报文事件参数
14+
/// </summary>
15+
/// <param name="tcpClientState">客户端状态</param>
16+
/// <param name="datagram">报文</param>
17+
public TcpDatagramReceivedEventArgs(TcpClientState tcpClientState, T datagram)
18+
{
19+
this.Client = tcpClientState;
20+
this.TcpClient = tcpClientState.TcpClient;
21+
this.Datagram = datagram;
22+
}
2323

24-
/// <summary>
25-
/// 客户端状态
26-
/// </summary>
27-
public TcpClientState Client { get; private set; }
24+
/// <summary>
25+
/// 客户端状态
26+
/// </summary>
27+
public TcpClientState Client { get; private set; }
2828

29-
/// <summary>
30-
/// 客户端
31-
/// </summary>
32-
public TcpClient TcpClient { get; private set; }
29+
/// <summary>
30+
/// 客户端
31+
/// </summary>
32+
public TcpClient TcpClient { get; private set; }
3333

34-
/// <summary>
35-
/// 报文
36-
/// </summary>
37-
public T Datagram { get; private set; }
38-
}
34+
/// <summary>
35+
/// 报文
36+
/// </summary>
37+
public T Datagram { get; private set; }
38+
}
3939
}

0 commit comments

Comments
 (0)