|
|
|
|
@ -12,11 +12,11 @@ namespace OMS.NET
|
|
|
|
|
private IPEndPoint iPEndPoint = new(IPAddress.Any, 0);
|
|
|
|
|
protected override async void OnMessage(MessageEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
GlobalArea.Log.Debug(this.ID + " " + this.Context.UserEndPoint.ToString() + ":" + e.Data);
|
|
|
|
|
GlobalArea.Log.Debug(ID + " " + Context.UserEndPoint.ToString() + ":" + e.Data);
|
|
|
|
|
Instruct? instruct = Instruct.JsonStringParse(e.Data);
|
|
|
|
|
if (instruct != null)
|
|
|
|
|
{
|
|
|
|
|
await instruct.HandlerAndMeasure(this.ID);//传递ws连接的id,为某些需要判断ws连接状态的处理逻辑准备
|
|
|
|
|
await instruct.HandlerAndMeasure(ID);//传递ws连接的id,为某些需要判断ws连接状态的处理逻辑准备
|
|
|
|
|
if (instruct.ResponseOrBroadcastInstructs.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
instruct.ResponseOrBroadcastInstructs.ForEach(res =>
|
|
|
|
|
@ -30,7 +30,7 @@ namespace OMS.NET
|
|
|
|
|
if (res.IsBroadcast)
|
|
|
|
|
{
|
|
|
|
|
string str = res.ToJsonString();
|
|
|
|
|
foreach (IWebSocketSession session in this.Sessions.Sessions)
|
|
|
|
|
foreach (IWebSocketSession session in Sessions.Sessions)
|
|
|
|
|
{
|
|
|
|
|
//看起来只有登录后的连接才能收到广播,这里添加下过滤
|
|
|
|
|
if (GlobalArea.LoginCheckByID(session.ID))
|
|
|
|
|
@ -47,23 +47,23 @@ namespace OMS.NET
|
|
|
|
|
|
|
|
|
|
protected override void OnOpen()
|
|
|
|
|
{
|
|
|
|
|
this.iPEndPoint = this.Context.UserEndPoint;
|
|
|
|
|
GlobalArea.AddUserConnect(this.ID, this.iPEndPoint);
|
|
|
|
|
Console.WriteLine(this.ID + " " + this.iPEndPoint.ToString() + " Conection Open");
|
|
|
|
|
iPEndPoint = Context.UserEndPoint;
|
|
|
|
|
GlobalArea.AddUserConnect(ID, iPEndPoint);
|
|
|
|
|
Console.WriteLine(ID + " " + iPEndPoint.ToString() + " Conection Open");
|
|
|
|
|
Console.WriteLine($"当前连接客户端数量: {GlobalArea.ConnectClientsCount}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnClose(CloseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
GlobalArea.RemoveUserConnectByID(this.ID);
|
|
|
|
|
Console.WriteLine(this.ID + " " + this.iPEndPoint.ToString() + " Conection Close" + e.Reason);
|
|
|
|
|
GlobalArea.RemoveUserConnectByID(ID);
|
|
|
|
|
Console.WriteLine(ID + " " + iPEndPoint.ToString() + " Conection Close" + e.Reason);
|
|
|
|
|
Console.WriteLine($"当前连接客户端数量: {GlobalArea.ConnectClientsCount}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnError(ErrorEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
GlobalArea.RemoveUserConnectByID(this.ID);
|
|
|
|
|
Console.WriteLine(this.ID + " " + this.iPEndPoint.ToString() + " Conection Error Close" + e.Message);
|
|
|
|
|
GlobalArea.RemoveUserConnectByID(ID);
|
|
|
|
|
Console.WriteLine(ID + " " + iPEndPoint.ToString() + " Conection Error Close" + e.Message);
|
|
|
|
|
Console.WriteLine($"当前连接客户端数量: {GlobalArea.ConnectClientsCount}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|