You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-15 22:56:30 +09:00
throw explanatory exception if trying to register callback with no sycnhronizationcontext
This commit is contained in:
@@ -274,13 +274,12 @@ namespace Lidgren.Network
|
||||
|
||||
if ((m_readPosition & 7) == 0) // read directly
|
||||
{
|
||||
// endianness is handled inside BitConverter.ToSingle
|
||||
float retval = BitConverter.ToSingle(m_data, m_readPosition >> 3);
|
||||
return retval;
|
||||
}
|
||||
|
||||
byte[] bytes = PeekBytes(4);
|
||||
return BitConverter.ToSingle(bytes, 0); // endianness is handled inside BitConverter.ToSingle
|
||||
return BitConverter.ToSingle(bytes, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -298,7 +297,7 @@ namespace Lidgren.Network
|
||||
}
|
||||
|
||||
byte[] bytes = PeekBytes(8);
|
||||
return BitConverter.ToDouble(bytes, 0); // endianness is handled inside BitConverter.ToSingle
|
||||
return BitConverter.ToDouble(bytes, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -334,14 +334,13 @@ namespace Lidgren.Network
|
||||
|
||||
if ((m_readPosition & 7) == 0) // read directly
|
||||
{
|
||||
// endianness is handled inside BitConverter.ToSingle
|
||||
float retval = BitConverter.ToSingle(m_data, m_readPosition >> 3);
|
||||
m_readPosition += 32;
|
||||
return retval;
|
||||
}
|
||||
|
||||
byte[] bytes = ReadBytes(4);
|
||||
return BitConverter.ToSingle(bytes, 0); // endianness is handled inside BitConverter.ToSingle
|
||||
return BitConverter.ToSingle(bytes, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -360,7 +359,7 @@ namespace Lidgren.Network
|
||||
}
|
||||
|
||||
byte[] bytes = ReadBytes(8);
|
||||
return BitConverter.ToDouble(bytes, 0); // endianness is handled inside BitConverter.ToSingle
|
||||
return BitConverter.ToDouble(bytes, 0);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -46,6 +46,8 @@ namespace Lidgren.Network
|
||||
/// </summary>
|
||||
public void RegisterReceivedCallback(SendOrPostCallback callback)
|
||||
{
|
||||
if (SynchronizationContext.Current == null)
|
||||
throw new NetException("Need a SynchronizationContext to register callback on correct thread!");
|
||||
if (m_receiveCallbacks == null)
|
||||
m_receiveCallbacks = new List<NetTuple<SynchronizationContext, SendOrPostCallback>>();
|
||||
m_receiveCallbacks.Add(new NetTuple<SynchronizationContext, SendOrPostCallback>(SynchronizationContext.Current, callback));
|
||||
|
||||
Reference in New Issue
Block a user