예제 #1
0
        private void OnAddSubscriber(MasterClientPeer subscriber)
        {
            this.subscribers.Add(subscriber);
            EventData eventData = this.GetAppStatsEventData();

            subscriber.SendEvent(eventData, new SendParameters {
                Unreliable = true
            });
        }
예제 #2
0
        public virtual void OnClientConnected(MasterClientPeer peer)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("OnClientConnect: peerId={0}, appId={1}", peer.ConnectionId, this.ApplicationId);
            }

            // remove from player cache
            if (this.PlayerOnlineCache != null && string.IsNullOrEmpty(peer.UserId) == false)
            {
                this.PlayerOnlineCache.OnConnectedToMaster(peer.UserId);
            }
        }
예제 #3
0
        public virtual void OnClientDisconnected(MasterClientPeer peer)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("OnClientDisconnect: peerId={0}, appId={1}", peer.ConnectionId, this.ApplicationId);
            }

            // remove from player cache
            if (this.PlayerOnlineCache != null && string.IsNullOrEmpty(peer.UserId) == false)
            {
                this.PlayerOnlineCache.OnDisconnectFromMaster(peer.UserId);
            }
        }
예제 #4
0
        public virtual void OnClientDisconnected(MasterClientPeer peer)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("OnClientDisconnect: peerId={0}, appId={1}", peer.ConnectionId, this.ApplicationId);
            }

            // remove from player cache
            if (this.PlayerOnlineCache != null && string.IsNullOrEmpty(peer.UserId) == false)
            {
                this.PlayerOnlineCache.OnDisconnectFromMaster(peer.UserId);
            }

            // unsubscribe from lobby statistic events
            this.LobbyStatsPublisher.Unsubscribe(peer);
        }
예제 #5
0
        protected override PeerBase CreatePeer(InitRequest initRequest)
        {
            if (this.IsGameServerPeer(initRequest))
            {
                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Received init request from game server");
                }

                return(new IncomingGameServerPeer(initRequest, this));
            }

            if (this.LocalNodeId == this.MasterNodeId)
            {
                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Received init request from game client on leader node");
                }

                var peer = new MasterClientPeer(initRequest);

                var settings = WebRpcSettings.Default;
                if (settings != null && settings.Enabled)
                {
                    peer.WebRpcHandler = new WebRpcHandler(
                        settings.BaseUrl.Value,
                        new Dictionary <string, object>
                    {
                        { "AppId", this.HwId },
                        { "AppVersion", "" },
                        { "Region", "" },
                        { "Cloud", "" },
                    },
                        null,
                        new HttpRequestQueueOptions(httpQueueReconnectInterval: settings.ReconnectInterval * 1000));
                }

                return(peer);
            }

            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Received init request from game client on slave node");
            }

            return(new RedirectedClientPeer(initRequest));
        }
        protected override PeerBase CreatePeer(InitRequest initRequest)
        {
            if (this.IsGameServerPeer(initRequest))
            {
                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Received init request from game server");
                }
                return(this.CreateGameServerPeer(initRequest));
            }
            log.Info("一个客户端连接中......MasterAppliction11");
            if (this.LocalNodeId == this.MasterNodeId)
            {
                log.Info("一个客户端连接中......MasterAppliction111");
                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Received init request from game client on leader node");
                }

                var peer = new MasterClientPeer(initRequest);
                peerList.Add(peer);
                for (var i = 0; peerList.Count > i; i++)
                {
                    log.Info("====展示信息===:" + peerList[i].ToString());
                }
                log.Info("====客户端:========:" + peerList.ToString());
                if (this.webRpcManager.IsRpcEnabled)
                {
                    peer.WebRpcHandler = this.webRpcManager.GetWebRpcHandler();
                }

                return(peer);
            }

            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Received init request from game client on slave node");
            }
            log.Info("一个客户端连接中......MasterAppliction11111");
            return(new RedirectedClientPeer(initRequest));
        }
예제 #7
0
 public void RemoveSubscriber(MasterClientPeer peer)
 {
     this.fiber.Enqueue(() => this.OnRemoveSubscriber(peer));
 }
예제 #8
0
 private void OnRemoveSubscriber(MasterClientPeer subscriber)
 {
     this.subscribers.Remove(subscriber);
 }
예제 #9
0
 public void RemoveSubscriber(MasterClientPeer peer)
 {
     this.fiber.Enqueue(() => this.OnRemoveSubscriber(peer));
 }
예제 #10
0
 private void OnRemoveSubscriber(MasterClientPeer subscriber)
 {
     this.subscribers.Remove(subscriber);
 }
예제 #11
0
 private void OnAddSubscriber(MasterClientPeer subscriber)
 {
     this.subscribers.Add(subscriber);
     EventData eventData = this.GetAppStatsEventData();
     subscriber.SendEvent(eventData, new SendParameters { Unreliable = true });
 }
예제 #12
0
        protected override PeerBase CreatePeer(InitRequest initRequest)
        {
            if (this.IsGameServerPeer(initRequest))
            {
                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Received init request from game server");
                }

                return new IncomingGameServerPeer(initRequest, this);
            }

            if (this.LocalNodeId == this.MasterNodeId)
            {
                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Received init request from game client on leader node");
                }

                var peer = new MasterClientPeer(initRequest);

                var settings = WebRpcSettings.Default;
                if (settings != null && settings.Enabled)
                {
                    peer.WebRpcHandler = new WebRpcHandler(
                        settings.BaseUrl.Value,
                        new Dictionary<string, object>
                                       {
                                           {"AppId", this.HwId},
                                           {"AppVersion", ""},
                                           {"Region", ""},
                                           {"Cloud", ""},
                                       },
                                       null,
                                       new HttpRequestQueueOptions(httpQueueReconnectInterval: settings.ReconnectInterval * 1000));
                }

                return peer;
            }

            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Received init request from game client on slave node");
            }

            return new RedirectedClientPeer(initRequest);
        }