public void NotifySubscribers <TParameters>(byte code, TParameters parameters, MessageSendOptions messageSendOptions)
            where TParameters : struct, IParameters
        {
            foreach (var subscriber in GetSubscribersFromPublishers)
            {
                var peerId = subscriber.Components.GetComponent <IPeerIdGetter>();
                if (peerId == null)
                {
                    continue;
                }

                var peerWrapper = peerContainer.GetPeerWrapper(peerId.GetId());
                if (peerWrapper == null)
                {
                    continue;
                }

                if (!peerWrapper.Peer.IsConnected)
                {
                    continue;
                }

                var eventSender = peerWrapper.PeerLogic.Components.GetComponent <IEventSenderWrapper>().AssertNotNull();
                eventSender.Send(code, parameters, messageSendOptions);
            }
        }
        public void Notify(UserProfilePropertiesChangedEventParameters parameters)
        {
            var userId    = parameters.UserId;
            var serverIds = userIdToServerIdConverter.Get(userId);

            if (serverIds == null)
            {
                LogUtils.Log($"Could not find server ids for user with id {userId}");
                return;
            }

            foreach (var serverId in serverIds)
            {
                var peerId = serverIdToPeerIdConverter.Get(serverId);
                if (!peerId.HasValue)
                {
                    continue;
                }

                if (peerId.Value == clientPeerProvider.PeerId)
                {
                    continue;
                }

                var peerWrapper = peerContainer.GetPeerWrapper(peerId.Value);
                if (peerWrapper == null)
                {
                    LogUtils.Log($"Could not find a peer wrapper of server with id {serverId}");
                    continue;
                }

                RaiseUserProfilePropertiesChanged(peerWrapper);
            }

            void RaiseUserProfilePropertiesChanged(IClientPeerWrapper peerWrapper)
            {
                var eventSenderWrapper = peerWrapper.PeerLogic.Components.GetComponent <IEventSenderWrapper>().AssertNotNull();

                eventSenderWrapper.Send((byte)UserProfileEvents.UserProfilePropertiesChanged, parameters, MessageSendOptions.DefaultReliable());
            }
        }
Beispiel #3
0
        private void OnUserProfilePropertiesChanged(UserProfilePropertiesChangedEventParameters parameters)
        {
            var userId = parameters.UserId;
            var peerId = userIdToPeerIdConverter.Get(userId);

            if (peerId == null)
            {
                return;
            }

            var peerWrapper = peerContainer.GetPeerWrapper(peerId.Value);

            if (peerWrapper == null)
            {
                LogUtils.Log(MessageBuilder.Trace($"Unable to find a peer wrapper of user with id {userId}"));
                return;
            }

            var eventInvoker = peerWrapper.PeerLogic.Components.GetComponent <IUserProfilePropertiesChangesEventInvoker>().AssertNotNull();

            eventInvoker.Invoke(parameters);
        }