Repository navigation
Expand file tree
/
Copy pathConnectSessionManager.cs
More file actions
107 lines (84 loc) · 2.3 KB
/
Copy pathConnectSessionManager.cs
File metadata and controls
107 lines (84 loc) · 2.3 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System.Collections.Generic;
namespace ChatServer;
// 전체 연결된 세션의 상태 관리
public class ConnectSessionManager
{
List<ConnectSession> _sessionList = new List<ConnectSession>();
ConnectSession _disableSession = new ConnectSession();
public void CreateSession(int maxCount)
{
for (int i = 0; i < maxCount; ++i)
{
_sessionList.Add(new ConnectSession());
}
_disableSession.IsEnable = false;
}
public void SetClear(int index)
{
var session = GetSession(index);
session.Clear();
}
public void SetDisable(int index)
{
var session = GetSession(index);
session.SetDisable();
}
public int GetRoomNumber(int index)
{
var session = GetSession(index);
return session.GetRoomNumber();
}
public bool EnableReuqestLogin(int index)
{
var session = GetSession(index);
return session.IsStateNone();
}
public bool IsStateRoom(int index)
{
var session = GetSession(index);
return session.IsStateRoom();
}
public void SetPreLogin(int index)
{
var session = GetSession(index);
session.SetStatePreLogin();
}
public void SetLogin(int index, string userID)
{
var session = GetSession(index);
session.SetStateLogin(userID);
}
public void SetStateNone(int index)
{
var session = GetSession(index);
session.SetStateNone();
}
public void SetStateLogin(int index)
{
var session = GetSession(index);
session.SetStateLogin();
}
public bool EnableReuqestEnterRoom(int index)
{
var session = GetSession(index);
return session.IsStateLogin();
}
public bool SetPreRoomEnter(int index, int roomNumber)
{
var session = GetSession(index);
return session.SetPreRoomEnter(roomNumber);
}
public bool SetRoomEntered(int index, int roomNumber)
{
var session = GetSession(index);
return session.SetRoomEntered(roomNumber);
}
ConnectSession GetSession(int index)
{
if(0 <= index && index < ClientSession.s_MaxSessionCount)
{
return _sessionList[index];
}
return _disableSession;
}
}