Skip to content
This repository was archived by the owner on Mar 5, 2026. It is now read-only.

Commit 1ee1c7b

Browse files
authored
Update README.md
Better looks from github
1 parent e39d089 commit 1ee1c7b

1 file changed

Lines changed: 50 additions & 40 deletions

File tree

README.md

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ Echo server (RFC 862)
99
Time server (RFC 868)
1010

1111
# 2. SOLUTION STRUCTURE
12-
/
13-
----/Console
14-
----/GUI
15-
----TinyTcpServer/
12+
13+
/
14+
----/Console
15+
----/GUI
16+
----TinyTcpServer/
17+
1618
----MossbauerLab.TinyTcpServer.Core
1719
----MossbauerLab.TinyTcpServer.Core.FunctionalTests
1820
----MossbauerLab.SimpleExtensions
@@ -26,53 +28,60 @@ Time server (RFC 868)
2628
https://www.nuget.org/packages/MossbauerLab.TinyTcpServer.Core/
2729

2830
# 4. FULL EXAMPLE OF HOW TO USE
31+
`
2932

30-
private const String LocalIpAddress = "127.0.0.1";
31-
private const UInt16 ServerPort = 8044;
32-
private const String Script = @"..\..\TestScripts\SimpleScript.cs";
33+
private const String LocalIpAddress = "127.0.0.1";
34+
private const UInt16 ServerPort = 8044;
35+
private const String Script = @"..\..\TestScripts\SimpleScript.cs";
3336
34-
private ITcpServer _server;
37+
private ITcpServer _server;
3538

36-
public void Init()
37-
{
38-
_server = new FlexibleTcpServer(Script, LocalIpAddress, ServerPort);
39-
}
39+
public void Init()
40+
{
41+
_server = new FlexibleTcpServer(Script, LocalIpAddress, ServerPort);
42+
}
43+
`
4044

4145
That is all ! all logics is inside you script
4246
There are requirement to presence of initial class and entry method
4347

44-
public class ServerScript
45-
{
46-
public void Init(ref ITcpServer server)
48+
`
49+
50+
public class ServerScript
4751
{
48-
if(server == null)
49-
throw new NullReferenceException("server");
50-
_server = server;
51-
_connectHandlerId = Guid.NewGuid();
52-
_dataHandlerId = Guid.NewGuid();
53-
//Console.WriteLine("Init....");
54-
_server.AddConnectionHandler(_connectHandlerId, OnClientConnection);
55-
_server.AddHandler(new TcpClientHandlerInfo(_dataHandlerId), OnClientExchange);
52+
public void Init(ref ITcpServer server)
53+
{
54+
if(server == null)
55+
throw new NullReferenceException("server");
56+
_server = server;
57+
_connectHandlerId = Guid.NewGuid();
58+
_dataHandlerId = Guid.NewGuid();
59+
//Console.WriteLine("Init....");
60+
_server.AddConnectionHandler(_connectHandlerId, OnClientConnection);
61+
_server.AddHandler(new TcpClientHandlerInfo(_dataHandlerId), OnClientExchange);
62+
}
63+
// ...
5664
}
57-
// ...
58-
}
5965

60-
// in this method we set up handlers
61-
Handlers on Connect and Exchange looks like:
62-
public Byte[] OnClientExchange(Byte[] receivedData, TcpClientHandlerInfo info)
63-
{
64-
lock (receivedData)
66+
// in this method we set up handlers
67+
// Handlers on Connect and Exchange looks like:
68+
public Byte[] OnClientExchange(Byte[] receivedData, TcpClientHandlerInfo info)
6569
{
66-
Byte[] outputData = new Byte[receivedData.Length];
67-
Array.Copy(receivedData, outputData, receivedData.Length);
68-
return outputData;
70+
lock (receivedData)
71+
{
72+
Byte[] outputData = new Byte[receivedData.Length];
73+
Array.Copy(receivedData, outputData, receivedData.Length);
74+
return outputData;
75+
}
6976
}
70-
}
71-
72-
public void OnClientConnection(TcpClientContext context, Boolean connect) // connect true if client connected and false if disconnected
73-
{
77+
78+
// connect true if client connected and false if disconnected
79+
public void OnClientConnection(TcpClientContext context, Boolean connect)
80+
81+
{
7482
75-
}
83+
}
84+
`
7685

7786
Full example present (in file SimpleScript inside MossbauerLab.TinyTcpServer.FunctionalTests
7887

@@ -81,7 +90,8 @@ There are requirement to presence of initial class and entry method
8190
In Console project there is a class that could parse config ftle (key=value) with that settings class is TcpServerConfigBuilder
8291

8392
it handles file, examples of settings:
84-
# This is a example of settings file all settings are represented as pair key=value, lines started from # are commentary (ignores)
93+
`
94+
8595
# number of clients processing the 'same time'
8696
ParallelTask = 256
8797
# buffer on receive for every client (in bytes)
@@ -102,7 +112,7 @@ There are requirement to presence of initial class and entry method
102112
ServerCloseTimeout = 2000
103113
# timeout in milliseconds to complete write operation
104114
WriteTimeout = 1000
105-
115+
`
106116
# 6 CONTRIBUTORS
107117
EvilLord666 aka Ushakov Michael
108118
KatanaZZZ aka Anonymous

0 commit comments

Comments
 (0)