Exemple #1
0
        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);
                }
            }
        }
        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);
            }
        }