This commit is contained in:
Mister_Nebula 2020-12-07 21:04:52 +00:00
parent a814c418a7
commit f726e651b8
6 changed files with 113 additions and 261 deletions

View File

@ -75,15 +75,6 @@ namespace QuantumUNET
} }
} }
[Obsolete("Moved to NetworkMigrationManager.")]
public PeerInfoMessage[] peers
{
get
{
return null;
}
}
internal int hostId internal int hostId
{ {
get get

View File

@ -450,9 +450,6 @@ namespace QuantumUNET
public virtual void TransportReceive(byte[] bytes, int numBytes, int channelId) => HandleBytes(bytes, numBytes, channelId); public virtual void TransportReceive(byte[] bytes, int numBytes, int channelId) => HandleBytes(bytes, numBytes, channelId);
[Obsolete("TransportRecieve has been deprecated. Use TransportReceive instead (UnityUpgradable) -> TransportReceive(*)", false)]
public virtual void TransportRecieve(byte[] bytes, int numBytes, int channelId) => TransportReceive(bytes, numBytes, channelId);
public virtual bool TransportSend(byte[] bytes, int numBytes, int channelId, out byte error) => NetworkTransport.Send(hostId, connectionId, channelId, bytes, numBytes, out error); public virtual bool TransportSend(byte[] bytes, int numBytes, int channelId, out byte error) => NetworkTransport.Send(hostId, connectionId, channelId, bytes, numBytes, out error);
internal void AddOwnedObject(QSBNetworkIdentity obj) internal void AddOwnedObject(QSBNetworkIdentity obj)

View File

@ -34,19 +34,6 @@ namespace QuantumUNET
} }
manager.networkAddress = GUI.TextField(new Rect(num + 100, num2, 95f, 20f), manager.networkAddress); manager.networkAddress = GUI.TextField(new Rect(num + 100, num2, 95f, 20f), manager.networkAddress);
num2 += 24; num2 += 24;
if (Application.platform == RuntimePlatform.WebGLPlayer)
{
GUI.Box(new Rect(num, num2, 200f, 25f), "( WebGL cannot be server )");
num2 += 24;
}
else
{
if (GUI.Button(new Rect(num, num2, 200f, 20f), "LAN Server Only"))
{
manager.StartServer();
}
num2 += 24;
}
} }
else else
{ {
@ -103,14 +90,6 @@ namespace QuantumUNET
} }
num2 += 24; num2 += 24;
} }
if (!QSBNetworkServer.active && !manager.IsClientConnected() && flag)
{
num2 += 10;
if (Application.platform == RuntimePlatform.WebGLPlayer)
{
GUI.Box(new Rect(num - 5, num2, 220f, 25f), "(WebGL cannot use Match Maker)");
}
}
} }
} }

View File

