mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 05:52:11 +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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void DoRead(IAsyncResult aResult)
|
// protected void DoRead(IAsyncResult aResult)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var xIncoming = (Incoming)aResult.AsyncState;
|
// var xIncoming = (Incoming)aResult.AsyncState;
|
||||||
int xCount = xIncoming.Stream.EndRead(aResult);
|
// int xCount = xIncoming.Stream.EndRead(aResult);
|
||||||
|
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("DC - Received: {0}", BytesToString(xIncoming.Packet, xIncoming.CurrentPos, xCount)));
|
// System.Diagnostics.Debug.WriteLine(String.Format("DC - Received: {0}", BytesToString(xIncoming.Packet, xIncoming.CurrentPos, xCount)));
|
||||||
xIncoming.CurrentPos += xCount;
|
// xIncoming.CurrentPos += xCount;
|
||||||
if (xCount == 0)
|
// if (xCount == 0)
|
||||||
{
|
// {
|
||||||
// If 0, end of stream then just exit without calling BeginRead again
|
// // If 0, end of stream then just exit without calling BeginRead again
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
else if (xIncoming.CurrentPos < xIncoming.Packet.Length)
|
// else if (xIncoming.CurrentPos < xIncoming.Packet.Length)
|
||||||
{
|
// {
|
||||||
// Packet is not full yet, read more data
|
// // Packet is not full yet, read more data
|
||||||
#if TRACK_PENDING
|
//#if TRACK_PENDING
|
||||||
try {
|
// try {
|
||||||
Interlocked.Increment(ref _pendingReadsCount);
|
// Interlocked.Increment(ref _pendingReadsCount);
|
||||||
#endif
|
//#endif
|
||||||
xIncoming.Stream.BeginRead(xIncoming.Packet, xIncoming.CurrentPos
|
// xIncoming.Stream.BeginRead(xIncoming.Packet, xIncoming.CurrentPos
|
||||||
, xIncoming.Packet.Length - xIncoming.CurrentPos
|
// , xIncoming.Packet.Length - xIncoming.CurrentPos
|
||||||
, new AsyncCallback(DoRead), xIncoming);
|
// , new AsyncCallback(DoRead), xIncoming);
|
||||||
#if TRACK_PENDING
|
//#if TRACK_PENDING
|
||||||
}
|
// }
|
||||||
catch (Exception e) {
|
// catch (Exception e) {
|
||||||
Interlocked.Decrement(ref _pendingReadsCount);
|
// Interlocked.Decrement(ref _pendingReadsCount);
|
||||||
throw;
|
// throw;
|
||||||
}
|
// }
|
||||||
#endif
|
//#endif
|
||||||
}
|
// }
|
||||||
else
|
// 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 - Full packet received - Received: {0}", BytesToString(xIncoming.Packet, 0, xIncoming.Packet.Length)));
|
||||||
|
|
||||||
// Full packet received, process it
|
// // Full packet received, process it
|
||||||
xIncoming.Completed(xIncoming.Packet);
|
// xIncoming.Completed(xIncoming.Packet);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (System.IO.IOException ex)
|
// catch (System.IO.IOException ex)
|
||||||
{
|
// {
|
||||||
ConnectionLost(ex);
|
// ConnectionLost(ex);
|
||||||
}
|
// }
|
||||||
#if TRACK_PENDING
|
//#if TRACK_PENDING
|
||||||
finally {
|
// finally {
|
||||||
Interlocked.Decrement(ref _pendingReadsCount);
|
// Interlocked.Decrement(ref _pendingReadsCount);
|
||||||
}
|
// }
|
||||||
#endif
|
//#endif
|
||||||
}
|
// }
|
||||||
|
|
||||||
private List<Incoming> ReadQueue = new List<Incoming>();
|
private List<Incoming> ReadQueue = new List<Incoming>();
|
||||||
private bool reading = false;
|
private bool reading = false;
|
||||||
|
|
@ -215,11 +215,11 @@ namespace Cosmos.Debug.Common
|
||||||
}
|
}
|
||||||
else
|
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
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue