예제 #1
0
        protected virtual OperationResponse GetUserJoinResponse(JoinGameRequest joinRequest, int actorNr, ProcessJoinParams prms)
        {
            var actor = this.ActorsManager.ActorsGetActorByNumber(actorNr);

            var joinResponse = new JoinResponse {ActorNr = actor.ActorNr};

            if (this.Properties.Count > 0)
            {
                joinResponse.CurrentGameProperties = this.Properties.GetProperties();
            }

            foreach (var t in this.ActorsManager)
            {
                // if actor is joining normaly we skip its own properties
                // if actor is rejoining we send its own properties
                if ((t.ActorNr != actor.ActorNr
                    || (!t.IsInactive && joinRequest.IsRejoining))
                    && (t.Properties.Count > 0 || this.PublishUserId))
                {
                    if (joinResponse.CurrentActorProperties == null)
                    {
                        joinResponse.CurrentActorProperties = new Hashtable();
                    }

                    var actorProperties = t.Properties.GetProperties();
                    if (t.IsInactive)
                    {
                        actorProperties.Add((byte) ActorParameter.IsInactive, true);
                    }

                    if (this.PublishUserId)
                    {
                        actorProperties.Add((byte)ActorParameter.UserId, t.UserId);
                    }
                    joinResponse.CurrentActorProperties.Add(t.ActorNr, actorProperties);
                }
            }

            var actorList = new List<int>();
            actorList.AddRange(this.ActorsManager.ActorsGetActorNumbers().ToArray());
            actorList.AddRange(this.ActorsManager.InactiveActorsGetActorNumbers().ToArray());

            if (!this.SuppressRoomEvents)
            {
                joinResponse.Actors = actorList.ToArray();
            }

            var oresponse = new OperationResponse(joinRequest.OperationRequest.OperationCode, joinResponse);
            if (prms.ResponseExtraParameters != null)
            {
                foreach (var extraParameter in prms.ResponseExtraParameters)
                {
                    oresponse.Parameters.Add(extraParameter.Key, extraParameter.Value);
                }
            }
            return oresponse;
        }
예제 #2
0
        protected bool JoinSendResponseAndEvents(HivePeer peer, JoinGameRequest joinRequest, SendParameters sendParameters, int actorNr, ProcessJoinParams prms)
        {
            peer.JoinStage = HivePeer.JoinStages.GettingUserResponse;
            var oresponse = this.GetUserJoinResponse(joinRequest, actorNr, prms);
            peer.SendOperationResponse(oresponse, sendParameters);

            peer.JoinStage = HivePeer.JoinStages.PublishingEvents;
            this.PublishJoinEvent(peer, joinRequest);
            peer.JoinStage = HivePeer.JoinStages.EventsPublished;
            this.PublishEventCache(peer, joinRequest);

            peer.JoinStage = HivePeer.JoinStages.Complete;
            return true;
        }
예제 #3
0
 protected virtual bool ProcessJoin(int actorNr, JoinGameRequest joinRequest, SendParameters sendParameters, ProcessJoinParams prms, HivePeer peer)
 {
     return this.JoinSendResponseAndEvents(peer, joinRequest, sendParameters, actorNr, prms);
 }
예제 #4
0
 protected override OperationResponse GetUserJoinResponse(JoinGameRequest joinRequest, int actorNr, ProcessJoinParams prms)
 {
     var res = base.GetUserJoinResponse(joinRequest, actorNr, prms);
     if (this.Plugin.Name != "Default")
     {
         res.Parameters.Add((byte)ParameterKey.PluginName, this.Plugin.Name);
         res.Parameters.Add((byte)ParameterKey.PluginVersion, this.Plugin.Version);
     }
     return res;
 }
예제 #5
0
        protected override bool ProcessJoin(int actorNr, JoinGameRequest joinRequest, 
            SendParameters sendParameters, ProcessJoinParams prms, HivePeer peer)
        {
            if (!base.ProcessJoin(actorNr, joinRequest, sendParameters, prms, peer))
            {
                return false;
            }

            var gamePeer = (GameClientPeer)peer;
            // update game state at master server
            var userId = gamePeer.UserId ?? string.Empty;

            this.NotifyMasterUserAdded(userId, joinRequest.AddUsers != null ? this.ActorsManager.ExpectedUsers.ToArray() : null);

            return true;
        }