-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStateObject.cs
66 lines (64 loc) · 1.87 KB
/
StateObject.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System.Net.Sockets;
namespace socket_server.Object
{
public class StateObject
{
public Socket workSocket = null;
public const int BufferSize = 2048;
public byte[] buffer = new byte[BufferSize];
//public StringBuilder sb = new StringBuilder();
public bool thru = false;
public string[,] detail = new string[10, 2]
{
{ "Addr", "" },
{ "Type", "" },
{ "PlaceID", "" },
{ "DeviceID", "" },
{ "", "" },
{ "", "" },
{ "", "" },
{ "", "" },
{ "", "" },
{ "", "" }
};
}
public class Detail
{
public enum TYPE
{
Addr, Type, PlaceID, DeviceID
}
public static void set(StateObject state, TYPE type, string content) {
switch (type) {
case TYPE.Addr:
state.detail[0, 1] = content;
break;
case TYPE.Type:
state.detail[1, 1] = content;
break;
case TYPE.PlaceID:
state.detail[2, 1] = content;
break;
case TYPE.DeviceID:
state.detail[3, 1] = content;
break;
default:
return;
}
}
public static string get(StateObject state, TYPE type) {
switch (type) {
case TYPE.Addr:
return state.detail[0, 1];
case TYPE.Type:
return state.detail[1, 1];
case TYPE.PlaceID:
return state.detail[2, 1];
case TYPE.DeviceID:
return state.detail[3, 1];
default:
return null;
}
}
}
}