mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-05-06 11:32:59 +00:00
Send Lock
This commit is contained in:
parent
5c995a7def
commit
5a0673b403
@ -71,7 +71,7 @@ namespace Esiur.Net.Packets
|
||||
Report,
|
||||
}
|
||||
|
||||
public enum IIPPacketEvent: byte
|
||||
public enum IIPPacketEvent : byte
|
||||
{
|
||||
// Event Manage
|
||||
ResourceReassigned = 0,
|
||||
@ -124,7 +124,7 @@ namespace Esiur.Net.Packets
|
||||
ClearAttributes
|
||||
}
|
||||
|
||||
public enum IIPPacketReport: byte
|
||||
public enum IIPPacketReport : byte
|
||||
{
|
||||
ManagementError,
|
||||
ExecutionError,
|
||||
@ -174,13 +174,6 @@ namespace Esiur.Net.Packets
|
||||
}
|
||||
|
||||
|
||||
//public uint[] ResourcesIds { get; set; }
|
||||
//public uint NewResourcesIds { get; set; }
|
||||
//public uint ChildrenIds { get; set; }
|
||||
//public uint StoresIds { get; set; }
|
||||
|
||||
//public IIPPacketAttachInfo[] AttachReply { get; set; }
|
||||
|
||||
public uint ResourceId { get; set; }
|
||||
public uint NewResourceId { get; set; }
|
||||
//public uint ParentId { get; set; }
|
||||
@ -256,11 +249,11 @@ namespace Esiur.Net.Packets
|
||||
CallbackId = data.GetUInt32(offset);
|
||||
offset += 4;
|
||||
}
|
||||
else // response or reply
|
||||
else
|
||||
{
|
||||
PreviousAction = Action;
|
||||
Action = (IIPPacketAction)(data[offset] & 0x1f);
|
||||
//Bulk = (data[offset++] & 0x20) == 0x20;
|
||||
Action = (IIPPacketAction)(data[offset++] & 0x3f);
|
||||
|
||||
if (NotEnough(offset, ends, 4))
|
||||
return -dataLengthNeeded;
|
||||
|
||||
@ -275,7 +268,7 @@ namespace Esiur.Net.Packets
|
||||
if (NotEnough(offset, ends, 4))
|
||||
return -dataLengthNeeded;
|
||||
|
||||
NewResourceId = data.GetUInt32( offset);
|
||||
NewResourceId = data.GetUInt32(offset);
|
||||
offset += 4;
|
||||
|
||||
}
|
||||
@ -292,7 +285,7 @@ namespace Esiur.Net.Packets
|
||||
ChildId = data.GetUInt32(offset);
|
||||
offset += 4;
|
||||
}
|
||||
else if(Event == IIPPacketEvent.Renamed)
|
||||
else if (Event == IIPPacketEvent.Renamed)
|
||||
{
|
||||
if (NotEnough(offset, ends, 2))
|
||||
return -dataLengthNeeded;
|
||||
@ -322,13 +315,13 @@ namespace Esiur.Net.Packets
|
||||
if (NotEnough(offset, ends, 4))
|
||||
return -dataLengthNeeded;
|
||||
|
||||
var cl = data.GetUInt32( offset);
|
||||
var cl = data.GetUInt32(offset);
|
||||
offset += 4;
|
||||
|
||||
if (NotEnough(offset, ends, cl))
|
||||
return -dataLengthNeeded;
|
||||
|
||||
Content = data.Clip( offset - 5, cl + 5);
|
||||
Content = data.Clip(offset - 5, cl + 5);
|
||||
offset += cl;
|
||||
}
|
||||
else
|
||||
@ -347,10 +340,10 @@ namespace Esiur.Net.Packets
|
||||
|
||||
MethodIndex = data[offset++];
|
||||
|
||||
var cl = data.GetUInt32( offset);
|
||||
var cl = data.GetUInt32(offset);
|
||||
offset += 4;
|
||||
|
||||
Content = data.Clip( offset, cl);
|
||||
Content = data.Clip(offset, cl);
|
||||
offset += cl;
|
||||
|
||||
}
|
||||
@ -378,22 +371,9 @@ namespace Esiur.Net.Packets
|
||||
if (NotEnough(offset, ends, 4))
|
||||
return -dataLengthNeeded;
|
||||
|
||||
/*if (Bulk)
|
||||
{
|
||||
var cl = data.GetUInt32(offset);
|
||||
offset += 4;
|
||||
|
||||
if (NotEnough(offset, ends, cl))
|
||||
return -dataLengthNeeded;
|
||||
|
||||
ResourcesIds = data.GetUInt32Array(offset, cl);
|
||||
}
|
||||
else*/
|
||||
{
|
||||
ResourceId = data.GetUInt32(offset);
|
||||
offset += 4;
|
||||
}
|
||||
}
|
||||
else if (Action == IIPPacketAction.ReattachResource)
|
||||
{
|
||||
if (NotEnough(offset, ends, 12))
|
||||
@ -609,7 +589,7 @@ namespace Esiur.Net.Packets
|
||||
if (NotEnough(offset, ends, cl))
|
||||
return -dataLengthNeeded;
|
||||
|
||||
Content = data.Clip(offset-5, cl + 5);
|
||||
Content = data.Clip(offset - 5, cl + 5);
|
||||
offset += cl;
|
||||
}
|
||||
else
|
||||
@ -617,7 +597,7 @@ namespace Esiur.Net.Packets
|
||||
if (NotEnough(offset, ends, (uint)size))
|
||||
return -dataLengthNeeded;
|
||||
|
||||
Content = data.Clip(offset-1, (uint)size + 1);
|
||||
Content = data.Clip(offset - 1, (uint)size + 1);
|
||||
offset += (uint)size;
|
||||
}
|
||||
}
|
||||
@ -648,8 +628,6 @@ namespace Esiur.Net.Packets
|
||||
|| Action == IIPPacketAction.ReattachResource)
|
||||
{
|
||||
|
||||
//if (!Bulk)
|
||||
//{
|
||||
if (NotEnough(offset, ends, 26))
|
||||
return -dataLengthNeeded;
|
||||
|
||||
@ -679,43 +657,6 @@ namespace Esiur.Net.Packets
|
||||
|
||||
Content = data.Clip(offset, cl);
|
||||
offset += cl;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// // length
|
||||
// if (NotEnough(offset, ends, 4))
|
||||
// return -dataLengthNeeded;
|
||||
|
||||
// var cl = data.GetUInt32(offset);
|
||||
// offset += 4;
|
||||
|
||||
// if (NotEnough(offset, ends, cl))
|
||||
// return -dataLengthNeeded;
|
||||
|
||||
// // Content = data.Clip(offset, cl);
|
||||
// //offset += cl;
|
||||
// cl += offset;
|
||||
|
||||
// var list = new List<IIPPacketAttachInfo>();
|
||||
|
||||
// while(offset < cl)
|
||||
// {
|
||||
// Guid classId = data.GetGuid(offset);
|
||||
// offset += 16;
|
||||
// ulong age = data.GetUInt64(offset);
|
||||
// offset += 8;
|
||||
// var len = data.GetUInt16(offset);
|
||||
// offset += 2;
|
||||
// var link = data.GetString(offset, len);
|
||||
// offset += len;
|
||||
// var cc = data.GetUInt32(offset);
|
||||
// list.Add(new IIPPacketAttachInfo(classId, age, link, data.Clip(offset, cc)));
|
||||
// offset += cc;
|
||||
// }
|
||||
|
||||
//AttachReply = list.ToArray();
|
||||
|
||||
//}
|
||||
}
|
||||
else if (Action == IIPPacketAction.DetachResource)
|
||||
{
|
||||
|
@ -239,22 +239,23 @@ namespace Esiur.Net.Sockets
|
||||
private void DataSent(Task<int> task)
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (sendLock)
|
||||
{
|
||||
|
||||
if (sendBufferQueue.Count > 0)
|
||||
{
|
||||
lock (sendLock)
|
||||
{
|
||||
byte[] data = sendBufferQueue.Dequeue();
|
||||
//Console.WriteLine(Encoding.UTF8.GetString(data));
|
||||
sock.SendAsync(new ArraySegment<byte>(data), SocketFlags.None).ContinueWith(DataSent);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
asyncSending = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (state != SocketState.Closed && !sock.Connected)
|
||||
|
Loading…
x
Reference in New Issue
Block a user