Moli
2022-04-15 22477f0eca904ec628ab59cd749f959af35c1439
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace WOLAwaken.Helper
{
    public class SendWOLPack
    {
        public byte[] SendData = new byte[102];
        public int[] macAddress = new int[] { 0x50, 0xEB, 0xF6, 0x43, 0x50, 0x08 }; //50:EB:F6:43:50:08
 
        public SendWOLPack()
        {
            var config = Helpers.Tool.GetSystemConfig().baseSysConfg;
            if (config != null) {
                if (config.mac != null && config.mac.Length > 0)
                {
                    macAddress = config.mac;
                }
            }
            int index = 0;
            for (int i = 0; i < 6; i++)
            {
                SendData[index++] = Convert.ToByte(0xFF);
            }
 
            for (int i = 0; i < 16; i++)
            {
                foreach (var a in macAddress)
                {
                    SendData[index++] = Convert.ToByte(a);
                }
            }
 
            new SendUdpPack().SendMessage(SendData);
        }
    }
}