void INetworkSender.PrepareAndSendWriter(NetworkWriter writer) { // only send the writer if the Scope is active if (IsActive) { writer.FinishMessage(); #if UNITY_EDITOR && SCOPE_DEBUGGING // log outgoing signal ScopeDebugger.AddOutgoingSignal(this, typeof(TServerScope), new NetworkReader(writer.ToArray())); #endif byte error; NetworkTransport.Send(client.connection.hostId, client.connection.connectionId, 0, writer.ToArray(), writer.Position, out error); if ((NetworkError)error != NetworkError.Ok) { UnityEngine.Debug.LogError((NetworkError)error); } } // otherwise, ignore or queue the Signal for later else { // if Signal queuing is enabled, enqueue the writer to be sent later if (_signalQueueEnabled) { queuedSignalWriters.Enqueue(writer); } // otherwise, just display a warning message else { UnityEngine.Debug.LogWarningFormat("Ignoring Signal sending because the Scope <color=white>{0}</color> is no longer active", GetType().Name); } } }
public void ExitScope() { #if NS_DEBUG_SCOPE_ACTIVITY UnityEngine.Debug.LogFormat("<color=red>Exited</color> Scope <color=white>{0}</color>", GetType().Name); #endif #if UNITY_EDITOR && SCOPE_DEBUGGING ScopeDebugger.AddScopeEvent(this, null, ScopeDebugger.ScopeEvent.Type.Exit); #endif OnExitScope(); OnExitScopeEvent(); IsActive = false; }
public void EnterScope() { IsActive = true; #if NS_DEBUG_SCOPE_ACTIVITY UnityEngine.Debug.LogFormat("<color=green>Entered</color> Scope <color=white>{0}</color>", GetType().Name); #endif #if UNITY_EDITOR && SCOPE_DEBUGGING ScopeDebugger.AddScopeEvent(this, null, ScopeDebugger.ScopeEvent.Type.Enter); #endif OnEnterScope(); OnEnterScopeEvent(); }
void INetworkSender.PrepareAndSendWriter(NetworkWriter writer) { writer.FinishMessage(); #if UNITY_EDITOR && SCOPE_DEBUGGING // log outgoing signal ScopeDebugger.AddOutgoingSignal(this, typeof(TClientScope), new NetworkReader(writer)); #endif if (!IsTargetGroup) { ScopeUtils.SendNetworkWriter(writer, TargetPeer); } else { ScopeUtils.SendNetworkWriter(writer, TargetPeerGroup); } }
public void ProcessMessage(NetworkMessage msg) { #if UNITY_EDITOR && SCOPE_DEBUGGING // log incoming signal ScopeDebugger.AddIncomingSignal(this, msg.reader); msg.reader.SeekZero(); #endif // if not pause, invoke the signal immediately if (!_isPaused) { MethodBindingCache.Invoke(this, cachedType, msg.reader); } // if paused, enqueue paused signal for later processing else { SignalInvocation inv = MethodBindingCache.GetMessageInvocation(cachedType, msg.reader); pausedMessages.Enqueue(inv); } }