@ -7,11 +7,9 @@ namespace QuantumUNET
{ {
public class QSBNetworkReader public class QSBNetworkReader
{ {
public QSBNetworkReader() private QSBNetBuffer m_buf;
{ private static byte[] s_StringReaderBuffer;
m_buf = new QSBNetBuffer(); private static Encoding s_Encoding;
Initialize();
}
public QSBNetworkReader(QSBNetworkWriter writer) public QSBNetworkReader(QSBNetworkWriter writer)
{ {
@ -34,69 +32,51 @@ namespace QuantumUNET
} }
} }
public uint Position public uint Position => m_buf.Position;
{
get
{
return m_buf.Position;
}
}
public int Length public int Length => m_buf.Length;
{
get
{
return m_buf.Length;
}
}
public void SeekZero() public void SeekZero() => m_buf.SeekZero();
{
m_buf.SeekZero();
}
internal void Replace(byte[] buffer) internal void Replace(byte[] buffer) => m_buf.Replace(buffer);
{
m_buf.Replace(buffer);
}
public uint ReadPackedUInt32() public uint ReadPackedUInt32()
{ {
byte b = ReadByte(); var b = ReadByte();
uint result; uint result;
if (b < 241) if (b < 241)
{ {
result = (uint)b; result = b;
} }
else else
{ {
byte b2 = ReadByte(); var b2 = ReadByte();
if (b >= 241 && b <= 248) if (b >= 241 && b <= 248)
{ {
result = 240U + 256U * (uint)(b - 241) + (uint)b2; result = 240U + (256U * (uint)(b - 241)) + b2;
} }
else else
{ {
byte b3 = ReadByte(); var b3 = ReadByte();
if (b == 249) if (b == 249)
{ {
result = 2288U + 256U * (uint)b2 + (uint)b3; result = 2288U + (256U * b2) + b3;
} }
else else
{ {
byte b4 = ReadByte(); var b4 = ReadByte();
if (b == 250) if (b == 250)
{ {
result = (uint)((int)b2 + ((int)b3 << 8) + ((int)b4 << 16)); result = (uint)(b2 + (b3 << 8) + (b4 << 16));
} }
else else
{ {
byte b5 = ReadByte(); var b5 = ReadByte();
if (b < 251) if (b < 251)
{ {
throw new IndexOutOfRangeException("ReadPackedUInt32() failure: " + b); throw new IndexOutOfRangeException("ReadPackedUInt32() failure: " + b);
} }
result = (uint)((int)b2 + ((int)b3 << 8) + ((int)b4 << 16) + ((int)b5 << 24)); result = (uint)(b2 + (b3 << 8) + (b4 << 16) + (b5 << 24));
} }
} }
} }
@ -106,69 +86,69 @@ namespace QuantumUNET
public ulong ReadPackedUInt64() public ulong ReadPackedUInt64()
{ {
byte b = ReadByte(); var b = ReadByte();
ulong result; ulong result;
if (b < 241) if (b < 241)
{ {
result = (ulong)b; result = b;
} }
else else
{ {
byte b2 = ReadByte(); var b2 = ReadByte();
if (b >= 241 && b <= 248) if (b >= 241 && b <= 248)
{ {
result = 240UL + 256UL * ((ulong)b - 241UL) + (ulong)b2; result = 240UL + (256UL * (b - 241UL)) + b2;
} }
else else
{ {
byte b3 = ReadByte(); var b3 = ReadByte();
if (b == 249) if (b == 249)
{ {
result = 2288UL + 256UL * (ulong)b2 + (ulong)b3; result = 2288UL + (256UL * b2) + b3;
} }
else else
{ {
byte b4 = ReadByte(); var b4 = ReadByte();
if (b == 250) if (b == 250)
{ {
result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16); result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16);
} }
else else
{ {
byte b5 = ReadByte(); var b5 = ReadByte();
if (b == 251) if (b == 251)
{ {
result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24); result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24);
} }
else else
{ {
byte b6 = ReadByte(); var b6 = ReadByte();
if (b == 252) if (b == 252)
{ {
result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32); result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32);
} }
else else
{ {
byte b7 = ReadByte(); var b7 = ReadByte();
if (b == 253) if (b == 253)
{ {
result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40); result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40);
} }
else else
{ {
byte b8 = ReadByte(); var b8 = ReadByte();
if (b == 254) if (b == 254)
{ {
result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40) + ((ulong)b8 << 48); result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40) + ((ulong)b8 << 48);
} }
else else
{ {
byte b9 = ReadByte(); var b9 = ReadByte();
if (b != 255) if (b != 255)
{ {
throw new IndexOutOfRangeException("ReadPackedUInt64() failure: " + b); throw new IndexOutOfRangeException("ReadPackedUInt64() failure: " + b);
} }
result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40) + ((ulong)b8 << 48) + ((ulong)b9 << 56); result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40) + ((ulong)b8 << 48) + ((ulong)b9 << 56);
} }
} }
} }
@ -180,61 +160,46 @@ namespace QuantumUNET
return result; return result;
} }
public NetworkInstanceId ReadNetworkId() public NetworkInstanceId ReadNetworkId() => new NetworkInstanceId(ReadPackedUInt32());
{
return new NetworkInstanceId(ReadPackedUInt32());
}
public NetworkSceneId ReadSceneId() public NetworkSceneId ReadSceneId() => new NetworkSceneId(ReadPackedUInt32());
{
return new NetworkSceneId(ReadPackedUInt32());
}
public byte ReadByte() public byte ReadByte() => m_buf.ReadByte();
{
return m_buf.ReadByte();
}
public sbyte ReadSByte() public sbyte ReadSByte() => (sbyte)m_buf.ReadByte();
{
return (sbyte)m_buf.ReadByte();
}
public short ReadInt16() public short ReadInt16()
{ {
ushort num = 0; ushort num = 0;
num |= (ushort)m_buf.ReadByte(); num |= m_buf.ReadByte();
num |= (ushort)(m_buf.ReadByte() << 8); num |= (ushort)(m_buf.ReadByte() << 8);
return (short)num; return (short)num;
} }
public ushort ReadUInt16() public ushort ReadUInt16() => (ushort)((ushort)(0U | m_buf.ReadByte()) | (uint)(ushort)((uint)m_buf.ReadByte() << 8));
{
return (ushort)((uint)(ushort)(0U | (uint)m_buf.ReadByte()) | (uint)(ushort)((uint)m_buf.ReadByte() << 8));
}
public int ReadInt32() public int ReadInt32()
{ {
uint num = 0U; var num = 0U;
num |= (uint)m_buf.ReadByte(); num |= m_buf.ReadByte();
num |= (uint)((uint)m_buf.ReadByte() << 8); num |= (uint)m_buf.ReadByte() << 8;
num |= (uint)((uint)m_buf.ReadByte() << 16); num |= (uint)m_buf.ReadByte() << 16;
return (int)(num | (uint)((uint)m_buf.ReadByte() << 24)); return (int)(num | ((uint)m_buf.ReadByte() << 24));
} }
public uint ReadUInt32() public uint ReadUInt32()
{ {
uint num = 0U; var num = 0U;
num |= (uint)m_buf.ReadByte(); num |= m_buf.ReadByte();
num |= (uint)((uint)m_buf.ReadByte() << 8); num |= (uint)m_buf.ReadByte() << 8;
num |= (uint)((uint)m_buf.ReadByte() << 16); num |= (uint)m_buf.ReadByte() << 16;
return num | (uint)((uint)m_buf.ReadByte() << 24); return num | ((uint)m_buf.ReadByte() << 24);
} }
public long ReadInt64() public long ReadInt64()
{ {
ulong num = 0UL; var num = 0UL;
ulong num2 = (ulong)m_buf.ReadByte(); var num2 = (ulong)m_buf.ReadByte();
num |= num2; num |= num2;
num2 = (ulong)m_buf.ReadByte() << 8; num2 = (ulong)m_buf.ReadByte() << 8;
num |= num2; num |= num2;
@ -254,8 +219,8 @@ namespace QuantumUNET
public ulong ReadUInt64() public ulong ReadUInt64()
{ {
ulong num = 0UL; var num = 0UL;
ulong num2 = (ulong)m_buf.ReadByte(); var num2 = (ulong)m_buf.ReadByte();
num |= num2; num |= num2;
num2 = (ulong)m_buf.ReadByte() << 8; num2 = (ulong)m_buf.ReadByte() << 8;
num |= num2; num |= num2;
@ -298,7 +263,7 @@ namespace QuantumUNET
public string ReadString() public string ReadString()
{ {
ushort num = ReadUInt16(); var num = ReadUInt16();
string result; string result;
if (num == 0) if (num == 0)
{ {
@ -310,25 +275,22 @@ namespace QuantumUNET
{ {
throw new IndexOutOfRangeException("ReadString() too long: " + num); throw new IndexOutOfRangeException("ReadString() too long: " + num);
} }
while ((int)num > s_StringReaderBuffer.Length) while (num > s_StringReaderBuffer.Length)
{ {
s_StringReaderBuffer = new byte[s_StringReaderBuffer.Length * 2]; s_StringReaderBuffer = new byte[s_StringReaderBuffer.Length * 2];
} }
m_buf.ReadBytes(s_StringReaderBuffer, (uint)num); m_buf.ReadBytes(s_StringReaderBuffer, num);
char[] chars = s_Encoding.GetChars(s_StringReaderBuffer, 0, (int)num); var chars = s_Encoding.GetChars(s_StringReaderBuffer, 0, num);
result = new string(chars); result = new string(chars);
} }
return result; return result;
} }
public char ReadChar() public char ReadChar() => (char)m_buf.ReadByte();
{
return (char)m_buf.ReadByte();
}
public bool ReadBoolean() public bool ReadBoolean()
{ {
int num = (int)m_buf.ReadByte(); var num = (int)m_buf.ReadByte();
return num == 1; return num == 1;
} }
@ -338,14 +300,14 @@ namespace QuantumUNET
{ {
throw new IndexOutOfRangeException("NetworkReader ReadBytes " + count); throw new IndexOutOfRangeException("NetworkReader ReadBytes " + count);
} }
byte[] array = new byte[count]; var array = new byte[count];
m_buf.ReadBytes(array, (uint)count); m_buf.ReadBytes(array, (uint)count);
return array; return array;
} }
public byte[] ReadBytesAndSize() public byte[] ReadBytesAndSize()
{ {
ushort num = ReadUInt16(); var num = ReadUInt16();
byte[] result; byte[] result;
if (num == 0) if (num == 0)
{ {
@ -353,55 +315,28 @@ namespace QuantumUNET
} }
else else
{ {
result = ReadBytes((int)num); result = ReadBytes(num);
} }
return result; return result;
} }
public Vector2 ReadVector2() public Vector2 ReadVector2() => new Vector2(ReadSingle(), ReadSingle());
{
return new Vector2(ReadSingle(), ReadSingle());
}
public Vector3 ReadVector3() public Vector3 ReadVector3() => new Vector3(ReadSingle(), ReadSingle(), ReadSingle());
{
return new Vector3(ReadSingle(), ReadSingle(), ReadSingle());
}
public Vector4 ReadVector4() public Vector4 ReadVector4() => new Vector4(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
{
return new Vector4(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
}
public Color ReadColor() public Color ReadColor() => new Color(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
{
return new Color(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
}
public Color32 ReadColor32() public Color32 ReadColor32() => new Color32(ReadByte(), ReadByte(), ReadByte(), ReadByte());
{
return new Color32(ReadByte(), ReadByte(), ReadByte(), ReadByte());
}
public Quaternion ReadQuaternion() public Quaternion ReadQuaternion() => new Quaternion(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
{
return new Quaternion(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
}
public Rect ReadRect() public Rect ReadRect() => new Rect(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
{
return new Rect(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
}
public Plane ReadPlane() public Plane ReadPlane() => new Plane(ReadVector3(), ReadSingle());
{
return new Plane(ReadVector3(), ReadSingle());
}
public Ray ReadRay() public Ray ReadRay() => new Ray(ReadVector3(), ReadVector3());
{
return new Ray(ReadVector3(), ReadVector3());
}
public Matrix4x4 ReadMatrix4x4() public Matrix4x4 ReadMatrix4x4()
{ {
@ -450,7 +385,7 @@ namespace QuantumUNET
public Transform ReadTransform() public Transform ReadTransform()
{ {
NetworkInstanceId networkInstanceId = ReadNetworkId(); var networkInstanceId = ReadNetworkId();
Transform result; Transform result;
if (networkInstanceId.IsEmpty()) if (networkInstanceId.IsEmpty())
{ {
@ -458,7 +393,7 @@ namespace QuantumUNET
} }
else else
{ {
GameObject gameObject = QSBClientScene.FindLocalObject(networkInstanceId); var gameObject = QSBClientScene.FindLocalObject(networkInstanceId);
if (gameObject == null) if (gameObject == null)
{ {
if (LogFilter.logDebug) if (LogFilter.logDebug)
@ -477,7 +412,7 @@ namespace QuantumUNET
public GameObject ReadGameObject() public GameObject ReadGameObject()
{ {
NetworkInstanceId networkInstanceId = ReadNetworkId(); var networkInstanceId = ReadNetworkId();
GameObject result; GameObject result;
if (networkInstanceId.IsEmpty()) if (networkInstanceId.IsEmpty())
{ {
@ -508,7 +443,7 @@ namespace QuantumUNET
public QSBNetworkIdentity ReadNetworkIdentity() public QSBNetworkIdentity ReadNetworkIdentity()
{ {
NetworkInstanceId networkInstanceId = ReadNetworkId(); var networkInstanceId = ReadNetworkId();
QSBNetworkIdentity result; QSBNetworkIdentity result;
if (networkInstanceId.IsEmpty()) if (networkInstanceId.IsEmpty())
{ {
@ -541,26 +476,13 @@ namespace QuantumUNET
return result; return result;
} }
public override string ToString() public override string ToString() => m_buf.ToString();
{
return m_buf.ToString();
}
public TMsg ReadMessage<TMsg>() where TMsg : QSBMessageBase, new() public TMsg ReadMessage<TMsg>() where TMsg : QSBMessageBase, new()
{ {
TMsg result = Activator.CreateInstance<TMsg>(); var result = Activator.CreateInstance<TMsg>();
result.Deserialize(this); result.Deserialize(this);
return result; return result;
} }
private QSBNetBuffer m_buf;
private const int k_MaxStringLength = 32768;
private const int k_InitialStringBufferSize = 1024;
private static byte[] s_StringReaderBuffer;
private static Encoding s_Encoding;
} }
} }

View File

@ -18,13 +18,13 @@ namespace QuantumUNET
{ {
get get
{ {
return this.m_LocalObjects; return m_LocalObjects;
} }
} }
internal void Shutdown() internal void Shutdown()
{ {
this.ClearLocalObjects(); ClearLocalObjects();
ClearSpawners(); ClearSpawners();
} }
@ -32,19 +32,19 @@ namespace QuantumUNET
{ {
if (obj == null) if (obj == null)
{ {
this.localObjects[netId] = null; localObjects[netId] = null;
} }
else else
{ {
QSBNetworkIdentity networkIdentity = null; QSBNetworkIdentity networkIdentity = null;
if (this.localObjects.ContainsKey(netId)) if (localObjects.ContainsKey(netId))
{ {
networkIdentity = this.localObjects[netId]; networkIdentity = localObjects[netId];
} }
if (networkIdentity == null) if (networkIdentity == null)
{ {
networkIdentity = obj.GetComponent<QSBNetworkIdentity>(); networkIdentity = obj.GetComponent<QSBNetworkIdentity>();
this.localObjects[netId] = networkIdentity; localObjects[netId] = networkIdentity;
} }
networkIdentity.UpdateClientServer(isClient, isServer); networkIdentity.UpdateClientServer(isClient, isServer);
} }
@ -52,9 +52,9 @@ namespace QuantumUNET
internal GameObject FindLocalObject(NetworkInstanceId netId) internal GameObject FindLocalObject(NetworkInstanceId netId)
{ {
if (this.localObjects.ContainsKey(netId)) if (localObjects.ContainsKey(netId))
{ {
QSBNetworkIdentity networkIdentity = this.localObjects[netId]; var networkIdentity = localObjects[netId];
if (networkIdentity != null) if (networkIdentity != null)
{ {
return networkIdentity.gameObject; return networkIdentity.gameObject;
@ -87,11 +87,11 @@ namespace QuantumUNET
internal bool RemoveLocalObjectAndDestroy(NetworkInstanceId netId) internal bool RemoveLocalObjectAndDestroy(NetworkInstanceId netId)
{ {
bool result; bool result;
if (this.localObjects.ContainsKey(netId)) if (localObjects.ContainsKey(netId))
{ {
QSBNetworkIdentity networkIdentity = this.localObjects[netId]; var networkIdentity = localObjects[netId];
UnityEngine.Object.Destroy(networkIdentity.gameObject); UnityEngine.Object.Destroy(networkIdentity.gameObject);
result = this.localObjects.Remove(netId); result = localObjects.Remove(netId);
} }
else else
{ {
@ -102,12 +102,12 @@ namespace QuantumUNET
internal void ClearLocalObjects() internal void ClearLocalObjects()
{ {
this.localObjects.Clear(); localObjects.Clear();
} }
internal static void RegisterPrefab(GameObject prefab, NetworkHash128 newAssetId) internal static void RegisterPrefab(GameObject prefab, NetworkHash128 newAssetId)
{ {
QSBNetworkIdentity component = prefab.GetComponent<QSBNetworkIdentity>(); var component = prefab.GetComponent<QSBNetworkIdentity>();
if (component) if (component)
{ {
component.SetDynamicAssetId(newAssetId); component.SetDynamicAssetId(newAssetId);
@ -121,11 +121,11 @@ namespace QuantumUNET
internal static void RegisterPrefab(GameObject prefab) internal static void RegisterPrefab(GameObject prefab)
{ {
QSBNetworkIdentity component = prefab.GetComponent<QSBNetworkIdentity>(); var component = prefab.GetComponent<QSBNetworkIdentity>();
if (component) if (component)
{ {
guidToPrefab[component.AssetId] = prefab; guidToPrefab[component.AssetId] = prefab;
NetworkIdentity[] componentsInChildren = prefab.GetComponentsInChildren<NetworkIdentity>(); var componentsInChildren = prefab.GetComponentsInChildren<NetworkIdentity>();
if (componentsInChildren.Length > 1) if (componentsInChildren.Length > 1)
{ {
if (LogFilter.logWarn) if (LogFilter.logWarn)
@ -192,7 +192,7 @@ namespace QuantumUNET
internal static void UnregisterPrefab(GameObject prefab) internal static void UnregisterPrefab(GameObject prefab)
{ {
QSBNetworkIdentity component = prefab.GetComponent<QSBNetworkIdentity>(); var component = prefab.GetComponent<QSBNetworkIdentity>();
if (component == null) if (component == null)
{ {
if (LogFilter.logError) if (LogFilter.logError)
@ -209,7 +209,7 @@ namespace QuantumUNET
internal static void RegisterPrefab(GameObject prefab, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) internal static void RegisterPrefab(GameObject prefab, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler)
{ {
QSBNetworkIdentity component = prefab.GetComponent<QSBNetworkIdentity>(); var component = prefab.GetComponent<QSBNetworkIdentity>();
if (component == null) if (component == null)
{ {
Debug.LogError("Could not register '" + prefab.name + "' since it contains no NetworkIdentity component"); Debug.LogError("Could not register '" + prefab.name + "' since it contains no NetworkIdentity component");
@ -250,7 +250,7 @@ namespace QuantumUNET
bool result; bool result;
if (unspawnHandlers.ContainsKey(assetId) && unspawnHandlers[assetId] != null) if (unspawnHandlers.ContainsKey(assetId) && unspawnHandlers[assetId] != null)
{ {
UnSpawnDelegate unSpawnDelegate = unspawnHandlers[assetId]; var unSpawnDelegate = unspawnHandlers[assetId];
unSpawnDelegate(obj); unSpawnDelegate(obj);
result = true; result = true;
} }
@ -263,9 +263,9 @@ namespace QuantumUNET
internal void DestroyAllClientObjects() internal void DestroyAllClientObjects()
{ {
foreach (NetworkInstanceId key in this.localObjects.Keys) foreach (var key in localObjects.Keys)
{ {
QSBNetworkIdentity networkIdentity = this.localObjects[key]; var networkIdentity = localObjects[key];
if (networkIdentity != null && networkIdentity.gameObject != null) if (networkIdentity != null && networkIdentity.gameObject != null)
{ {
if (!InvokeUnSpawnHandler(networkIdentity.AssetId, networkIdentity.gameObject)) if (!InvokeUnSpawnHandler(networkIdentity.AssetId, networkIdentity.gameObject))
@ -282,14 +282,14 @@ namespace QuantumUNET
} }
} }
} }
this.ClearLocalObjects(); ClearLocalObjects();
} }
internal void DumpAllClientObjects() internal void DumpAllClientObjects()
{ {
foreach (NetworkInstanceId networkInstanceId in this.localObjects.Keys) foreach (var networkInstanceId in localObjects.Keys)
{ {
QSBNetworkIdentity networkIdentity = this.localObjects[networkInstanceId]; var networkIdentity = localObjects[networkInstanceId];
if (networkIdentity != null) if (networkIdentity != null)
{ {
Debug.Log(string.Concat(new object[] Debug.Log(string.Concat(new object[]

View File

@ -75,29 +75,7 @@ namespace QuantumUNET
} }
} }
[Obsolete("Moved to NetworkMigrationManager")] public static bool dontListen { get; set; }
public static bool sendPeerInfo
{
get
{
return false;
}
set
{
}
}
public static bool dontListen
{
get
{
return m_DontListen;
}
set
{
m_DontListen = value;
}
}
public static bool useWebSockets public static bool useWebSockets
{ {
@ -130,13 +108,7 @@ namespace QuantumUNET
} }
} }
public static bool active public static bool active { get; private set; }
{
get
{
return s_Active;
}
}
public static bool localClientActive public static bool localClientActive
{ {
@ -194,7 +166,7 @@ namespace QuantumUNET
NetworkTransport.Shutdown(); NetworkTransport.Shutdown();
NetworkTransport.Init(); NetworkTransport.Init();
s_Instance = null; s_Instance = null;
s_Active = false; active = false;
} }
public static void Shutdown() public static void Shutdown()
@ -202,14 +174,14 @@ namespace QuantumUNET
if (s_Instance != null) if (s_Instance != null)
{ {
s_Instance.InternalDisconnectAll(); s_Instance.InternalDisconnectAll();
if (!m_DontListen) if (!dontListen)
{ {
s_Instance.m_SimpleServerSimple.Stop(); s_Instance.m_SimpleServerSimple.Stop();
} }
s_Instance = null; s_Instance = null;
} }
m_DontListen = false; dontListen = false;
s_Active = false; active = false;
} }
internal void RegisterMessageHandlers() internal void RegisterMessageHandlers()
@ -233,7 +205,7 @@ namespace QuantumUNET
private void InternalListenRelay(string relayIp, int relayPort, NetworkID netGuid, SourceID sourceId, NodeID nodeId) private void InternalListenRelay(string relayIp, int relayPort, NetworkID netGuid, SourceID sourceId, NodeID nodeId)
{ {
m_SimpleServerSimple.ListenRelay(relayIp, relayPort, netGuid, sourceId, nodeId); m_SimpleServerSimple.ListenRelay(relayIp, relayPort, netGuid, sourceId, nodeId);
s_Active = true; active = true;
RegisterMessageHandlers(); RegisterMessageHandlers();
} }
@ -249,7 +221,7 @@ namespace QuantumUNET
internal bool InternalListen(string ipAddress, int serverPort) internal bool InternalListen(string ipAddress, int serverPort)
{ {
if (m_DontListen) if (dontListen)
{ {
m_SimpleServerSimple.Initialize(); m_SimpleServerSimple.Initialize();
} }
@ -258,7 +230,7 @@ namespace QuantumUNET
return false; return false;
} }
maxPacketSize = hostTopology.DefaultConfig.PacketSize; maxPacketSize = hostTopology.DefaultConfig.PacketSize;
s_Active = true; active = true;
RegisterMessageHandlers(); RegisterMessageHandlers();
return true; return true;
} }
@ -271,7 +243,7 @@ namespace QuantumUNET
internal QSBNetworkClient BecomeHostInternal(QSBNetworkClient oldClient, int port, int oldConnectionId, QSBPeerInfoMessage[] peers) internal QSBNetworkClient BecomeHostInternal(QSBNetworkClient oldClient, int port, int oldConnectionId, QSBPeerInfoMessage[] peers)
{ {
QSBNetworkClient result; QSBNetworkClient result;
if (s_Active) if (active)
{ {
if (LogFilter.logError) if (LogFilter.logError)
{ {
@ -741,7 +713,7 @@ namespace QuantumUNET
internal void InternalUpdate() internal void InternalUpdate()
{ {
m_SimpleServerSimple.Update(); m_SimpleServerSimple.Update();
if (m_DontListen) if (dontListen)
{ {
m_SimpleServerSimple.UpdateConnections(); m_SimpleServerSimple.UpdateConnections();
} }
@ -1916,19 +1888,10 @@ namespace QuantumUNET
} }
} }
[Obsolete("moved to NetworkMigrationManager")]
public void SendNetworkInfo(NetworkConnection targetConnection)
{
}
private static bool s_Active;
private static volatile QSBNetworkServer s_Instance; private static volatile QSBNetworkServer s_Instance;
private static object s_Sync = new UnityEngine.Object(); private static object s_Sync = new UnityEngine.Object();
private static bool m_DontListen;
private bool m_LocalClientActive; private bool m_LocalClientActive;
private List<QSBNetworkConnection> m_LocalConnectionsFakeList = new List<QSBNetworkConnection>(); private List<QSBNetworkConnection> m_LocalConnectionsFakeList = new List<QSBNetworkConnection>();