Skip to content

Commit a3139a9

Browse files
Update Library.cs
1 parent 0e26377 commit a3139a9

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

class/Library.cs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,86 @@ public string[] GetList()
119119
return ValueList;
120120
}
121121
}
122+
123+
public class WebSocketsBroadcas
124+
{
125+
public string Message { get; set; }
126+
public string RoleName { get; set; }
127+
public string WebSocketId { get; set; }
128+
public string ClientId { get; set; }
129+
130+
public WebSocketsBroadcas()
131+
{
132+
133+
}
134+
135+
public WebSocketsBroadcas(string Message, string RoleName, string WebSocketId, string ClientId)
136+
{
137+
this.Message = Message;
138+
this.RoleName = RoleName;
139+
this.WebSocketId = WebSocketId;
140+
this.ClientId = ClientId;
141+
}
142+
}
143+
144+
public class WebSocketsBroadcastCollection
145+
{
146+
private List<WebSocketsBroadcas> WebSocketsBroadcasList = new List<WebSocketsBroadcas>();
147+
148+
public void Add(string Message, string RoleName, string WebSocketId, string ClientId)
149+
{
150+
WebSocketsBroadcasList.Add(new WebSocketsBroadcas(Message, RoleName, WebSocketId, ClientId));
151+
}
152+
153+
public void DeleteByIndex(int Index)
154+
{
155+
int TmpIndex = (Index >= 0) ? Index : WebSocketsBroadcasList.Count + Index;
156+
WebSocketsBroadcasList.RemoveAt(TmpIndex);
157+
}
158+
159+
public void Empty()
160+
{
161+
WebSocketsBroadcasList = new List<WebSocketsBroadcas>();
162+
}
163+
164+
public void AddList(List<WebSocketsBroadcas> WebSocketsBroadcasList)
165+
{
166+
foreach (WebSocketsBroadcas wsb in WebSocketsBroadcasList)
167+
this.WebSocketsBroadcasList.Add(wsb);
168+
}
169+
170+
public string GetMessageByIndex(int Index)
171+
{
172+
int TmpIndex = (Index >= 0) ? Index : WebSocketsBroadcasList.Count + Index;
173+
return WebSocketsBroadcasList[TmpIndex].Message;
174+
}
175+
176+
public string GetRoleNameByIndex(int Index)
177+
{
178+
int TmpIndex = (Index >= 0) ? Index : WebSocketsBroadcasList.Count + Index;
179+
return WebSocketsBroadcasList[TmpIndex].RoleName;
180+
}
181+
182+
public string GetWebSocketIdByIndex(int Index)
183+
{
184+
int TmpIndex = (Index >= 0) ? Index : WebSocketsBroadcasList.Count + Index;
185+
return WebSocketsBroadcasList[TmpIndex].WebSocketId;
186+
}
187+
188+
public string GetClientIdByIndex(int Index)
189+
{
190+
int TmpIndex = (Index >= 0) ? Index : WebSocketsBroadcasList.Count + Index;
191+
return WebSocketsBroadcasList[TmpIndex].ClientId;
192+
}
193+
194+
public int Count()
195+
{
196+
return WebSocketsBroadcasList.Count;
197+
}
198+
199+
public List<WebSocketsBroadcas> GetList()
200+
{
201+
return WebSocketsBroadcasList;
202+
}
203+
}
122204
}

0 commit comments

Comments
 (0)