예제 #1
0
        /// <summary>活动内下线 </summary>
        private void ActivityOut(Int64 userid)
        {
            var mn = 0;

            if (Variable.Activity.ScenePlayer.Keys.Contains(string.Format("{0}_{1}", (int)ModuleNumber.SIEGE, userid)))
            {
                mn = (int)ModuleNumber.SIEGE;
            }
            if (Variable.Activity.ScenePlayer.Keys.Contains(string.Format("{0}_{1}", (int)ModuleNumber.BUILDING, userid)))
            {
                mn = (int)ModuleNumber.BUILDING;
            }
            var             otherplays = Scene.ActivityOtherPlayers(userid, mn);//活动内其他玩家
            var             key        = string.Format("{0}_{1}", mn, userid);
            view_scene_user scene;

            Variable.Activity.ScenePlayer.TryRemove(key, out scene);

            foreach (var item in otherplays)
            {
                var obj = new OnlineObject {
                    OffLine = userid, OtherPlayer = Variable.Activity.ScenePlayer[item].user_id
                };
                var tokenTest = new CancellationTokenSource();
                Task.Factory.StartNew(m =>
                {
                    var temp = m as OnlineObject;
                    if (temp == null)
                    {
                        return;
                    }
                    var aso = BuildData(temp.OffLine);
                    if (!Variable.OnlinePlayer.ContainsKey(temp.OtherPlayer))
                    {
                        return;
                    }
                    var othersession = Variable.OnlinePlayer[temp.OtherPlayer] as TGGSession;
                    if (othersession == null)
                    {
                        return;
                    }
                    if (mn == (int)ModuleNumber.BUILDING)
                    {
                        SendPushCommand(othersession, aso, (int)BuildingCommand.PUSH_PLAYER_EXIT, (int)ModuleNumber.BUILDING);
                    }
                    if (mn == (int)ModuleNumber.SIEGE)
                    {
                        SendPushCommand(othersession, aso, (int)SiegeCommand.PUSH_PLAYER_EXIT, (int)ModuleNumber.SIEGE);
                    }
                    tokenTest.Cancel();
                }, obj, tokenTest.Token);
            }
        }