Skip to content

Commit 6b9ec4a

Browse files
committed
Add simple protocol example based on Fast Binary Encoding
1 parent 744dce9 commit 6b9ec4a

18 files changed

Lines changed: 9033 additions & 12 deletions

File tree

NetCoreServer.sln

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UdsMulticastClient", "perfo
103103
EndProject
104104
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UdsMulticastServer", "performance\UdsMulticastServer\UdsMulticastServer.csproj", "{80C95510-AF12-4CF0-8852-B21241F6C1F3}"
105105
EndProject
106+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{C5B8C97B-97EC-40E9-8F64-252F8DF3D709}"
107+
EndProject
108+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "proto", "proto", "{7535CE12-3B22-4473-890A-980B72E5D27A}"
109+
EndProject
110+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "proto", "proto\proto.csproj", "{0A31A021-B53C-4B1B-A408-A46ABC97C93F}"
111+
EndProject
106112
Global
107113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
108114
Debug|Any CPU = Debug|Any CPU
@@ -495,6 +501,14 @@ Global
495501
{80C95510-AF12-4CF0-8852-B21241F6C1F3}.Release|Any CPU.Build.0 = Release|Any CPU
496502
{80C95510-AF12-4CF0-8852-B21241F6C1F3}.Release|x64.ActiveCfg = Release|Any CPU
497503
{80C95510-AF12-4CF0-8852-B21241F6C1F3}.Release|x64.Build.0 = Release|Any CPU
504+
{0A31A021-B53C-4B1B-A408-A46ABC97C93F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
505+
{0A31A021-B53C-4B1B-A408-A46ABC97C93F}.Debug|Any CPU.Build.0 = Debug|Any CPU
506+
{0A31A021-B53C-4B1B-A408-A46ABC97C93F}.Debug|x64.ActiveCfg = Debug|Any CPU
507+
{0A31A021-B53C-4B1B-A408-A46ABC97C93F}.Debug|x64.Build.0 = Debug|Any CPU
508+
{0A31A021-B53C-4B1B-A408-A46ABC97C93F}.Release|Any CPU.ActiveCfg = Release|Any CPU
509+
{0A31A021-B53C-4B1B-A408-A46ABC97C93F}.Release|Any CPU.Build.0 = Release|Any CPU
510+
{0A31A021-B53C-4B1B-A408-A46ABC97C93F}.Release|x64.ActiveCfg = Release|Any CPU
511+
{0A31A021-B53C-4B1B-A408-A46ABC97C93F}.Release|x64.Build.0 = Release|Any CPU
498512
EndGlobalSection
499513
GlobalSection(SolutionProperties) = preSolution
500514
HideSolutionNode = FALSE
@@ -506,6 +520,7 @@ Global
506520
{2535575F-D98F-4398-BB3D-F7FA0CC2F9DB} = {81ED94B5-0C65-432C-AEF5-67C3DFF7F2EE}
507521
{A1EA2EF7-663C-48E0-9AEB-E3AF7F139839} = {8965E5CD-E36E-4DC5-A36E-827AFFC642D1}
508522
{580A09F4-D24A-408B-A75C-A4AF2B15AE02} = {8965E5CD-E36E-4DC5-A36E-827AFFC642D1}
523+
{9C37C898-6C8C-49D6-B06F-0A9B26F3FF7F} = {C5B8C97B-97EC-40E9-8F64-252F8DF3D709}
509524
{08FAAF0A-5D41-45F7-A6D3-A0AB84E26B36} = {81ED94B5-0C65-432C-AEF5-67C3DFF7F2EE}
510525
{08200780-1BD6-4E3C-8059-D28E614A1375} = {81ED94B5-0C65-432C-AEF5-67C3DFF7F2EE}
511526
{A3AA15B3-FD4D-4CFA-989A-B9EE6F18E687} = {8965E5CD-E36E-4DC5-A36E-827AFFC642D1}
@@ -546,6 +561,7 @@ Global
546561
{13567A7F-923D-42C0-9451-A1821E087A69} = {8965E5CD-E36E-4DC5-A36E-827AFFC642D1}
547562
{B1D5EA8F-9A1E-4AD6-9C40-A6A5EFDDE044} = {8965E5CD-E36E-4DC5-A36E-827AFFC642D1}
548563
{80C95510-AF12-4CF0-8852-B21241F6C1F3} = {8965E5CD-E36E-4DC5-A36E-827AFFC642D1}
564+
{0A31A021-B53C-4B1B-A408-A46ABC97C93F} = {7535CE12-3B22-4473-890A-980B72E5D27A}
549565
EndGlobalSection
550566
GlobalSection(ExtensibilityGlobals) = postSolution
551567
SolutionGuid = {64415837-63D9-474E-A25C-EE91C9CA90C5}

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Has integration with message protocol based on [Fast Binary Encoding](https://gi
3232
* [Example: UDP multicast client](#example-udp-multicast-client)
3333
* [Example: Unix Domain Socket chat server](#example-unix-domain-socket-chat-server)
3434
* [Example: Unix Domain Socket chat client](#example-unix-domain-socket-chat-client)
35+
* [Example: Simple protocol](#example-simple-protocol)
3536
* [Example: HTTP server](#example-http-server)
3637
* [Example: HTTP client](#example-http-client)
3738
* [Example: HTTPS server](#example-https-server)
@@ -1258,6 +1259,74 @@ namespace UdsChatClient
12581259
}
12591260
```
12601261

1262+
## Example: Simple protocol
1263+
Simple protocol is defined in [simple.fbe](https://github.com/chronoxor/NetCoreServer/blob/master/proto/simple.fbe) file:
1264+
1265+
```proto
1266+
/*
1267+
Simple Fast Binary Encoding protocol for CppServer
1268+
https://github.com/chronoxor/FastBinaryEncoding
1269+
1270+
Generate protocol command: fbec --csharp --proto --input=simple.fbe --output=.
1271+
*/
1272+
1273+
// Domain declaration
1274+
domain com.chronoxor
1275+
1276+
// Package declaration
1277+
package simple
1278+
1279+
// Protocol version
1280+
version 1.0
1281+
1282+
// Simple request message
1283+
[request]
1284+
[response(SimpleResponse)]
1285+
[reject(SimpleReject)]
1286+
message SimpleRequest
1287+
{
1288+
// Request Id
1289+
uuid [id] = uuid1;
1290+
// Request message
1291+
string Message;
1292+
}
1293+
1294+
// Simple response
1295+
message SimpleResponse
1296+
{
1297+
// Response Id
1298+
uuid [id] = uuid1;
1299+
// Calculated message length
1300+
uint32 Length;
1301+
// Calculated message hash
1302+
uint32 Hash;
1303+
}
1304+
1305+
// Simple reject
1306+
message SimpleReject
1307+
{
1308+
// Reject Id
1309+
uuid [id] = uuid1;
1310+
// Error message
1311+
string Error;
1312+
}
1313+
1314+
// Simple notification
1315+
message SimpleNotify
1316+
{
1317+
// Server notification
1318+
string Notification;
1319+
}
1320+
1321+
// Disconnect request message
1322+
[request]
1323+
message DisconnectRequest
1324+
{
1325+
// Request Id
1326+
uuid [id] = uuid1;
1327+
}
1328+
```
1329+
12611330
## Example: HTTP server
12621331
Here comes the example of the HTTP cache server. It allows to manipulate
12631332
cache data with HTTP methods (GET, POST, PUT and DELETE).

examples/UdsChatClient/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Net.Sockets;
44
using System.Text;
55
using System.Threading;
6-
using UdsClient = NetCoreServer.UdsClient;
6+
using NetCoreServer;
77

88
namespace UdsChatClient
99
{

performance/UdsEchoServer/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.IO;
3-
using System.Net;
43
using System.Net.Sockets;
54
using NetCoreServer;
65
using NDesk.Options;

performance/UdsMulticastServer/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.IO;
3-
using System.Net;
43
using System.Net.Sockets;
54
using System.Threading;
65
using System.Threading.Tasks;

performance/WsEchoClient/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Net.Sockets;
4-
using System.Text;
54
using System.Threading;
65
using NDesk.Options;
76
using NetCoreServer;

performance/WsMulticastClient/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Net.Sockets;
6-
using System.Text;
76
using System.Threading;
87

98
namespace WsMulticastClient

performance/WssEchoClient/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Net.Sockets;
66
using System.Security.Authentication;
77
using System.Security.Cryptography.X509Certificates;
8-
using System.Text;
98
using System.Threading;
109

1110
namespace WssEchoClient

performance/WssMulticastClient/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Net.Sockets;
66
using System.Security.Authentication;
77
using System.Security.Cryptography.X509Certificates;
8-
using System.Text;
98
using System.Threading;
109

1110
namespace WssMulticastClient

0 commit comments

Comments
 (0)