2023-03-24 17:02:04 +08:00

55 lines
1.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Win32;
namespace XKRS.Common.Model.Authority
{
public static class AuthorityCheck
{
public static Timer AuthorityCheckTimer = null;
public static UdpClient RemoteCheckClient = null;//提供用户数据报协议Udp网络服务
static byte[] CHECKBUFFER = null;
static IPEndPoint AuthorityServer = null;//将网络终结点表示为IP地址和端口号
public static bool IsAuthorityOK { get; set; } = false;//是否批准静态属性 默认初值为false
static bool _isCheckAuthorityNecessary = true;
static AuthorityCheck()
{
//AuthorityCheckTimer = new Timer(OnAuthorityCheck, null, 0, 1000 * 60);
RemoteCheckClient = new UdpClient();
//获取或设置 System.Boolean 值,该值指定是否 System.Net.Sockets.UdpClient 可能会发送或接收广播的数据包。
RemoteCheckClient.EnableBroadcast = true;
//获取或设置一个值,指定的后的时间量同步 Overload:System.Net.Sockets.Socket.Receive 调用将会超时。
RemoteCheckClient.Client.ReceiveTimeout = 1000;
CHECKBUFFER = Encoding.UTF8.GetBytes("AuthorityCheck");
//string checkStr = ConfigurationManger.AppSettings["AuthorityCheck"];
}
private static void OnAuthorityCheck(object state)
{
AuthorityCheckOperation();
}
public static void AuthorityCheckOperartion()
{
if (!_isCheckAuthorityNecessary)
{
IsAuthorityOK = true;
}
else
{
DogFeature feature = new DogFeature();
}
}
}
}