You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.8 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* 版权所有 (c) 2025 WenJY 保留所有权利。
* CLR版本4.0.30319.42000
* 机器名称Mr.Wen's MacBook Pro
* 命名空间Sln.Iot.Business
* 唯一标识71034873-2FF6-4081-AC87-DFCCCCCF51F2
*
* 创建者WenJY
* 电子邮箱:
* 创建时间2025-04-11 16:03:28
* 版本V1.0.0
* 描述:
*
*--------------------------------------------------------------------
* 修改人:
* 时间:
* 修改说明:
*
* 版本V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
using System;
using Microsoft.Extensions.Logging;
using Sln.Iot.Business.@base;
using Sln.Iot.Common;
using Sln.Iot.Config;
using Sln.Iot.Model.dto;
using Sln.Iot.Serilog;
using Sln.Iot.Socket.Adapter;
using TouchSocket.Core;
using TouchSocket.Sockets;
namespace Sln.Iot.Business
{
/// <summary>
/// 登录指令
/// </summary>
public class LoginBusiness:BaseBusiness
{
public LoginBusiness(SerilogHelper logger, AppConfig appConfig,StringChange stringChange) : base(logger, appConfig,stringChange)
{
}
/// <summary>
/// 指令解析
/// </summary>
/// <param name="client"></param>
/// <param name="requestInfo"></param>
/// <param name="bodyLength"></param>
/// <returns></returns>
public override FilterResult BufferAnalysis(ISocketClient client, BufferRequestInfo requestInfo, int bodyLength)
{
var flag = "";
byte[] bDeviceType = new byte[1];
byte[] bDeviceID = new byte[2];
Array.Copy(requestInfo.buffer, 1, bDeviceType, 0, 1);
Array.Copy(requestInfo.buffer, 2, bDeviceID, 0, 2);
flag = base._stringChange.ConverToString(bDeviceType);
flag += base._stringChange.ConverToString(bDeviceID);
string clientIdStr = flag.ToString();
if (clientIdStr.Contains("45"))
{
if (client.Id != clientIdStr)
{
client.ResetId(clientIdStr);
//更新客户端状态
}
}
return FilterResult.Success;
}
/// <summary>
/// 应答处理
/// </summary>
/// <param name="client"></param>
/// <param name="buffer"></param>
public override void ResponseHandle(ISocketClient client, byte[] buffer)
{
MessagePack SendMessagePackInfo = new MessagePack()
{
m_MessageType = 0xA1
};
base.GetMessagePack(ref SendMessagePackInfo,buffer);
base.SendMessageAsync(client, SendMessagePackInfo);
}
}
}