2
0
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:
Ahmed Zamil 2019-11-20 20:57:31 +03:00
parent 5c995a7def
commit 5a0673b403
2 changed files with 50 additions and 108 deletions

View File

@ -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;
@ -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))
@ -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)
{

View File

@ -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)