File tree Expand file tree Collapse file tree 1 file changed +38
-2
lines changed Expand file tree Collapse file tree 1 file changed +38
-2
lines changed Original file line number Diff line number Diff line change 1
1
# SSCore
2
- dotnet core version of SuperSocket
3
-
2
+ dotnet core version of SuperSocket. Pick up socket communication logic from SuperSocket, and exclude command concept.
4
3
5
4
## usage
5
+
6
+ 1 . Create SocketServerBase object
7
+ 2 . Add handler for new client connection.
8
+ 3 . Start the socket server object.
9
+ 4 . Implement the handler of new client connection.
10
+ 5 . Add handler for receiving message.
11
+
12
+ ## Example
13
+
14
+
15
+ class Program
16
+ {
17
+ static void Main(string[] args)
18
+ {
19
+ SocketServerBase server = new SocketServerBase();
20
+ server.NewClientAccepted += Server_NewClientAccepted;
21
+ server.Start();
22
+
23
+ Console.WriteLine("enter any key to exit.");
24
+ Console.ReadKey();
25
+ }
26
+
27
+ private static void Server_NewClientAccepted(Socket client, ISocketSession session)
28
+ {
29
+ Console.WriteLine("----- new client ------------");
30
+ AsyncSocketSession ass = session as AsyncSocketSession;
31
+
32
+ ass.SetReceiveHandler(arg =>
33
+ {
34
+ Console.WriteLine("----- new receive ------------");
35
+ string received = System.Text.Encoding.UTF8.GetString(arg.Buffer, arg.Offset, arg.BytesTransferred);
36
+ Console.WriteLine(received);
37
+
38
+ ass.Send(received);
39
+ });
40
+ }
41
+ }
You can’t perform that action at this time.
0 commit comments