dfbattle/Service.cs
2022-11-23 19:08:31 +08:00

29 lines
615 B
C#

using Fleck;
using System;
namespace BattleServer
{
/// <summary>
/// 服务端
/// </summary>
class Service
{
private WebSocketServer server;
private List<Client> clients;
public Service()
{
var server = new WebSocketServer("ws://127.0.0.1:9898"); //创建webscoket服务端实例
server.Start(onAccept);
clients = new List<Client>();
}
private void onAccept(IWebSocketConnection webSocket)
{
Client client = new Client(webSocket);
clients.Add(client);
}
}
}