mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 20:39:01 +00:00
Final change for new release.
This commit is contained in:
parent
a952b8ff4b
commit
33fd366580
1 changed files with 50 additions and 50 deletions
|
|
@ -140,56 +140,56 @@ namespace Cosmos.Debug.Common
|
|||
#endif
|
||||
}
|
||||
|
||||
protected void DoRead(IAsyncResult aResult)
|
||||
{
|
||||
try
|
||||
{
|
||||
var xIncoming = (Incoming)aResult.AsyncState;
|
||||
int xCount = xIncoming.Stream.EndRead(aResult);
|
||||
// protected void DoRead(IAsyncResult aResult)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var xIncoming = (Incoming)aResult.AsyncState;
|
||||
// int xCount = xIncoming.Stream.EndRead(aResult);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("DC - Received: {0}", BytesToString(xIncoming.Packet, xIncoming.CurrentPos, xCount)));
|
||||
xIncoming.CurrentPos += xCount;
|
||||
if (xCount == 0)
|
||||
{
|
||||
// If 0, end of stream then just exit without calling BeginRead again
|
||||
return;
|
||||
}
|
||||
else if (xIncoming.CurrentPos < xIncoming.Packet.Length)
|
||||
{
|
||||
// Packet is not full yet, read more data
|
||||
#if TRACK_PENDING
|
||||
try {
|
||||
Interlocked.Increment(ref _pendingReadsCount);
|
||||
#endif
|
||||
xIncoming.Stream.BeginRead(xIncoming.Packet, xIncoming.CurrentPos
|
||||
, xIncoming.Packet.Length - xIncoming.CurrentPos
|
||||
, new AsyncCallback(DoRead), xIncoming);
|
||||
#if TRACK_PENDING
|
||||
}
|
||||
catch (Exception e) {
|
||||
Interlocked.Decrement(ref _pendingReadsCount);
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("DC - Full packet received - Received: {0}", BytesToString(xIncoming.Packet, 0, xIncoming.Packet.Length)));
|
||||
// System.Diagnostics.Debug.WriteLine(String.Format("DC - Received: {0}", BytesToString(xIncoming.Packet, xIncoming.CurrentPos, xCount)));
|
||||
// xIncoming.CurrentPos += xCount;
|
||||
// if (xCount == 0)
|
||||
// {
|
||||
// // If 0, end of stream then just exit without calling BeginRead again
|
||||
// return;
|
||||
// }
|
||||
// else if (xIncoming.CurrentPos < xIncoming.Packet.Length)
|
||||
// {
|
||||
// // Packet is not full yet, read more data
|
||||
//#if TRACK_PENDING
|
||||
// try {
|
||||
// Interlocked.Increment(ref _pendingReadsCount);
|
||||
//#endif
|
||||
// xIncoming.Stream.BeginRead(xIncoming.Packet, xIncoming.CurrentPos
|
||||
// , xIncoming.Packet.Length - xIncoming.CurrentPos
|
||||
// , new AsyncCallback(DoRead), xIncoming);
|
||||
//#if TRACK_PENDING
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// Interlocked.Decrement(ref _pendingReadsCount);
|
||||
// throw;
|
||||
// }
|
||||
//#endif
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// System.Diagnostics.Debug.WriteLine(String.Format("DC - Full packet received - Received: {0}", BytesToString(xIncoming.Packet, 0, xIncoming.Packet.Length)));
|
||||
|
||||
// Full packet received, process it
|
||||
xIncoming.Completed(xIncoming.Packet);
|
||||
}
|
||||
}
|
||||
catch (System.IO.IOException ex)
|
||||
{
|
||||
ConnectionLost(ex);
|
||||
}
|
||||
#if TRACK_PENDING
|
||||
finally {
|
||||
Interlocked.Decrement(ref _pendingReadsCount);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// // Full packet received, process it
|
||||
// xIncoming.Completed(xIncoming.Packet);
|
||||
// }
|
||||
// }
|
||||
// catch (System.IO.IOException ex)
|
||||
// {
|
||||
// ConnectionLost(ex);
|
||||
// }
|
||||
//#if TRACK_PENDING
|
||||
// finally {
|
||||
// Interlocked.Decrement(ref _pendingReadsCount);
|
||||
// }
|
||||
//#endif
|
||||
// }
|
||||
|
||||
private List<Incoming> ReadQueue = new List<Incoming>();
|
||||
private bool reading = false;
|
||||
|
|
@ -215,11 +215,11 @@ namespace Cosmos.Debug.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
mStream.BeginRead(next.Packet, next.CurrentPos, next.Packet.Length - next.CurrentPos, new AsyncCallback(DoRead2), next);
|
||||
mStream.BeginRead(next.Packet, next.CurrentPos, next.Packet.Length - next.CurrentPos, new AsyncCallback(DoRead), next);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DoRead2(IAsyncResult result)
|
||||
private void DoRead(IAsyncResult result)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue