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:
@@ -3,6 +3,10 @@ using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
|
||||
#if !__NOIPENDPOINT__
|
||||
using NetEndPoint = System.Net.IPEndPoint;
|
||||
#endif
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
/// <summary>
|
||||
@@ -17,7 +21,7 @@ namespace Lidgren.Network
|
||||
private object m_messageReceivedEventCreationLock = new object();
|
||||
|
||||
internal readonly List<NetConnection> m_connections;
|
||||
private readonly Dictionary<IPEndPoint, NetConnection> m_connectionLookup;
|
||||
private readonly Dictionary<NetEndPoint, NetConnection> m_connectionLookup;
|
||||
|
||||
private string m_shutdownReason;
|
||||
|
||||
@@ -113,11 +117,11 @@ namespace Lidgren.Network
|
||||
m_configuration = config;
|
||||
m_statistics = new NetPeerStatistics(this);
|
||||
m_releasedIncomingMessages = new NetQueue<NetIncomingMessage>(4);
|
||||
m_unsentUnconnectedMessages = new NetQueue<NetTuple<IPEndPoint, NetOutgoingMessage>>(2);
|
||||
m_unsentUnconnectedMessages = new NetQueue<NetTuple<NetEndPoint, NetOutgoingMessage>>(2);
|
||||
m_connections = new List<NetConnection>();
|
||||
m_connectionLookup = new Dictionary<IPEndPoint, NetConnection>();
|
||||
m_handshakes = new Dictionary<IPEndPoint, NetConnection>();
|
||||
m_senderRemote = (EndPoint)new IPEndPoint(IPAddress.Any, 0);
|
||||
m_connectionLookup = new Dictionary<NetEndPoint, NetConnection>();
|
||||
m_handshakes = new Dictionary<NetEndPoint, NetConnection>();
|
||||
m_senderRemote = (EndPoint)new NetEndPoint(IPAddress.Any, 0);
|
||||
m_status = NetPeerStatus.NotRunning;
|
||||
m_receivedFragmentGroups = new Dictionary<NetConnection, Dictionary<int, ReceivedFragmentGroup>>();
|
||||
}
|
||||
@@ -156,13 +160,13 @@ namespace Lidgren.Network
|
||||
m_upnp.Discover(this);
|
||||
|
||||
// allow some time for network thread to start up in case they call Connect() or UPnP calls immediately
|
||||
Thread.Sleep(50);
|
||||
NetUtility.Sleep(50);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the connection, if any, for a certain remote endpoint
|
||||
/// </summary>
|
||||
public NetConnection GetConnection(IPEndPoint ep)
|
||||
public NetConnection GetConnection(NetEndPoint ep)
|
||||
{
|
||||
NetConnection retval;
|
||||
|
||||
@@ -226,7 +230,7 @@ namespace Lidgren.Network
|
||||
}
|
||||
|
||||
// send message immediately and recycle it
|
||||
internal void SendLibrary(NetOutgoingMessage msg, IPEndPoint recipient)
|
||||
internal void SendLibrary(NetOutgoingMessage msg, NetEndPoint recipient)
|
||||
{
|
||||
VerifyNetworkThread();
|
||||
NetException.Assert(msg.m_isSent == false);
|
||||
@@ -245,7 +249,7 @@ namespace Lidgren.Network
|
||||
/// </summary>
|
||||
public NetConnection Connect(string host, int port)
|
||||
{
|
||||
return Connect(new IPEndPoint(NetUtility.Resolve(host), port), null);
|
||||
return Connect(new NetEndPoint(NetUtility.Resolve(host), port), null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -253,13 +257,13 @@ namespace Lidgren.Network
|
||||
/// </summary>
|
||||
public NetConnection Connect(string host, int port, NetOutgoingMessage hailMessage)
|
||||
{
|
||||
return Connect(new IPEndPoint(NetUtility.Resolve(host), port), hailMessage);
|
||||
return Connect(new NetEndPoint(NetUtility.Resolve(host), port), hailMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a connection to a remote endpoint
|
||||
/// </summary>
|
||||
public NetConnection Connect(IPEndPoint remoteEndPoint)
|
||||
public NetConnection Connect(NetEndPoint remoteEndPoint)
|
||||
{
|
||||
return Connect(remoteEndPoint, null);
|
||||
}
|
||||
@@ -267,7 +271,7 @@ namespace Lidgren.Network
|
||||
/// <summary>
|
||||
/// Create a connection to a remote endpoint
|
||||
/// </summary>
|
||||
public virtual NetConnection Connect(IPEndPoint remoteEndPoint, NetOutgoingMessage hailMessage)
|
||||
public virtual NetConnection Connect(NetEndPoint remoteEndPoint, NetOutgoingMessage hailMessage)
|
||||
{
|
||||
if (remoteEndPoint == null)
|
||||
throw new ArgumentNullException("remoteEndPoint");
|
||||
@@ -319,12 +323,8 @@ namespace Lidgren.Network
|
||||
/// <summary>
|
||||
/// Send raw bytes; only used for debugging
|
||||
/// </summary>
|
||||
#if DEBUG
|
||||
public void RawSend(byte[] arr, int offset, int length, IPEndPoint destination)
|
||||
#else
|
||||
public void RawSend(byte[] arr, int offset, int length, IPEndPoint destination)
|
||||
#endif
|
||||
{
|
||||
public void RawSend(byte[] arr, int offset, int length, NetEndPoint destination)
|
||||
{
|
||||
// wrong thread - this miiiight crash with network thread... but what's a boy to do.
|
||||
Array.Copy(arr, offset, m_sendBuffer, 0, length);
|
||||
bool unused;
|
||||
|
||||
Reference in New Issue
Block a user