#region 磁碟空間管理:刪除Player上指定的媒體檔案
public void CommandSetManageDisk(byte gid, byte did,string deletestring)
{
// 分包發送
string ManageDiskStr = deletestring;
byte i = 0;
Encoding GB2312Encoding = UnicodeEncoding.GetEncoding("GB2312");
byte[] ManageDisk = GB2312Encoding.GetBytes(ManageDiskStr);
byte [] myManageDisk = new byte [300];
int txtLength = ManageDisk.Length;
int packetizationtimer = txtLength / 300;
int packetizationresidue = txtLength % 300;
int packetizationsender;
//如果沒有餘數,發包時就不用多發一次
if (packetizationresidue > 0)
{
packetizationsender = packetizationtimer + 1;
}
else
{
packetizationsender = packetizationtimer;
}
//開始分包發送
for (i = 0; i < packetizationsender; i++)
{
if (i < packetizationtimer)
{
Array.Copy(ManageDisk, i * 300, myManageDisk, 0, 300);
}
else
{
Array.Copy(ManageDisk, i * 300, myManageDisk, 0, packetizationresidue);
}
PlayerMessages.SetManageDisk setmanagedisk = new PlayerMessages.SetManageDisk();
setmanagedisk.direct = 0x02;
setmanagedisk.category = 0x03;
setmanagedisk.type = 0x10;
setmanagedisk.GroupID = gid ;
setmanagedisk.DeviceID = did ;
setmanagedisk.Sequence = i;
setmanagedisk.size = 300;
if (i == (packetizationsender-1)) {
setmanagedisk.Sequence=0xFF;
setmanagedisk.size =(ushort)packetizationresidue;
}
setmanagedisk.DeleteFile = myManageDisk;
byte[] data = PlayerMessages.StructToBytes(setmanagedisk);
ssock.OnUDPDataSend(data);
}
}
PlayerMessages.SetManageDisk 是struct,UDP包的資料結構
setmanagedisk.Sequence = i;表示包的序號,0xFF表示最後一個包