上传战斗优化
This commit is contained in:
parent
0648f41645
commit
00ee9c35ab
@ -13,6 +13,11 @@ namespace BattleServer
|
||||
{
|
||||
socket = _socket;
|
||||
socket.OnBinary = doBinary;
|
||||
socket.OnClose = close;
|
||||
}
|
||||
|
||||
private void close (){
|
||||
Service.Instance.Shutdown(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -10,6 +10,7 @@ namespace BattleServer
|
||||
/// </summary>
|
||||
class Service
|
||||
{
|
||||
public static Service Instance;
|
||||
private WebSocketServer server;
|
||||
private List<Client> clients;
|
||||
|
||||
@ -18,6 +19,7 @@ namespace BattleServer
|
||||
var server = new WebSocketServer("ws://127.0.0.1:9897"); //创建webscoket服务端实例
|
||||
server.Start(onAccept);
|
||||
clients = new List<Client>();
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
private void onAccept(IWebSocketConnection webSocket)
|
||||
@ -26,5 +28,10 @@ namespace BattleServer
|
||||
Console.WriteLine("新的连接对象进入{0}", client.ToString());
|
||||
clients.Add(client);
|
||||
}
|
||||
|
||||
public void Shutdown(Client client){
|
||||
Console.WriteLine("连接对象断开{0}", client.ToString());
|
||||
this.clients.Remove(client);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user