コード例 #1
0
ファイル: ServiceHandler.cs プロジェクト: Karveit/OpenWorker
        public void Enter(SyncSession session, GateEnterRequest request)
        {
            if (_gate.Id != request.Gate)
            {
                NetworkUtils.DropBadAction();
            }

            if (!_relay.Session.Contains(new RGSSessionContainsRequest {
                Account = request.Account, Key = request.SessionKey
            }).Result)
            {
                NetworkUtils.DropBadAction();
            }

            {
                using AccountContext context = _accountFactory.CreateDbContext();

                AccountModel model = context.Accounts.AsNoTracking().First(c => c.Id == request.Account);

                session.Account    = new(model);
                session.Characters = GetCharacters(model, request.Gate);
                session.Background = model.CharacterBackground;
                session.Permission = HandlerPermission.Authorized;
            }

            session.SendDeferred(new GateEnterResponse()
            {
                AccountId = request.Account, Result = GateEnterResult.Success
            });
            session.SendDeferred(new SWorldCurrentDataResponse());
        }
コード例 #2
0
ファイル: GestureHandler.cs プロジェクト: Karveit/OpenWorker
        public void UpdateSlots(SyncSession session, GestureQuickSlotsUpdateRequest request)
        {
            foreach (uint id in request.Values)
            {
                if (id == 0)
                {
                    continue;
                }

                if (!_tables.Gesture.TryGetValue((ushort)id, out GestureTableEntity? gesture))
                {
                    NetworkUtils.DropBadAction();
                }

                if (gesture !.Hero != session.Character.Hero && gesture !.Hero != Hero.None)
                {
                    NetworkUtils.DropBadAction();
                }
            }

            using CharacterContext context = _characterRepository.CreateDbContext();

            CharacterModel model = context.Characters.First(s => s.Id == session.Character.Id);

            model.Gestures = request.Values.ToArray();

            context.UseAndSave(c => c.Update(model));

            session.SendDeferred(new CharacterGestureUpdateSlotsResponse()
            {
                Values = request.Values
            });
        }
コード例 #3
0
 public void GetInfo(SyncSession session) => session
 .SendDeferred(new CharacterInfoResponse()
 {
     Character = ResponseHelper.GetCharacter(session),
     Place     = ResponseHelper.GetPlace(session, _instance),
 })
 .SendDeferred(new CharacterSkillInfoResponse()
 {
 })
 .SendDeferred(new InfiniteTowerLoadInfoResponse()
 {
 })
 .SendDeferred(new CharacterGestureLoadResponse()
 {
     Values = session.Gestures
 })
 .SendDeferred(new CharacterProfileResponse()
 {
     About  = session.Profile.About,
     Note   = session.Profile.Note,
     Status = session.Profile.Status,
 })
 .SendDeferred(new CharacterPostInfoResponse()
 {
     Values = Array.Empty <object>()
 })
 .SendDeferred(new CharacterStatsUpdateResponse()
 {
     Character = session.Character.Id,
     Values    = session.Stats.Select(s => new CharacterStatsUpdateResponse.CSUREntity()
     {
         Id = s.Id, Value = s.Value
     })
 });
コード例 #4
0
 public void GetInfo(SyncSession session) => session
 .SendDeferred(new ChannelInfoResponse()
 {
     Location = _instance.Location.Id,
     Values   = _channels.Values.Select(s => new ChannelInfoResponse.Entity()
     {
         Id     = (ushort)(1 + s.Id),
         Status = s.Status
     })
 });
コード例 #5
0
        public void Receive(SyncSession session, ChatReceiveRequest request)
        {
            if (request.Message.Length == 0)
            {
                return;
            }

            if (request.Message.StartsWith('/'))
            {
                string[] msg = request.Message.Split(' ');
                if (_repository.TryGetValue(msg[0], out ChatCommand? command))
                {
                    command(session, msg);

                    session.SendDeferred(new ChatMessageResponse()
                    {
                        Character = session.Character.Id,
                        Chat      = ChatType.Notice,
                        Message   = "Command executed"
                    });

                    return;
                }

                session.SendDeferred(new ChatMessageResponse()
                {
                    Character = session.Character.Id,
                    Chat      = ChatType.Yell,
                    Message   = "Command not found"
                });

                return;
            }

            session.Channel !.BroadcastDeferred(new ChatMessageResponse()
            {
                Character = session.Character.Id,
                Chat      = request.Type,
                Message   = request.Message
            });
        }
