30 lines
696 B
C#
30 lines
696 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:9897"); //创建webscoket服务端实例
|
|
server.Start(onAccept);
|
|
clients = new List<Client>();
|
|
}
|
|
|
|
private void onAccept(IWebSocketConnection webSocket)
|
|
{
|
|
Client client = new Client(webSocket);
|
|
Console.WriteLine("新的连接对象进入{0}", client.ToString());
|
|
clients.Add(client);
|
|
}
|
|
}
|
|
} |