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,
|
Report,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum IIPPacketEvent: byte
|
public enum IIPPacketEvent : byte
|
||||||
{
|
{
|
||||||
// Event Manage
|
// Event Manage
|
||||||
ResourceReassigned = 0,
|
ResourceReassigned = 0,
|
||||||
@ -124,7 +124,7 @@ namespace Esiur.Net.Packets
|
|||||||
ClearAttributes
|
ClearAttributes
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum IIPPacketReport: byte
|
public enum IIPPacketReport : byte
|
||||||
{
|
{
|
||||||
ManagementError,
|
ManagementError,
|
||||||
ExecutionError,
|
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 ResourceId { get; set; }
|
||||||
public uint NewResourceId { get; set; }
|
public uint NewResourceId { get; set; }
|
||||||
//public uint ParentId { get; set; }
|
//public uint ParentId { get; set; }
|
||||||
@ -256,11 +249,11 @@ namespace Esiur.Net.Packets
|
|||||||
CallbackId = data.GetUInt32(offset);
|
CallbackId = data.GetUInt32(offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
}
|
}
|
||||||
else // response or reply
|
else
|
||||||
{
|
{
|
||||||
PreviousAction = Action;
|
PreviousAction = Action;
|
||||||
Action = (IIPPacketAction)(data[offset] & 0x1f);
|
Action = (IIPPacketAction)(data[offset++] & 0x3f);
|
||||||
//Bulk = (data[offset++] & 0x20) == 0x20;
|
|
||||||
if (NotEnough(offset, ends, 4))
|
if (NotEnough(offset, ends, 4))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
@ -275,7 +268,7 @@ namespace Esiur.Net.Packets
|
|||||||
if (NotEnough(offset, ends, 4))
|
if (NotEnough(offset, ends, 4))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
NewResourceId = data.GetUInt32( offset);
|
NewResourceId = data.GetUInt32(offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -292,7 +285,7 @@ namespace Esiur.Net.Packets
|
|||||||
ChildId = data.GetUInt32(offset);
|
ChildId = data.GetUInt32(offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
}
|
}
|
||||||
else if(Event == IIPPacketEvent.Renamed)
|
else if (Event == IIPPacketEvent.Renamed)
|
||||||
{
|
{
|
||||||
if (NotEnough(offset, ends, 2))
|
if (NotEnough(offset, ends, 2))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
@ -322,13 +315,13 @@ namespace Esiur.Net.Packets
|
|||||||
if (NotEnough(offset, ends, 4))
|
if (NotEnough(offset, ends, 4))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
var cl = data.GetUInt32( offset);
|
var cl = data.GetUInt32(offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
|
||||||
if (NotEnough(offset, ends, cl))
|
if (NotEnough(offset, ends, cl))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
Content = data.Clip( offset - 5, cl + 5);
|
Content = data.Clip(offset - 5, cl + 5);
|
||||||
offset += cl;
|
offset += cl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -347,10 +340,10 @@ namespace Esiur.Net.Packets
|
|||||||
|
|
||||||
MethodIndex = data[offset++];
|
MethodIndex = data[offset++];
|
||||||
|
|
||||||
var cl = data.GetUInt32( offset);
|
var cl = data.GetUInt32(offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
|
||||||
Content = data.Clip( offset, cl);
|
Content = data.Clip(offset, cl);
|
||||||
offset += cl;
|
offset += cl;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -378,21 +371,8 @@ namespace Esiur.Net.Packets
|
|||||||
if (NotEnough(offset, ends, 4))
|
if (NotEnough(offset, ends, 4))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
/*if (Bulk)
|
ResourceId = data.GetUInt32(offset);
|
||||||
{
|
offset += 4;
|
||||||
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)
|
else if (Action == IIPPacketAction.ReattachResource)
|
||||||
{
|
{
|
||||||
@ -609,7 +589,7 @@ namespace Esiur.Net.Packets
|
|||||||
if (NotEnough(offset, ends, cl))
|
if (NotEnough(offset, ends, cl))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
Content = data.Clip(offset-5, cl + 5);
|
Content = data.Clip(offset - 5, cl + 5);
|
||||||
offset += cl;
|
offset += cl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -617,7 +597,7 @@ namespace Esiur.Net.Packets
|
|||||||
if (NotEnough(offset, ends, (uint)size))
|
if (NotEnough(offset, ends, (uint)size))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
Content = data.Clip(offset-1, (uint)size + 1);
|
Content = data.Clip(offset - 1, (uint)size + 1);
|
||||||
offset += (uint)size;
|
offset += (uint)size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -648,74 +628,35 @@ namespace Esiur.Net.Packets
|
|||||||
|| Action == IIPPacketAction.ReattachResource)
|
|| Action == IIPPacketAction.ReattachResource)
|
||||||
{
|
{
|
||||||
|
|
||||||
//if (!Bulk)
|
if (NotEnough(offset, ends, 26))
|
||||||
//{
|
return -dataLengthNeeded;
|
||||||
if (NotEnough(offset, ends, 26))
|
|
||||||
return -dataLengthNeeded;
|
|
||||||
|
|
||||||
ClassId = data.GetGuid(offset);
|
ClassId = data.GetGuid(offset);
|
||||||
offset += 16;
|
offset += 16;
|
||||||
|
|
||||||
ResourceAge = data.GetUInt64(offset);
|
ResourceAge = data.GetUInt64(offset);
|
||||||
offset += 8;
|
offset += 8;
|
||||||
|
|
||||||
uint cl = data.GetUInt16(offset);
|
uint cl = data.GetUInt16(offset);
|
||||||
offset += 2;
|
offset += 2;
|
||||||
|
|
||||||
if (NotEnough(offset, ends, cl))
|
if (NotEnough(offset, ends, cl))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
ResourceLink = data.GetString(offset, cl);
|
ResourceLink = data.GetString(offset, cl);
|
||||||
offset += cl;
|
offset += cl;
|
||||||
|
|
||||||
if (NotEnough(offset, ends, 4))
|
if (NotEnough(offset, ends, 4))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
cl = data.GetUInt32(offset);
|
cl = data.GetUInt32(offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
|
||||||
if (NotEnough(offset, ends, cl))
|
if (NotEnough(offset, ends, cl))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
Content = data.Clip(offset, cl);
|
Content = data.Clip(offset, cl);
|
||||||
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)
|
else if (Action == IIPPacketAction.DetachResource)
|
||||||
{
|
{
|
||||||
@ -737,7 +678,7 @@ namespace Esiur.Net.Packets
|
|||||||
{
|
{
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
// Inquire
|
// Inquire
|
||||||
else if (Action == IIPPacketAction.TemplateFromClassName
|
else if (Action == IIPPacketAction.TemplateFromClassName
|
||||||
|| Action == IIPPacketAction.TemplateFromClassId
|
|| Action == IIPPacketAction.TemplateFromClassId
|
||||||
|| Action == IIPPacketAction.TemplateFromResourceId
|
|| Action == IIPPacketAction.TemplateFromResourceId
|
||||||
|
@ -240,19 +240,20 @@ namespace Esiur.Net.Sockets
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
lock (sendLock)
|
||||||
if (sendBufferQueue.Count > 0)
|
|
||||||
{
|
{
|
||||||
lock (sendLock)
|
|
||||||
|
if (sendBufferQueue.Count > 0)
|
||||||
{
|
{
|
||||||
byte[] data = sendBufferQueue.Dequeue();
|
byte[] data = sendBufferQueue.Dequeue();
|
||||||
//Console.WriteLine(Encoding.UTF8.GetString(data));
|
//Console.WriteLine(Encoding.UTF8.GetString(data));
|
||||||
sock.SendAsync(new ArraySegment<byte>(data), SocketFlags.None).ContinueWith(DataSent);
|
sock.SendAsync(new ArraySegment<byte>(data), SocketFlags.None).ContinueWith(DataSent);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
asyncSending = false;
|
asyncSending = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user