Exemplo n.º 1
0
        protected void SendEventInternal(Type invokeClass, string eventName, NetworkWriter writer, int channelId)
        {
            if (!NetworkServer.active)
            {
                logger.LogWarning("SendEvent no server?");
                return;
            }

            // construct the message
            SyncEventMessage message = new SyncEventMessage
            {
                netId          = netId,
                componentIndex = ComponentIndex,
                // type+func so Inventory.RpcUse != Equipment.RpcUse
                functionHash = RemoteCallHelper.GetMethodHash(invokeClass, eventName),
                // segment to avoid reader allocations
                payload = writer.ToArraySegment()
            };

            NetworkServer.SendToReady(netIdentity, message, channelId);
        }
Exemplo n.º 2
0
        protected void SendEventInternal(Type invokeClass, string eventName, NetworkWriter writer, int channelId)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("SendEvent no server?");
                return;
            }

            // construct the message
            SyncEventMessage message = new SyncEventMessage
            {
                netId          = netId,
                componentIndex = ComponentIndex,
                functionHash   = GetMethodHash(invokeClass, eventName), // type+func so Inventory.RpcUse != Equipment.RpcUse
                payload        = writer.ToArraySegment()                // segment to avoid reader allocations
            };

            NetworkServer.SendToReady(netIdentity, message, channelId);
#if MIRROR_PROFILING
            NetworkProfiler.RecordMessage(NetworkDirection.Outgoing, typeof(SyncEventMessage), $"{invokeClass.GetType()}.{eventName}", 1);
#endif
        }
Exemplo n.º 3
0
        static void OnSyncEventMessage(NetworkMessage netMsg)
        {
            SyncEventMessage message = netMsg.ReadMessage <SyncEventMessage>();

            if (LogFilter.logDebug)
            {
                Debug.Log("ClientScene::OnSyncEventMessage " + message.netId);
            }

            NetworkIdentity uv;

            if (s_NetworkScene.GetNetworkIdentity(message.netId, out uv))
            {
                uv.HandleSyncEvent(message.eventHash, new NetworkReader(message.payload));
            }
            else
            {
                if (LogFilter.logWarn)
                {
                    Debug.LogWarning("Did not find target for SyncEvent message for " + message.netId);
                }
            }
        }