mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-04-15 20:42:33 +00:00
fix in qnet
This commit is contained in:
parent
a0286c3c74
commit
2ea7c56ce3
@ -51,11 +51,13 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckSendRate();
|
||||
if (!CheckAnimStateChanged(out var stateHash, out var normalizedTime))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var animationMessage = new QAnimationMessage
|
||||
{
|
||||
netId = NetId,
|
||||
@ -77,6 +79,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QNetworkServer.SendToReady(gameObject, 40, animationMessage);
|
||||
}
|
||||
}
|
||||
@ -92,20 +95,24 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_TransitionHash = animatorTransitionInfo.fullPathHash;
|
||||
m_AnimationHash = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
var animatorStateInfo = m_Animator.GetCurrentAnimatorStateInfo(0);
|
||||
if (animatorStateInfo.fullPathHash == m_AnimationHash)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_AnimationHash != 0)
|
||||
{
|
||||
stateHash = animatorStateInfo.fullPathHash;
|
||||
normalizedTime = animatorStateInfo.normalizedTime;
|
||||
}
|
||||
|
||||
m_TransitionHash = 0;
|
||||
m_AnimationHash = animatorStateInfo.fullPathHash;
|
||||
return true;
|
||||
@ -117,6 +124,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_SendTimer = Time.time + GetNetworkSendInterval();
|
||||
var parametersMessage = new QAnimationParametersMessage
|
||||
{
|
||||
@ -146,10 +154,12 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.stateHash != 0)
|
||||
{
|
||||
m_Animator.Play(msg.stateHash, 0, msg.normalizedTime);
|
||||
}
|
||||
|
||||
ReadParameters(reader, false);
|
||||
}
|
||||
|
||||
@ -159,6 +169,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ReadParameters(reader, true);
|
||||
}
|
||||
|
||||
@ -200,6 +211,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (parameter.type)
|
||||
{
|
||||
case AnimatorControllerParameterType.Int:
|
||||
@ -227,6 +239,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_Animator.IsInTransition(0))
|
||||
{
|
||||
var animatorStateInfo = m_Animator.GetNextAnimatorStateInfo(0);
|
||||
@ -239,6 +252,7 @@ namespace QuantumUNET.Components
|
||||
writer.Write(animatorStateInfo.fullPathHash);
|
||||
writer.Write(animatorStateInfo.normalizedTime);
|
||||
}
|
||||
|
||||
WriteParameters(writer, false);
|
||||
return true;
|
||||
}
|
||||
@ -249,6 +263,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var stateNameHash = reader.ReadInt32();
|
||||
var normalizedTime = reader.ReadSingle();
|
||||
ReadParameters(reader, false);
|
||||
@ -270,11 +285,13 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var readyConnection = QClientScene.readyConnection;
|
||||
if (readyConnection == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
readyConnection.Send(42, animationTriggerMessage);
|
||||
}
|
||||
else
|
||||
@ -283,6 +300,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QNetworkServer.SendToReady(gameObject, 42, animationTriggerMessage);
|
||||
}
|
||||
}
|
||||
@ -295,6 +313,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var component = localObject.GetComponent<QNetworkAnimator>();
|
||||
var reader = new QNetworkReader(AnimationMessage.parameters);
|
||||
component?.HandleAnimMsg(AnimationMessage, reader);
|
||||
@ -309,6 +328,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var component = localObject.GetComponent<QNetworkAnimator>();
|
||||
var reader = new QNetworkReader(ParametersMessage.parameters);
|
||||
component?.HandleAnimParamsMsg(ParametersMessage, reader);
|
||||
@ -323,6 +343,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var component = localObject.GetComponent<QNetworkAnimator>();
|
||||
component?.HandleAnimTriggerMsg(TriggersMessage.hash);
|
||||
QNetworkServer.SendToReady(localObject, 42, TriggersMessage);
|
||||
|
@ -46,6 +46,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
RootIdentity.RemoveSubIdentity(this);
|
||||
}
|
||||
|
||||
RootIdentity = newRoot;
|
||||
RootIdentity.AddSubIndentity(this);
|
||||
}
|
||||
@ -74,6 +75,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
QLog.Error("SetClientOwner m_ClientAuthorityOwner already set!");
|
||||
}
|
||||
|
||||
ClientAuthorityOwner = conn;
|
||||
ClientAuthorityOwner.AddOwnedObject(this);
|
||||
}
|
||||
@ -109,6 +111,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
result = new ReadOnlyCollection<QNetworkConnection>(m_Observers);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -192,6 +195,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
HasAuthority = true;
|
||||
}
|
||||
|
||||
m_Observers = new List<QNetworkConnection>();
|
||||
m_ObserverConnections = new HashSet<int>();
|
||||
CacheBehaviours();
|
||||
@ -204,6 +208,7 @@ namespace QuantumUNET.Components
|
||||
QLog.Warning($"Object has non-zero netId {NetId} for {gameObject}");
|
||||
return;
|
||||
}
|
||||
|
||||
QNetworkServer.instance.SetLocalObjectOnServer(NetId, gameObject);
|
||||
foreach (var networkBehaviour in m_NetworkBehaviours)
|
||||
{
|
||||
@ -216,11 +221,13 @@ namespace QuantumUNET.Components
|
||||
QLog.FatalError($"Exception in OnStartServer:{ex.Message} {ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
if (QNetworkClient.active && QNetworkServer.localClientActive)
|
||||
{
|
||||
QClientScene.SetLocalObject(NetId, gameObject);
|
||||
OnStartClient();
|
||||
}
|
||||
|
||||
if (HasAuthority)
|
||||
{
|
||||
OnStartAuthority();
|
||||
@ -234,6 +241,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
IsClient = true;
|
||||
}
|
||||
|
||||
CacheBehaviours();
|
||||
QLog.Debug($"OnStartClient {gameObject} GUID:{NetId} localPlayerAuthority:{LocalPlayerAuthority}");
|
||||
foreach (var networkBehaviour in m_NetworkBehaviours)
|
||||
@ -346,6 +354,7 @@ namespace QuantumUNET.Components
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool result;
|
||||
if (networkBehaviour == null)
|
||||
{
|
||||
@ -360,6 +369,7 @@ namespace QuantumUNET.Components
|
||||
invokeComponent = networkBehaviour;
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -470,6 +480,7 @@ namespace QuantumUNET.Components
|
||||
num |= 1U << dirtyChannel;
|
||||
}
|
||||
}
|
||||
|
||||
if (num != 0U)
|
||||
{
|
||||
var j = 0;
|
||||
@ -494,6 +505,7 @@ namespace QuantumUNET.Components
|
||||
networkBehaviour.ClearAllDirtyBits();
|
||||
flag = true;
|
||||
}
|
||||
|
||||
var maxPacketSize = QNetworkServer.maxPacketSize;
|
||||
if (s_UpdateWriter.Position - position > maxPacketSize)
|
||||
{
|
||||
@ -502,12 +514,14 @@ namespace QuantumUNET.Components
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
s_UpdateWriter.FinishMessage();
|
||||
QNetworkServer.SendWriterToReady(gameObject, s_UpdateWriter, j);
|
||||
}
|
||||
}
|
||||
|
||||
j++;
|
||||
}
|
||||
}
|
||||
@ -535,6 +549,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
HasAuthority = true;
|
||||
}
|
||||
|
||||
foreach (var networkBehaviour in m_NetworkBehaviours)
|
||||
{
|
||||
networkBehaviour.OnStartLocalPlayer();
|
||||
@ -562,6 +577,7 @@ namespace QuantumUNET.Components
|
||||
networkBehaviour.OnNetworkDestroy();
|
||||
num++;
|
||||
}
|
||||
|
||||
m_IsServer = false;
|
||||
}
|
||||
|
||||
@ -575,6 +591,7 @@ namespace QuantumUNET.Components
|
||||
var networkConnection = m_Observers[i];
|
||||
networkConnection.RemoveFromVisList(this, true);
|
||||
}
|
||||
|
||||
m_Observers.Clear();
|
||||
m_ObserverConnections.Clear();
|
||||
}
|
||||
@ -621,6 +638,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
flag2 |= networkBehaviour.OnRebuildObservers(hashSet, initialize);
|
||||
}
|
||||
|
||||
if (!flag2)
|
||||
{
|
||||
if (initialize)
|
||||
@ -666,6 +684,7 @@ namespace QuantumUNET.Components
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var networkConnection4 in hashSet2)
|
||||
{
|
||||
if (!hashSet.Contains(networkConnection4))
|
||||
@ -675,6 +694,7 @@ namespace QuantumUNET.Components
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (initialize)
|
||||
{
|
||||
foreach (var connection in QNetworkServer.localConnections)
|
||||
@ -685,6 +705,7 @@ namespace QuantumUNET.Components
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
m_Observers = new List<QNetworkConnection>(hashSet);
|
||||
@ -720,6 +741,7 @@ namespace QuantumUNET.Components
|
||||
QLog.Warning($"RemoveClientAuthority for {gameObject} has different owner.");
|
||||
return false;
|
||||
}
|
||||
|
||||
ClientAuthorityOwner.RemoveOwnedObject(this);
|
||||
ClientAuthorityOwner = null;
|
||||
ForceAuthority(true);
|
||||
@ -754,6 +776,7 @@ namespace QuantumUNET.Components
|
||||
QLog.Warning($"AssignClientAuthority for {gameObject} owner cannot be null. Use RemoveClientAuthority() instead.");
|
||||
return false;
|
||||
}
|
||||
|
||||
ClientAuthorityOwner = conn;
|
||||
ClientAuthorityOwner.AddOwnedObject(this);
|
||||
|
||||
|
@ -57,6 +57,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
m_ConnectionConfig = new ConnectionConfig();
|
||||
}
|
||||
|
||||
return m_ConnectionConfig;
|
||||
}
|
||||
}
|
||||
@ -69,6 +70,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
m_GlobalConfig = new GlobalConfig();
|
||||
}
|
||||
|
||||
return m_GlobalConfig;
|
||||
}
|
||||
}
|
||||
@ -91,6 +93,7 @@ namespace QuantumUNET.Components
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
}
|
||||
@ -109,6 +112,7 @@ namespace QuantumUNET.Components
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
QLog.Log("NetworkManager created singleton (DontDestroyOnLoad)");
|
||||
singleton = this;
|
||||
if (Application.isPlaying)
|
||||
@ -121,6 +125,7 @@ namespace QuantumUNET.Components
|
||||
QLog.Log("NetworkManager created singleton (ForScene)");
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
if (networkAddress != "")
|
||||
{
|
||||
s_Address = networkAddress;
|
||||
@ -152,12 +157,14 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
Application.runInBackground = true;
|
||||
}
|
||||
|
||||
QNetworkCRC.scriptCRCCheck = scriptCRCCheck;
|
||||
QNetworkServer.useWebSockets = useWebSockets;
|
||||
if (m_GlobalConfig != null)
|
||||
{
|
||||
NetworkTransport.Init(m_GlobalConfig);
|
||||
}
|
||||
|
||||
if (customConfig && m_ConnectionConfig != null && config == null)
|
||||
{
|
||||
m_ConnectionConfig.Channels.Clear();
|
||||
@ -165,12 +172,15 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
m_ConnectionConfig.AddChannel(channel);
|
||||
}
|
||||
|
||||
QNetworkServer.Configure(m_ConnectionConfig, this.maxConnections);
|
||||
}
|
||||
|
||||
if (config != null)
|
||||
{
|
||||
QNetworkServer.Configure(config, maxConnections);
|
||||
}
|
||||
|
||||
if (serverBindToIP && !string.IsNullOrEmpty(serverBindAddress))
|
||||
{
|
||||
if (!QNetworkServer.Listen(serverBindAddress, networkPort))
|
||||
@ -184,6 +194,7 @@ namespace QuantumUNET.Components
|
||||
QLog.FatalError("StartServer listen failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
RegisterServerMessages();
|
||||
QLog.Log($"NetworkManager StartServer port:{networkPort}");
|
||||
isNetworkActive = true;
|
||||
@ -196,6 +207,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
QNetworkServer.SpawnObjects();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -210,6 +222,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
QClientScene.RegisterPrefab(playerPrefab);
|
||||
}
|
||||
|
||||
foreach (var gameObject in spawnPrefabs)
|
||||
{
|
||||
if (gameObject != null)
|
||||
@ -225,6 +238,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
Application.runInBackground = true;
|
||||
}
|
||||
|
||||
if (externalClient != null)
|
||||
{
|
||||
client = externalClient;
|
||||
@ -243,6 +257,7 @@ namespace QuantumUNET.Components
|
||||
ClientChangeScene(offlineScene, false);
|
||||
}
|
||||
}
|
||||
|
||||
s_Address = networkAddress;
|
||||
}
|
||||
|
||||
@ -253,11 +268,13 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
Application.runInBackground = true;
|
||||
}
|
||||
|
||||
isNetworkActive = true;
|
||||
if (m_GlobalConfig != null)
|
||||
{
|
||||
NetworkTransport.Init(m_GlobalConfig);
|
||||
}
|
||||
|
||||
client = new QNetworkClient
|
||||
{
|
||||
hostPort = hostPort
|
||||
@ -268,6 +285,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("Platform specific protocols are not supported on this platform");
|
||||
}
|
||||
|
||||
client.Configure(config, 1);
|
||||
}
|
||||
else if (customConfig && m_ConnectionConfig != null)
|
||||
@ -277,18 +295,22 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
m_ConnectionConfig.AddChannel(channel);
|
||||
}
|
||||
|
||||
if (m_ConnectionConfig.UsePlatformSpecificProtocols && Application.platform != RuntimePlatform.PS4 && Application.platform != RuntimePlatform.PSP2)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("Platform specific protocols are not supported on this platform");
|
||||
}
|
||||
|
||||
client.Configure(m_ConnectionConfig, maxConnections);
|
||||
}
|
||||
|
||||
RegisterClientMessages(client);
|
||||
if (string.IsNullOrEmpty(networkAddress))
|
||||
{
|
||||
QLog.Error("Must set the Network Address field in the manager");
|
||||
return null;
|
||||
}
|
||||
|
||||
client.Connect(networkAddress, networkPort);
|
||||
OnStartClient(client);
|
||||
s_Address = networkAddress;
|
||||
@ -314,6 +336,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -331,6 +354,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -362,6 +386,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
ServerChangeScene(offlineScene);
|
||||
}
|
||||
|
||||
CleanupNetworkIdentities();
|
||||
}
|
||||
}
|
||||
@ -377,11 +402,13 @@ namespace QuantumUNET.Components
|
||||
client.Shutdown();
|
||||
client = null;
|
||||
}
|
||||
|
||||
QClientScene.DestroyAllClientObjects();
|
||||
if (!string.IsNullOrEmpty(offlineScene))
|
||||
{
|
||||
ClientChangeScene(offlineScene, false);
|
||||
}
|
||||
|
||||
CleanupNetworkIdentities();
|
||||
}
|
||||
|
||||
@ -427,6 +454,7 @@ namespace QuantumUNET.Components
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
s_LoadingSceneAsync = SceneManager.LoadSceneAsync(newSceneName);
|
||||
networkSceneName = newSceneName;
|
||||
}
|
||||
@ -447,11 +475,13 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
QLog.Error("FinishLoadScene client is null");
|
||||
}
|
||||
|
||||
if (QNetworkServer.active)
|
||||
{
|
||||
QNetworkServer.SpawnObjects();
|
||||
OnServerSceneChanged(networkSceneName);
|
||||
}
|
||||
|
||||
if (IsClientConnected() && client != null)
|
||||
{
|
||||
RegisterClientMessages(client);
|
||||
@ -499,6 +529,7 @@ namespace QuantumUNET.Components
|
||||
netMsg.Connection.SetChannelOption(i, ChannelOption.MaxPendingBuffers, m_MaxBufferedPackets);
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_AllowFragmentation)
|
||||
{
|
||||
for (var j = 0; j < QNetworkServer.numChannels; j++)
|
||||
@ -506,11 +537,13 @@ namespace QuantumUNET.Components
|
||||
netMsg.Connection.SetChannelOption(j, ChannelOption.AllowFragmentation, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (networkSceneName != "" && networkSceneName != offlineScene)
|
||||
{
|
||||
var msg = new QStringMessage(networkSceneName);
|
||||
netMsg.Connection.Send(39, msg);
|
||||
}
|
||||
|
||||
OnServerConnect(netMsg.Connection);
|
||||
}
|
||||
|
||||
@ -580,6 +613,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
ClientChangeScene(offlineScene, false);
|
||||
}
|
||||
|
||||
OnClientDisconnect(netMsg.Connection);
|
||||
}
|
||||
|
||||
@ -626,6 +660,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
QLog.Warning("Ready with no player object");
|
||||
}
|
||||
|
||||
QNetworkServer.SetClientReady(conn);
|
||||
}
|
||||
|
||||
@ -714,10 +749,12 @@ namespace QuantumUNET.Components
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag2)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
QClientScene.AddPlayer(0);
|
||||
|
@ -27,12 +27,15 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
Manager.StartHost();
|
||||
}
|
||||
|
||||
yOffset += 20;
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(xOffset, yOffset, 105f, 20f), "Connect"))
|
||||
{
|
||||
Manager.StartClient();
|
||||
}
|
||||
|
||||
Manager.networkAddress = GUI.TextField(new Rect(xOffset + 100, yOffset, 95f, 20f), Manager.networkAddress);
|
||||
yOffset += 20;
|
||||
}
|
||||
@ -56,15 +59,18 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
text += " (using WebSockets)";
|
||||
}
|
||||
|
||||
GUI.Label(new Rect(xOffset, yOffset, 300f, 20f), text);
|
||||
yOffset += 20;
|
||||
}
|
||||
|
||||
if (Manager.IsClientConnected())
|
||||
{
|
||||
GUI.Label(new Rect(xOffset, yOffset, 300f, 20f), $"Connected to {Manager.networkAddress}, port {Manager.networkPort}");
|
||||
yOffset += 20;
|
||||
}
|
||||
}
|
||||
|
||||
if (Manager.IsClientConnected() && !QClientScene.ready)
|
||||
{
|
||||
if (GUI.Button(new Rect(xOffset, yOffset, 200f, 20f), "Client Ready"))
|
||||
@ -75,14 +81,17 @@ namespace QuantumUNET.Components
|
||||
QClientScene.AddPlayer(0);
|
||||
}
|
||||
}
|
||||
|
||||
yOffset += 20;
|
||||
}
|
||||
|
||||
if (QNetworkServer.active || Manager.IsClientConnected())
|
||||
{
|
||||
if (GUI.Button(new Rect(xOffset, yOffset, 200f, 20f), "Stop"))
|
||||
{
|
||||
Manager.StopHost();
|
||||
}
|
||||
|
||||
yOffset += 20;
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,10 @@ namespace QuantumUNET.Components
|
||||
writer.WritePackedUInt32(0U);
|
||||
return false;
|
||||
}
|
||||
|
||||
writer.WritePackedUInt32(1U);
|
||||
}
|
||||
|
||||
SerializeTransform(writer);
|
||||
return true;
|
||||
}
|
||||
@ -51,6 +53,7 @@ namespace QuantumUNET.Components
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DeserializeTransform(reader);
|
||||
}
|
||||
}
|
||||
@ -71,6 +74,7 @@ namespace QuantumUNET.Components
|
||||
DeserializeRotation(reader);
|
||||
return;
|
||||
}
|
||||
|
||||
transform.position = reader.ReadVector3();
|
||||
transform.rotation = DeserializeRotation(reader);
|
||||
}
|
||||
|
@ -63,8 +63,10 @@ namespace QuantumUNET.Components
|
||||
writer.WritePackedUInt32(0U);
|
||||
return false;
|
||||
}
|
||||
|
||||
writer.WritePackedUInt32(1U);
|
||||
}
|
||||
|
||||
SerializeModeTransform(writer);
|
||||
return true;
|
||||
}
|
||||
@ -88,6 +90,7 @@ namespace QuantumUNET.Components
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UnserializeModeTransform(reader, initialState);
|
||||
LastSyncTime = Time.time;
|
||||
}
|
||||
@ -115,6 +118,7 @@ namespace QuantumUNET.Components
|
||||
{
|
||||
FixedUpdateServer();
|
||||
}
|
||||
|
||||
if (IsClient)
|
||||
{
|
||||
FixedUpdateClient();
|
||||
@ -141,6 +145,7 @@ namespace QuantumUNET.Components
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SetDirtyBit(1U);
|
||||
}
|
||||
}
|
||||
@ -208,6 +213,7 @@ namespace QuantumUNET.Components
|
||||
num = Quaternion.Angle(m_Target.localRotation, m_PrevRotation);
|
||||
result = num > 1E-05f;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UnityEngine.Debug.Log($"DEBUG : {message}");
|
||||
}
|
||||
|
||||
@ -33,6 +34,7 @@
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UnityEngine.Debug.Log($"LOG : {message}");
|
||||
}
|
||||
|
||||
@ -42,6 +44,7 @@
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UnityEngine.Debug.LogWarning($"WARN : {message}");
|
||||
}
|
||||
|
||||
@ -51,6 +54,7 @@
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UnityEngine.Debug.LogError($"ERROR : {message}");
|
||||
}
|
||||
|
||||
@ -60,6 +64,7 @@
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UnityEngine.Debug.LogError($"FATAL : {message}");
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,10 @@
|
||||
{
|
||||
text = $"[{value}]";
|
||||
}
|
||||
|
||||
result = text;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,7 @@ namespace QuantumUNET
|
||||
player = localPlayers[playerControllerId];
|
||||
result = player.Gameobject != null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -73,6 +74,7 @@ namespace QuantumUNET
|
||||
localPlayers.Add(new QPlayerController());
|
||||
}
|
||||
}
|
||||
|
||||
var playerController = new QPlayerController
|
||||
{
|
||||
Gameobject = view.gameObject,
|
||||
@ -106,10 +108,12 @@ namespace QuantumUNET
|
||||
{
|
||||
Debug.LogWarning($"ClientScene::AddPlayer: playerControllerId of {playerControllerId} is unusually high");
|
||||
}
|
||||
|
||||
while (playerControllerId >= localPlayers.Count)
|
||||
{
|
||||
localPlayers.Add(new QPlayerController());
|
||||
}
|
||||
|
||||
if (readyConn == null)
|
||||
{
|
||||
if (!ready)
|
||||
@ -123,6 +127,7 @@ namespace QuantumUNET
|
||||
ready = true;
|
||||
readyConnection = readyConn;
|
||||
}
|
||||
|
||||
if (readyConnection.GetPlayerController(playerControllerId, out var playerController))
|
||||
{
|
||||
if (playerController.IsValid && playerController.Gameobject != null)
|
||||
@ -131,6 +136,7 @@ namespace QuantumUNET
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"ClientScene::AddPlayer() for ID {playerControllerId} called with connection [{readyConnection}]");
|
||||
var addPlayerMessage = new QAddPlayerMessage
|
||||
{
|
||||
@ -143,9 +149,11 @@ namespace QuantumUNET
|
||||
addPlayerMessage.msgData = networkWriter.ToArray();
|
||||
addPlayerMessage.msgSize = networkWriter.Position;
|
||||
}
|
||||
|
||||
readyConnection.Send(37, addPlayerMessage);
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -170,6 +178,7 @@ namespace QuantumUNET
|
||||
Debug.LogError($"Failed to find player ID {playerControllerId}");
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -199,6 +208,7 @@ namespace QuantumUNET
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -261,6 +271,7 @@ namespace QuantumUNET
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -288,6 +299,7 @@ namespace QuantumUNET
|
||||
client.RegisterHandlerSafe(QMsgType.Animation, QNetworkAnimator.OnAnimationClientMessage);
|
||||
client.RegisterHandlerSafe(QMsgType.AnimationParameters, QNetworkAnimator.OnAnimationParametersClientMessage);
|
||||
}
|
||||
|
||||
client.RegisterHandlerSafe(QMsgType.Rpc, OnRPCMessage);
|
||||
client.RegisterHandlerSafe(QMsgType.SyncEvent, OnSyncEventMessage);
|
||||
client.RegisterHandlerSafe(QMsgType.AnimationTrigger, QNetworkAnimator.OnAnimationTriggerClientMessage);
|
||||
@ -331,12 +343,14 @@ namespace QuantumUNET
|
||||
{
|
||||
uv.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
uv.transform.position = position;
|
||||
if (payload != null && payload.Length > 0)
|
||||
{
|
||||
var reader = new QNetworkReader(payload);
|
||||
uv.OnUpdateVars(reader, true);
|
||||
}
|
||||
|
||||
if (newGameObject != null)
|
||||
{
|
||||
newGameObject.SetActive(true);
|
||||
@ -448,6 +462,7 @@ namespace QuantumUNET
|
||||
CheckForOwner(networkIdentity);
|
||||
}
|
||||
}
|
||||
|
||||
s_IsSpawnFinished = true;
|
||||
}
|
||||
}
|
||||
@ -471,6 +486,7 @@ namespace QuantumUNET
|
||||
SpawnableObjects[networkIdentity.SceneId] = networkIdentity;
|
||||
}
|
||||
}
|
||||
|
||||
s_NetworkScene.RemoveLocalObject(s_ObjectDestroyMessage.NetId);
|
||||
networkIdentity.MarkForReset();
|
||||
}
|
||||
@ -594,6 +610,7 @@ namespace QuantumUNET
|
||||
{
|
||||
playerController.UnetView.SetNotLocalPlayer();
|
||||
}
|
||||
|
||||
if (s_NetworkScene.GetNetworkIdentity(s_OwnerMessage.NetId, out var networkIdentity))
|
||||
{
|
||||
networkIdentity.SetConnectionToServer(netMsg.Connection);
|
||||
@ -627,6 +644,7 @@ namespace QuantumUNET
|
||||
Debug.LogError("Owner message received on a local client.");
|
||||
break;
|
||||
}
|
||||
|
||||
InternalAddPlayer(uv, pendingOwner.playerControllerId);
|
||||
s_PendingOwnerIds.RemoveAt(i);
|
||||
break;
|
||||
|
@ -15,6 +15,7 @@ namespace QuantumUNET
|
||||
PostInternalMessage(33);
|
||||
m_Connected = false;
|
||||
}
|
||||
|
||||
m_AsyncConnect = ConnectState.Disconnected;
|
||||
m_LocalServer.RemoveLocalClient(m_Connection);
|
||||
}
|
||||
@ -30,6 +31,7 @@ namespace QuantumUNET
|
||||
m_FreeMessages.Push(t);
|
||||
}
|
||||
}
|
||||
|
||||
m_LocalServer = QNetworkServer.instance;
|
||||
m_Connection = new QULocalConnectionToServer(m_LocalServer);
|
||||
SetHandlers(m_Connection);
|
||||
@ -41,6 +43,7 @@ namespace QuantumUNET
|
||||
{
|
||||
PostInternalMessage(32);
|
||||
}
|
||||
|
||||
m_Connected = true;
|
||||
}
|
||||
|
||||
@ -57,6 +60,7 @@ namespace QuantumUNET
|
||||
QClientScene.SetLocalObject(unetView.NetId, localPlayer.Gameobject);
|
||||
unetView.SetConnectionToServer(m_Connection);
|
||||
}
|
||||
|
||||
QClientScene.InternalAddPlayer(unetView, localPlayer.PlayerControllerId);
|
||||
}
|
||||
|
||||
@ -92,6 +96,7 @@ namespace QuantumUNET
|
||||
{
|
||||
s_InternalMessage.Reader.Replace(msg.buffer);
|
||||
}
|
||||
|
||||
s_InternalMessage.Reader.ReadInt16();
|
||||
s_InternalMessage.ChannelId = msg.channelId;
|
||||
s_InternalMessage.Connection = connection;
|
||||
@ -100,12 +105,14 @@ namespace QuantumUNET
|
||||
m_FreeMessages.Push(msg);
|
||||
connection.lastMessageTime = Time.time;
|
||||
}
|
||||
|
||||
m_InternalMsgs = internalMsgs;
|
||||
m_InternalMsgs.Clear();
|
||||
foreach (var msg in m_InternalMsgs2)
|
||||
{
|
||||
m_InternalMsgs.Add(msg);
|
||||
}
|
||||
|
||||
m_InternalMsgs2.Clear();
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ namespace QuantumUNET
|
||||
QLog.FatalError($"Trying to get QNetworkIdentity of a null gameobject?");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (m_MyView == null)
|
||||
{
|
||||
m_MyView = GetComponent<QNetworkIdentity>();
|
||||
@ -44,12 +45,14 @@ namespace QuantumUNET
|
||||
{
|
||||
QLog.FatalError($"There is no QNetworkIdentity on this object (name={name}). Please add one.");
|
||||
}
|
||||
|
||||
myView = m_MyView;
|
||||
}
|
||||
else
|
||||
{
|
||||
myView = m_MyView;
|
||||
}
|
||||
|
||||
return myView;
|
||||
}
|
||||
}
|
||||
@ -94,6 +97,7 @@ namespace QuantumUNET
|
||||
QLog.Warning("ClientRpc call on un-spawned object");
|
||||
return;
|
||||
}
|
||||
|
||||
writer.FinishMessage();
|
||||
QNetworkServer.SendWriterToReady(gameObject, writer, channelId);
|
||||
}
|
||||
@ -105,6 +109,7 @@ namespace QuantumUNET
|
||||
QLog.Warning("TargetRpc call on un-spawned object");
|
||||
return;
|
||||
}
|
||||
|
||||
writer.FinishMessage();
|
||||
conn.SendWriter(writer, channelId);
|
||||
}
|
||||
@ -118,6 +123,7 @@ namespace QuantumUNET
|
||||
QLog.Error($"Tried to send event {eventName} on channel {channelId} but QSBNetworkServer isn't active.");
|
||||
return;
|
||||
}
|
||||
|
||||
writer.FinishMessage();
|
||||
QNetworkServer.SendWriterToReady(gameObject, writer, channelId);
|
||||
}
|
||||
@ -194,6 +200,7 @@ namespace QuantumUNET
|
||||
var invoker = s_CmdHandlerDelegates[cmdHash];
|
||||
result = invoker.DebugString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -239,6 +246,7 @@ namespace QuantumUNET
|
||||
invokeFunction = invoker.invokeFunction;
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -277,10 +285,12 @@ namespace QuantumUNET
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
invoker.invokeFunction(this, reader);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -307,10 +317,12 @@ namespace QuantumUNET
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
invoker.invokeFunction(this, reader);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -334,6 +346,7 @@ namespace QuantumUNET
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -361,6 +374,7 @@ namespace QuantumUNET
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -376,6 +390,7 @@ namespace QuantumUNET
|
||||
var invoker = s_CmdHandlerDelegates[cmdHash];
|
||||
result = $"{invoker.invokeType}:{invoker.invokeFunction.GetMethodName()}";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -395,8 +410,10 @@ namespace QuantumUNET
|
||||
{
|
||||
text = text.Substring(prefix.Length);
|
||||
}
|
||||
|
||||
result = text;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -430,11 +447,13 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NetworkInstanceId networkInstanceId2 = default;
|
||||
if (gameObjectField != null)
|
||||
{
|
||||
networkInstanceId2 = gameObjectField.GetComponent<QNetworkIdentity>().NetId;
|
||||
}
|
||||
|
||||
if (networkInstanceId != networkInstanceId2)
|
||||
{
|
||||
QLog.Log(
|
||||
@ -489,6 +508,7 @@ namespace QuantumUNET
|
||||
return GetNetworkChannel();
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -498,6 +518,7 @@ namespace QuantumUNET
|
||||
{
|
||||
writer.WritePackedUInt32(0U);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ namespace QuantumUNET
|
||||
{
|
||||
s_Singleton = new QNetworkCRC();
|
||||
}
|
||||
|
||||
return s_Singleton;
|
||||
}
|
||||
}
|
||||
@ -68,6 +69,7 @@ namespace QuantumUNET
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (crcmessageEntry.channel >= numChannels)
|
||||
{
|
||||
Debug.LogError(
|
||||
@ -76,8 +78,10 @@ namespace QuantumUNET
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -87,6 +91,7 @@ namespace QuantumUNET
|
||||
{
|
||||
Debug.Log($"CRC Local Dump {text} : {scripts[text]}");
|
||||
}
|
||||
|
||||
foreach (var crcmessageEntry in remoteScripts)
|
||||
{
|
||||
Debug.Log($"CRC Remote Dump {crcmessageEntry.name} : {crcmessageEntry.channel}");
|
||||
|
@ -73,10 +73,12 @@ namespace QuantumUNET
|
||||
{
|
||||
throw new ArgumentException("Port must not be a negative number.");
|
||||
}
|
||||
|
||||
if (value > 65535)
|
||||
{
|
||||
throw new ArgumentException("Port must not be greater than 65535.");
|
||||
}
|
||||
|
||||
m_HostPort = value;
|
||||
}
|
||||
}
|
||||
@ -142,6 +144,7 @@ namespace QuantumUNET
|
||||
connectionConfig.UsePlatformSpecificProtocols = false;
|
||||
hostTopology = new HostTopology(connectionConfig, 8);
|
||||
}
|
||||
|
||||
hostId = NetworkTransport.AddHost(hostTopology, m_HostPort);
|
||||
}
|
||||
|
||||
@ -218,6 +221,7 @@ namespace QuantumUNET
|
||||
QLog.Error("NetworkClient Send with no connection");
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -241,6 +245,7 @@ namespace QuantumUNET
|
||||
QLog.Error("NetworkClient SendWriter with no connection");
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -264,6 +269,7 @@ namespace QuantumUNET
|
||||
QLog.Error("NetworkClient SendBytes with no connection");
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -287,6 +293,7 @@ namespace QuantumUNET
|
||||
QLog.Error("NetworkClient SendUnreliable with no connection");
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -310,6 +317,7 @@ namespace QuantumUNET
|
||||
QLog.Error("NetworkClient SendByChannel with no connection");
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -333,6 +341,7 @@ namespace QuantumUNET
|
||||
NetworkTransport.RemoveHost(hostId);
|
||||
hostId = -1;
|
||||
}
|
||||
|
||||
RemoveClient(this);
|
||||
if (allClients.Count == 0)
|
||||
{
|
||||
@ -359,6 +368,7 @@ namespace QuantumUNET
|
||||
m_AsyncConnect = ConnectState.Disconnected;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Connection != null)
|
||||
{
|
||||
if ((int)Time.time != m_StatResetTime)
|
||||
@ -367,6 +377,7 @@ namespace QuantumUNET
|
||||
m_StatResetTime = (int)Time.time;
|
||||
}
|
||||
}
|
||||
|
||||
var num = 0;
|
||||
byte b;
|
||||
for (; ; )
|
||||
@ -376,6 +387,7 @@ namespace QuantumUNET
|
||||
{
|
||||
m_Connection.LastError = (NetworkError)b;
|
||||
}
|
||||
|
||||
switch (networkEventType)
|
||||
{
|
||||
case NetworkEventType.DataEvent:
|
||||
@ -383,6 +395,7 @@ namespace QuantumUNET
|
||||
{
|
||||
goto Block_11;
|
||||
}
|
||||
|
||||
m_MsgReader.SeekZero();
|
||||
m_Connection.TransportReceive(m_MsgBuffer, numBytes, channelId);
|
||||
break;
|
||||
@ -393,6 +406,7 @@ namespace QuantumUNET
|
||||
{
|
||||
goto Block_10;
|
||||
}
|
||||
|
||||
m_AsyncConnect = ConnectState.Connected;
|
||||
m_Connection.InvokeHandlerNoData(32);
|
||||
break;
|
||||
@ -407,6 +421,7 @@ namespace QuantumUNET
|
||||
GenerateDisconnectError(b);
|
||||
}
|
||||
}
|
||||
|
||||
QClientScene.HandleClientDisconnect(m_Connection);
|
||||
m_Connection?.InvokeHandlerNoData(33);
|
||||
break;
|
||||
@ -418,19 +433,23 @@ namespace QuantumUNET
|
||||
QLog.Error($"Unknown network message type received: {networkEventType}");
|
||||
break;
|
||||
}
|
||||
|
||||
if (++num >= 500)
|
||||
{
|
||||
goto Block_17;
|
||||
}
|
||||
|
||||
if (hostId == -1)
|
||||
{
|
||||
goto Block_19;
|
||||
}
|
||||
|
||||
if (networkEventType == NetworkEventType.Nothing)
|
||||
{
|
||||
goto IL_2C6;
|
||||
}
|
||||
}
|
||||
|
||||
Block_10:
|
||||
GenerateConnectError(b);
|
||||
return;
|
||||
@ -559,6 +578,7 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
@ -587,6 +607,7 @@ namespace QuantumUNET
|
||||
{
|
||||
allClients[0].Shutdown();
|
||||
}
|
||||
|
||||
allClients = new List<QNetworkClient>();
|
||||
active = false;
|
||||
QClientScene.Shutdown();
|
||||
@ -598,6 +619,7 @@ namespace QuantumUNET
|
||||
{
|
||||
NetworkTransport.Init();
|
||||
}
|
||||
|
||||
active = state;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ namespace QuantumUNET
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("Platform specific protocols are not supported on this platform");
|
||||
}
|
||||
|
||||
m_Channels = new QChannelBuffer[channelCount];
|
||||
for (var i = 0; i < channelCount; i++)
|
||||
{
|
||||
@ -47,6 +48,7 @@ namespace QuantumUNET
|
||||
{
|
||||
bufferSize = hostTopology.DefaultConfig.FragmentSize * 128;
|
||||
}
|
||||
|
||||
m_Channels[i] = new QChannelBuffer(this, bufferSize, (byte)i, IsReliableQoS(channelQOS.QOS), IsSequencedQoS(channelQOS.QOS));
|
||||
}
|
||||
}
|
||||
@ -71,6 +73,7 @@ namespace QuantumUNET
|
||||
channel.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
m_Channels = null;
|
||||
if (ClientOwnedObjects != null)
|
||||
{
|
||||
@ -83,6 +86,7 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ClientOwnedObjects = null;
|
||||
m_Disposed = true;
|
||||
}
|
||||
@ -139,6 +143,7 @@ namespace QuantumUNET
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -155,6 +160,7 @@ namespace QuantumUNET
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -183,6 +189,7 @@ namespace QuantumUNET
|
||||
{
|
||||
PlayerControllers.Add(new QPlayerController());
|
||||
}
|
||||
|
||||
PlayerControllers[player.PlayerControllerId] = player;
|
||||
}
|
||||
|
||||
@ -196,6 +203,7 @@ namespace QuantumUNET
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QLog.Error($"RemovePlayer player at playerControllerId {playerControllerId} not found");
|
||||
}
|
||||
|
||||
@ -220,6 +228,7 @@ namespace QuantumUNET
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -275,6 +284,7 @@ namespace QuantumUNET
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QLog.Log(
|
||||
$"ConnectionSend con:{connectionId} bytes:{num} msgId:{num2} {stringBuilder}");
|
||||
}
|
||||
@ -297,6 +307,7 @@ namespace QuantumUNET
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -323,11 +334,13 @@ namespace QuantumUNET
|
||||
{
|
||||
networkMessageDelegate = m_MessageHandlersDict[num2];
|
||||
}
|
||||
|
||||
if (networkMessageDelegate == null)
|
||||
{
|
||||
QLog.Error($"Unknown message ID {num2} connId:{connectionId}");
|
||||
break;
|
||||
}
|
||||
|
||||
m_NetMsg.MsgType = num2;
|
||||
m_NetMsg.Reader = reader2;
|
||||
m_NetMsg.Connection = this;
|
||||
@ -387,6 +400,7 @@ namespace QuantumUNET
|
||||
{
|
||||
networkIdentity.RemoveObserverInternal(this);
|
||||
}
|
||||
|
||||
VisList.Clear();
|
||||
}
|
||||
|
||||
@ -400,6 +414,7 @@ namespace QuantumUNET
|
||||
{
|
||||
ClientOwnedObjects = new HashSet<NetworkInstanceId>();
|
||||
}
|
||||
|
||||
ClientOwnedObjects.Add(obj.NetId);
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ namespace QuantumUNET
|
||||
QLog.Log($"RegisterHandler replacing {msgType}");
|
||||
_msgHandlers.Remove(msgType);
|
||||
}
|
||||
|
||||
QLog.Debug($"RegisterHandler id:{msgType} handler:{handler.GetMethodName()}");
|
||||
_msgHandlers.Add(msgType, handler);
|
||||
}
|
||||
|
@ -34,11 +34,13 @@ namespace QuantumUNET
|
||||
{
|
||||
networkIdentity = localObjects[netId];
|
||||
}
|
||||
|
||||
if (networkIdentity == null)
|
||||
{
|
||||
networkIdentity = obj.GetComponent<QNetworkIdentity>();
|
||||
localObjects[netId] = networkIdentity;
|
||||
}
|
||||
|
||||
networkIdentity.UpdateClientServer(isClient, isServer);
|
||||
}
|
||||
}
|
||||
@ -53,6 +55,7 @@ namespace QuantumUNET
|
||||
return networkIdentity.gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -69,6 +72,7 @@ namespace QuantumUNET
|
||||
uv = null;
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -87,6 +91,7 @@ namespace QuantumUNET
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -143,6 +148,7 @@ namespace QuantumUNET
|
||||
prefab = null;
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -221,6 +227,7 @@ namespace QuantumUNET
|
||||
handler = null;
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -237,6 +244,7 @@ namespace QuantumUNET
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -261,6 +269,7 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ClearLocalObjects();
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,7 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s_Instance;
|
||||
}
|
||||
}
|
||||
@ -101,8 +102,10 @@ namespace QuantumUNET
|
||||
{
|
||||
s_Instance.m_SimpleServerSimple.Stop();
|
||||
}
|
||||
|
||||
s_Instance = null;
|
||||
}
|
||||
|
||||
dontListen = false;
|
||||
active = false;
|
||||
}
|
||||
@ -160,6 +163,7 @@ namespace QuantumUNET
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
maxPacketSize = hostTopology.DefaultConfig.PacketSize;
|
||||
active = true;
|
||||
RegisterMessageHandlers();
|
||||
@ -195,6 +199,7 @@ namespace QuantumUNET
|
||||
m_LocalConnection.InvokeHandlerNoData(32);
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -208,12 +213,14 @@ namespace QuantumUNET
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_LocalConnection != null)
|
||||
{
|
||||
m_LocalConnection.Disconnect();
|
||||
m_LocalConnection.Dispose();
|
||||
m_LocalConnection = null;
|
||||
}
|
||||
|
||||
m_LocalClientActive = false;
|
||||
m_SimpleServerSimple.RemoveConnectionAtIndex(0);
|
||||
}
|
||||
@ -252,6 +259,7 @@ namespace QuantumUNET
|
||||
flag &= networkConnection.Send(msgType, msg);
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
@ -273,8 +281,10 @@ namespace QuantumUNET
|
||||
var networkConnection = component.Observers[i];
|
||||
flag &= networkConnection.Send(msgType, msg);
|
||||
}
|
||||
|
||||
result = flag;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -313,9 +323,11 @@ namespace QuantumUNET
|
||||
flag &= networkConnection2.Send(msgType, msg);
|
||||
}
|
||||
}
|
||||
|
||||
result = flag;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -326,6 +338,7 @@ namespace QuantumUNET
|
||||
{
|
||||
throw new UnityException("NetworkWriter used buffer is too big!");
|
||||
}
|
||||
|
||||
SendBytesToReady(contextObj, arraySegment.Array, arraySegment.Count, channelId);
|
||||
}
|
||||
|
||||
@ -344,6 +357,7 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
QLog.Error("SendBytesToReady failed");
|
||||
@ -367,6 +381,7 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag2)
|
||||
{
|
||||
QLog.Error($"SendBytesToReady failed for {contextObj}");
|
||||
@ -408,6 +423,7 @@ namespace QuantumUNET
|
||||
flag &= networkConnection.SendUnreliable(msgType, msg);
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
@ -440,8 +456,10 @@ namespace QuantumUNET
|
||||
flag &= networkConnection2.SendUnreliable(msgType, msg);
|
||||
}
|
||||
}
|
||||
|
||||
result = flag;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -456,6 +474,7 @@ namespace QuantumUNET
|
||||
flag &= networkConnection.SendByChannel(msgType, msg, channelId);
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
@ -488,8 +507,10 @@ namespace QuantumUNET
|
||||
flag &= networkConnection2.SendByChannel(msgType, msg, channelId);
|
||||
}
|
||||
}
|
||||
|
||||
result = flag;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -504,6 +525,7 @@ namespace QuantumUNET
|
||||
m_LocalConnection.Dispose();
|
||||
m_LocalConnection = null;
|
||||
}
|
||||
|
||||
m_LocalClientActive = false;
|
||||
}
|
||||
|
||||
@ -524,6 +546,7 @@ namespace QuantumUNET
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (m_RemoveListCount++ % 100 == 0)
|
||||
{
|
||||
CheckForNullObjects();
|
||||
@ -540,12 +563,14 @@ namespace QuantumUNET
|
||||
m_RemoveList.Add(networkInstanceId);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_RemoveList.Count > 0)
|
||||
{
|
||||
foreach (var key in m_RemoveList)
|
||||
{
|
||||
objects.Remove(key);
|
||||
}
|
||||
|
||||
m_RemoveList.Clear();
|
||||
}
|
||||
}
|
||||
@ -557,6 +582,7 @@ namespace QuantumUNET
|
||||
{
|
||||
m_SimpleServerSimple.UpdateConnections();
|
||||
}
|
||||
|
||||
UpdateServerObjects();
|
||||
}
|
||||
|
||||
@ -578,6 +604,7 @@ namespace QuantumUNET
|
||||
QLog.Warning("Player not destroyed when connection disconnected.");
|
||||
}
|
||||
}
|
||||
|
||||
QLog.Log($"Server lost client:{conn.connectionId}");
|
||||
conn.RemoveObservers();
|
||||
conn.Dispose();
|
||||
@ -676,6 +703,7 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QLog.Error($"Failed to send message to player object '{player.name}, not found in connection list");
|
||||
}
|
||||
|
||||
@ -690,6 +718,7 @@ namespace QuantumUNET
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QLog.Error($"Failed to send message to connection ID '{connectionId}, not found in connection list");
|
||||
}
|
||||
|
||||
@ -718,6 +747,7 @@ namespace QuantumUNET
|
||||
{
|
||||
x = playerController.Gameobject;
|
||||
}
|
||||
|
||||
if (x != null)
|
||||
{
|
||||
QLog.Log(
|
||||
@ -743,11 +773,13 @@ namespace QuantumUNET
|
||||
{
|
||||
networkIdentity.SetClientOwner(conn);
|
||||
}
|
||||
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -770,8 +802,10 @@ namespace QuantumUNET
|
||||
{
|
||||
QLog.Warning($"AddPlayer: playerControllerId of {playerControllerId} is unusually high");
|
||||
}
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -786,6 +820,7 @@ namespace QuantumUNET
|
||||
{
|
||||
uv.OnStartServer(true);
|
||||
}
|
||||
|
||||
uv.RebuildObservers(true);
|
||||
SendSpawnMessage(uv, null);
|
||||
ulocalConnectionToClient.LocalClient.AddLocalPlayer(newPlayerController);
|
||||
@ -798,6 +833,7 @@ namespace QuantumUNET
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -807,6 +843,7 @@ namespace QuantumUNET
|
||||
{
|
||||
Spawn(playerGameObject);
|
||||
}
|
||||
|
||||
conn.Send(4, new QOwnerMessage
|
||||
{
|
||||
NetId = uv.NetId,
|
||||
@ -827,6 +864,7 @@ namespace QuantumUNET
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -845,6 +883,7 @@ namespace QuantumUNET
|
||||
{
|
||||
QLog.Warning("Ready with no player object");
|
||||
}
|
||||
|
||||
conn.isReady = true;
|
||||
if (conn is QULocalConnectionToClient)
|
||||
{
|
||||
@ -858,6 +897,7 @@ namespace QuantumUNET
|
||||
{
|
||||
networkIdentity.AddObserver(conn);
|
||||
}
|
||||
|
||||
if (!networkIdentity.IsClient)
|
||||
{
|
||||
QLog.Log("LocalClient.SetSpawnObject calling OnStartClient");
|
||||
@ -891,6 +931,7 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
objectSpawnFinishedMessage.State = 1U;
|
||||
conn.Send(12, objectSpawnFinishedMessage);
|
||||
}
|
||||
@ -988,6 +1029,7 @@ namespace QuantumUNET
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
if (component.ClientAuthorityOwner != netMsg.Connection)
|
||||
@ -996,6 +1038,7 @@ namespace QuantumUNET
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QLog.Log($"OnCommandMessage for netId={networkInstanceId} conn={netMsg.Connection}");
|
||||
component.HandleCommand(cmdHash, netMsg.Reader);
|
||||
}
|
||||
@ -1040,6 +1083,7 @@ namespace QuantumUNET
|
||||
{
|
||||
objectSpawnMessage.Payload = networkWriter.ToArray();
|
||||
}
|
||||
|
||||
if (conn != null)
|
||||
{
|
||||
conn.Send(3, objectSpawnMessage);
|
||||
@ -1063,6 +1107,7 @@ namespace QuantumUNET
|
||||
{
|
||||
objectSpawnSceneMessage.Payload = networkWriter2.ToArray();
|
||||
}
|
||||
|
||||
if (conn != null)
|
||||
{
|
||||
conn.Send(10, objectSpawnSceneMessage);
|
||||
@ -1091,6 +1136,7 @@ namespace QuantumUNET
|
||||
DestroyObject(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var playerController in conn.PlayerControllers)
|
||||
{
|
||||
if (playerController.IsValid)
|
||||
@ -1099,9 +1145,11 @@ namespace QuantumUNET
|
||||
{
|
||||
DestroyObject(playerController.UnetView, true);
|
||||
}
|
||||
|
||||
playerController.Gameobject = null;
|
||||
}
|
||||
}
|
||||
|
||||
conn.PlayerControllers.Clear();
|
||||
}
|
||||
}
|
||||
@ -1152,10 +1200,12 @@ namespace QuantumUNET
|
||||
uv.OnNetworkDestroy();
|
||||
QClientScene.SetLocalObject(objectDestroyMessage.NetId, null);
|
||||
}
|
||||
|
||||
if (destroyServerObject)
|
||||
{
|
||||
UnityEngine.Object.Destroy(uv.gameObject);
|
||||
}
|
||||
|
||||
uv.MarkForReset();
|
||||
}
|
||||
|
||||
@ -1183,6 +1233,7 @@ namespace QuantumUNET
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1204,6 +1255,7 @@ namespace QuantumUNET
|
||||
{
|
||||
result = SpawnWithClientAuthority(obj, component.ConnectionToClient);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1221,6 +1273,7 @@ namespace QuantumUNET
|
||||
var component = obj.GetComponent<QNetworkIdentity>();
|
||||
result = !(component == null) && component.IsServer && component.AssignClientAuthority(conn);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1239,6 +1292,7 @@ namespace QuantumUNET
|
||||
{
|
||||
networkIdentity.SetDynamicAssetId(assetId);
|
||||
}
|
||||
|
||||
instance.SpawnObject(obj);
|
||||
}
|
||||
}
|
||||
@ -1262,6 +1316,7 @@ namespace QuantumUNET
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1281,6 +1336,7 @@ namespace QuantumUNET
|
||||
QLog.Error($"Local invoke: Failed to find local connection to invoke handler on [connectionId={conn.connectionId}] for MsgId:{msgType}");
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1308,6 +1364,7 @@ namespace QuantumUNET
|
||||
networkIdentity.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var networkIdentity2 in objectsOfTypeAll)
|
||||
{
|
||||
if (ValidateSceneObject(networkIdentity2))
|
||||
@ -1316,8 +1373,10 @@ namespace QuantumUNET
|
||||
networkIdentity2.ForceAuthority(true);
|
||||
}
|
||||
}
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1337,6 +1396,7 @@ namespace QuantumUNET
|
||||
channel = (byte)QNetworkCRC.singleton.scripts[text]
|
||||
});
|
||||
}
|
||||
|
||||
crcmessage.scripts = list.ToArray();
|
||||
targetConnection.Send(14, crcmessage);
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ namespace QuantumUNET
|
||||
connectionConfig.AddChannel(QosType.Unreliable);
|
||||
hostTopology = new HostTopology(connectionConfig, 8);
|
||||
}
|
||||
|
||||
Debug.Log("NetworkServerSimple initialize.");
|
||||
}
|
||||
}
|
||||
@ -82,6 +83,7 @@ namespace QuantumUNET
|
||||
Debug.Log($"NetworkServerSimple listen: {ipAddress}:{listenPort}");
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -105,6 +107,7 @@ namespace QuantumUNET
|
||||
Debug.Log($"NetworkServerSimple listen {listenPort}");
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -154,15 +157,18 @@ namespace QuantumUNET
|
||||
{
|
||||
Debug.Log($"NetGroup event:{networkEventType}");
|
||||
}
|
||||
|
||||
if (networkEventType == NetworkEventType.ConnectEvent)
|
||||
{
|
||||
Debug.Log("NetGroup server connected");
|
||||
}
|
||||
|
||||
if (networkEventType == NetworkEventType.DisconnectEvent)
|
||||
{
|
||||
Debug.Log("NetGroup server disconnected");
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
networkEventType = NetworkTransport.ReceiveFromHost(serverHostId, out var connectionId, out var channelId, messageBuffer, messageBuffer.Length, out var receivedSize, out var b);
|
||||
@ -170,6 +176,7 @@ namespace QuantumUNET
|
||||
{
|
||||
Debug.Log($"Server event: host={serverHostId} event={networkEventType} error={b}");
|
||||
}
|
||||
|
||||
switch (networkEventType)
|
||||
{
|
||||
case NetworkEventType.DataEvent:
|
||||
@ -208,6 +215,7 @@ namespace QuantumUNET
|
||||
{
|
||||
result = m_Connections[connectionId];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -217,6 +225,7 @@ namespace QuantumUNET
|
||||
{
|
||||
m_Connections.Add(null);
|
||||
}
|
||||
|
||||
bool result;
|
||||
if (m_Connections[conn.connectionId] != null)
|
||||
{
|
||||
@ -228,6 +237,7 @@ namespace QuantumUNET
|
||||
conn.SetHandlers(m_MessageHandlers);
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -243,6 +253,7 @@ namespace QuantumUNET
|
||||
m_Connections[connectionId] = null;
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -264,6 +275,7 @@ namespace QuantumUNET
|
||||
{
|
||||
m_Connections.Add(null);
|
||||
}
|
||||
|
||||
m_Connections[connectionId] = networkConnection;
|
||||
OnConnected(networkConnection);
|
||||
}
|
||||
@ -287,6 +299,7 @@ namespace QuantumUNET
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
networkConnection.Disconnect();
|
||||
m_Connections[connectionId] = null;
|
||||
Debug.Log($"Server lost client:{connectionId}");
|
||||
|
@ -33,6 +33,7 @@ namespace QuantumUNET
|
||||
{
|
||||
result = m_LocalServer.InvokeBytes(this, bytes, numBytes, channelId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -80,9 +80,11 @@ namespace QuantumUNET.Transport
|
||||
_freePackets.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
_pendingPackets.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
@ -141,6 +143,7 @@ namespace QuantumUNET.Transport
|
||||
_maxPendingPacketCount = value;
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -151,6 +154,7 @@ namespace QuantumUNET.Transport
|
||||
SendInternalBuffer();
|
||||
_lastFlushTime = Time.realtimeSinceStartup;
|
||||
}
|
||||
|
||||
if (Time.realtimeSinceStartup - _lastBufferedMessageCountTimer > 1f)
|
||||
{
|
||||
LastBufferedPerSecond = NumBufferedPerSecond;
|
||||
@ -184,6 +188,7 @@ namespace QuantumUNET.Transport
|
||||
_fragmentBuffer.SeekZero();
|
||||
_readingFragment = true;
|
||||
}
|
||||
|
||||
var array = reader.ReadBytesAndSize();
|
||||
_fragmentBuffer.WriteBytes(array, (ushort)array.Length);
|
||||
result = false;
|
||||
@ -193,6 +198,7 @@ namespace QuantumUNET.Transport
|
||||
_readingFragment = false;
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -212,6 +218,7 @@ namespace QuantumUNET.Transport
|
||||
num += num2;
|
||||
bytesToSend -= num2;
|
||||
}
|
||||
|
||||
_fragmentWriter.StartMessage(17);
|
||||
_fragmentWriter.Write(1);
|
||||
_fragmentWriter.FinishMessage();
|
||||
@ -255,6 +262,7 @@ namespace QuantumUNET.Transport
|
||||
{
|
||||
QueuePacket();
|
||||
}
|
||||
|
||||
_currentPacket.Write(bytes, bytesToSend);
|
||||
result = true;
|
||||
}
|
||||
@ -264,6 +272,7 @@ namespace QuantumUNET.Transport
|
||||
{
|
||||
Debug.LogError($"ChannelBuffer buffer limit of {_pendingPackets.Count} packets reached.");
|
||||
}
|
||||
|
||||
_isBroken = true;
|
||||
result = false;
|
||||
}
|
||||
@ -290,6 +299,7 @@ namespace QuantumUNET.Transport
|
||||
_currentPacket.Write(bytes, bytesToSend);
|
||||
result = MaxDelay != 0f || SendInternalBuffer();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -314,6 +324,7 @@ namespace QuantumUNET.Transport
|
||||
channelPacket.Reset();
|
||||
result = channelPacket;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -338,6 +349,7 @@ namespace QuantumUNET.Transport
|
||||
_pendingPackets.Enqueue(channelPacket);
|
||||
break;
|
||||
}
|
||||
|
||||
_pendingPacketCount--;
|
||||
FreePacket(channelPacket);
|
||||
if (_isBroken && _pendingPackets.Count < _maxPendingPacketCount / 2)
|
||||
@ -346,12 +358,14 @@ namespace QuantumUNET.Transport
|
||||
_isBroken = false;
|
||||
}
|
||||
}
|
||||
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = _currentPacket.SendToTransport(_connection, _channelId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -40,15 +40,18 @@ namespace QuantumUNET.Transport
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (b != 0)
|
||||
{
|
||||
if (m_IsReliable && b == 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Debug.LogError($"Send Error: {(NetworkError)b} channel:{channelId} bytesToSend:{m_Position}");
|
||||
result = false;
|
||||
}
|
||||
|
||||
m_Position = 0;
|
||||
return result;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ namespace QuantumUNET.Transport
|
||||
{
|
||||
throw new IndexOutOfRangeException($"NetworkReader:ReadByte out of range:{ToString()}");
|
||||
}
|
||||
|
||||
return m_Buffer[(int)(UIntPtr)Position++];
|
||||
}
|
||||
|
||||
@ -27,12 +28,14 @@ namespace QuantumUNET.Transport
|
||||
{
|
||||
throw new IndexOutOfRangeException($"NetworkReader:ReadBytes out of range: ({count}) {ToString()}");
|
||||
}
|
||||
|
||||
ushort num = 0;
|
||||
while (num < count)
|
||||
{
|
||||
buffer[num] = m_Buffer[(int)(UIntPtr)(Position + num)];
|
||||
num += 1;
|
||||
}
|
||||
|
||||
Position += count;
|
||||
}
|
||||
|
||||
@ -92,6 +95,7 @@ namespace QuantumUNET.Transport
|
||||
m_Buffer[targetOffset + i] = buffer[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (num > Position)
|
||||
{
|
||||
Position = num;
|
||||
@ -112,6 +116,7 @@ namespace QuantumUNET.Transport
|
||||
m_Buffer[(int)checked(unchecked(Position + (ulong)i))] = buffer[i];
|
||||
}
|
||||
}
|
||||
|
||||
Position += count;
|
||||
}
|
||||
|
||||
@ -128,6 +133,7 @@ namespace QuantumUNET.Transport
|
||||
Debug.LogWarning($"NetworkBuffer size is {num} bytes!");
|
||||
}
|
||||
}
|
||||
|
||||
var array = new byte[num];
|
||||
m_Buffer.CopyTo(array, 0);
|
||||
m_Buffer = array;
|
||||
|
@ -78,11 +78,13 @@ namespace QuantumUNET.Transport
|
||||
{
|
||||
throw new IndexOutOfRangeException($"ReadPackedUInt32() failure: {b}");
|
||||
}
|
||||
|
||||
result = (uint)(b2 + (b3 << 8) + (b4 << 16) + (b5 << 24));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -150,6 +152,7 @@ namespace QuantumUNET.Transport
|
||||
{
|
||||
throw new IndexOutOfRangeException($"ReadPackedUInt64() failure: {b}");
|
||||
}
|
||||
|
||||
result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40) + ((ulong)b8 << 48) + ((ulong)b9 << 56);
|
||||
}
|
||||
}
|
||||
@ -159,6 +162,7 @@ namespace QuantumUNET.Transport
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -275,14 +279,17 @@ namespace QuantumUNET.Transport
|
||||
{
|
||||
throw new IndexOutOfRangeException($"ReadString() too long: {num}");
|
||||
}
|
||||
|
||||
while (num > s_StringReaderBuffer.Length)
|
||||
{
|
||||
s_StringReaderBuffer = new byte[s_StringReaderBuffer.Length * 2];
|
||||
}
|
||||
|
||||
m_buf.ReadBytes(s_StringReaderBuffer, num);
|
||||
var chars = s_Encoding.GetChars(s_StringReaderBuffer, 0, num);
|
||||
result = new string(chars);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -300,6 +307,7 @@ namespace QuantumUNET.Transport
|
||||
{
|
||||
throw new IndexOutOfRangeException($"NetworkReader ReadBytes {count}");
|
||||
}
|
||||
|
||||
var array = new byte[count];
|
||||
m_buf.ReadBytes(array, (uint)count);
|
||||
return array;
|
||||
@ -395,6 +403,7 @@ namespace QuantumUNET.Transport
|
||||
result = gameObject.transform;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -415,8 +424,10 @@ namespace QuantumUNET.Transport
|
||||
{
|
||||
Debug.Log($"ReadGameObject netId:{networkInstanceId}go: null");
|
||||
}
|
||||
|
||||
result = gameObject;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -443,6 +454,7 @@ namespace QuantumUNET.Transport
|
||||
result = gameObject.GetComponent<QNetworkIdentity>();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -200,6 +200,7 @@ namespace QuantumUNET.Transport
|
||||
{
|
||||
throw new IndexOutOfRangeException($"Serialize(string) too long: {value.Length}");
|
||||
}
|
||||
|
||||
Write((ushort)byteCount);
|
||||
var bytes = s_Encoding.GetBytes(value, 0, value.Length, s_StringWriteBuffer, 0);
|
||||
m_Buffer.WriteBytes(s_StringWriteBuffer, (ushort)bytes);
|
||||
@ -213,6 +214,7 @@ namespace QuantumUNET.Transport
|
||||
m_Buffer.WriteByte(1);
|
||||
return;
|
||||
}
|
||||
|
||||
m_Buffer.WriteByte(0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user