コード例 #6
0
ファイル: GateHandler.cs プロジェクト: Karveit/OpenWorker
        public void Connect(SyncSession session, GateConnectRequest request)
        {
            GateRepository.Entity?gate = _repository.FirstOrDefault(s => s.Id == request.Gate);
            if (gate is null || gate.Status == GateStatus.Offline)
            {
                return;
            }

            session.SendDeferred(new AuthGateConnectionEndPointResponse
            {
                Ip   = gate.Ip,
                Port = gate.Port
            });
        }
コード例 #7
0
        public void GetOthers(SyncSession session)
        {
            session.SendDeferred(new NpcOthersInfosResponse()
            {
                Values = _npcs.Select(s => new NpcOthersInfosResponse.Entity()
                {
                    Id         = s.Id,
                    CreatureId = s.CreatureId,
                    Position   = s.Position,
                    Rotation   = s.Rotation,
                    Waypoint   = s.Waypoint
                })
            });

            session.Channel !.SendOtherCharactersAsync(_instance);
        }
コード例 #8
0
        public void Enter(SyncSession session, DistrictEnterRequest request)
        {
            if (!_globalRelay.Session.Contains(new() { Account = request.Account, Key = request.SessionKey }).Result)
            {
                NetworkUtils.DropBadAction();
            }

            {
                AccountModel model = GetAccountModel(request.Account);
                session.Account = new(model);
            }

            {
                CharacterModel model = GetCharacterModel(request.Character, request.Account);

                session.Character      = new(model);
                session.Profile        = new(model.Profile);
                session.Stats          = new();
                session.SpecialOptions = new();
                session.Gestures       = model.Gestures;

                using ItemContext context = _itemFactory.CreateDbContext();
                session.Storages          = new(model, _tables, context);
            }

            if (!_channels.TryJoin(session))
            {
                NetworkUtils.DropBadAction();
            }

            if (!_sync.Characters.TryAdd(session.Character.Id, session))
            {
                NetworkUtils.DropBadAction();
            }

            session.Permission = HandlerPermission.Authorized;

            session.SendDeferred(new SWorldCurrentDataResponse());
            session.SendDeferred(new WorldVersionResponse()
            {
                Id   = 0,
                Main = 1,
                Sub  = 837,
                Data = 16888
            });

            if (_tables.BattlePass.Count > 0)
            {
                PassInfoTableEntity entity = _tables.BattlePass.Values.First();
                session.SendDeferred(new BattlePassLoadResponse()
                {
                    Id         = entity.Id,
                    HavePoint  = 2000,
                    NextReward = 3,
                    StartDate  = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
                    EndDate    = DateTimeOffset.UtcNow.AddMonths(1).ToUnixTimeSeconds(),
                    IsPremium  = 1
                });
            }

            session.SendDeferred(new DayEventBoosterResponse()
            {
                Values = _dayEventBoosters.Select(s => new DayEventBoosterResponse.Entity()
                {
                    Id   = s.Id,
                    Maze = s.Maze.Id
                }).ToArray()
            });

            // CharacterSuperArmorGage
            // LOGLV 2 : 454.747 :: eSUB_CMD_BOOSTER_ADD 2

            session.SendDeferred(new DistrictEnterResponse()
            {
                Place = new()
                {
                    Location = _instance.Location.Id,
                    Position = session.Character.Place.Position,
                    Rotation = session.Character.Place.Rotation,
                }
            });
コード例 #9
0
 public void Leave(SyncSession session)
 {
     session.SendDeferred(new PartyDeleteResponse());
 }
コード例 #10
0
ファイル: GateHandler.cs プロジェクト: Karveit/OpenWorker
 public void GetCharacterCount(SyncSession session) => session
 .SendDeferred(new SLUserCharacterForServerResponse
 {
     Values = GetPersonalInfo(session)
 })
 .SendDeferred(_features);
コード例 #11
0
ファイル: PostHandler.cs プロジェクト: Karveit/OpenWorker
 public static void GetPostInfo(SyncSession session) => session
 .SendDeferred(new PostInfoResponse()
 {
 });