You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-16 07:06:30 +09:00
First iteration improved multiplatform support
This commit is contained in:
@@ -25,6 +25,10 @@ using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Diagnostics;
|
||||
|
||||
#if !__NOIPENDPOINT__
|
||||
using NetEndPoint = System.Net.IPEndPoint;
|
||||
#endif
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public partial class NetPeer
|
||||
@@ -37,10 +41,10 @@ namespace Lidgren.Network
|
||||
{
|
||||
public byte[] Data;
|
||||
public double DelayedUntil;
|
||||
public IPEndPoint Target;
|
||||
public NetEndPoint Target;
|
||||
}
|
||||
|
||||
internal void SendPacket(int numBytes, IPEndPoint target, int numMessages, out bool connectionReset)
|
||||
internal void SendPacket(int numBytes, NetEndPoint target, int numMessages, out bool connectionReset)
|
||||
{
|
||||
connectionReset = false;
|
||||
|
||||
@@ -128,13 +132,13 @@ namespace Lidgren.Network
|
||||
catch { }
|
||||
}
|
||||
|
||||
internal bool ActuallySendPacket(byte[] data, int numBytes, IPEndPoint target, out bool connectionReset)
|
||||
internal bool ActuallySendPacket(byte[] data, int numBytes, NetEndPoint target, out bool connectionReset)
|
||||
{
|
||||
connectionReset = false;
|
||||
try
|
||||
{
|
||||
// TODO: refactor this check outta here
|
||||
if (target.Address == IPAddress.Broadcast)
|
||||
if (target.Address == NetUtility.GetBroadcastAddress())
|
||||
{
|
||||
// Some networks do not allow
|
||||
// a global broadcast so we use the BroadcastAddress from the configuration
|
||||
@@ -177,7 +181,7 @@ namespace Lidgren.Network
|
||||
return true;
|
||||
}
|
||||
|
||||
internal bool SendMTUPacket(int numBytes, IPEndPoint target)
|
||||
internal bool SendMTUPacket(int numBytes, NetEndPoint target)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -213,7 +217,7 @@ namespace Lidgren.Network
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
internal bool SendMTUPacket(int numBytes, IPEndPoint target)
|
||||
internal bool SendMTUPacket(int numBytes, NetEndPoint target)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -250,7 +254,7 @@ namespace Lidgren.Network
|
||||
//
|
||||
// Release - just send the packet straight away
|
||||
//
|
||||
internal void SendPacket(int numBytes, IPEndPoint target, int numMessages, out bool connectionReset)
|
||||
internal void SendPacket(int numBytes, NetEndPoint target, int numMessages, out bool connectionReset)
|
||||
{
|
||||
#if USE_RELEASE_STATISTICS
|
||||
m_statistics.PacketSent(numBytes, numMessages);
|
||||
@@ -259,7 +263,7 @@ namespace Lidgren.Network
|
||||
try
|
||||
{
|
||||
// TODO: refactor this check outta here
|
||||
if (target.Address == IPAddress.Broadcast)
|
||||
if (target.Address == NetUtility.GetBroadcastAddress())
|
||||
m_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
|
||||
|
||||
int bytesSent = m_socket.SendTo(m_sendBuffer, 0, numBytes, SocketFlags.None, target);
|
||||
@@ -288,7 +292,7 @@ namespace Lidgren.Network
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (target.Address == IPAddress.Broadcast)
|
||||
if (target.Address == NetUtility.GetBroadcastAddress())
|
||||
m_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, false);
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user