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.SendAsync(new GateEnterResponse() { AccountId = request.Account, Result = GateEnterResult.Success }); session.SendAsync(new SWorldCurrentDataResponse()); }
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.SendAsync(new CharacterGestureUpdateSlotsResponse() { Values = request.Values }); }
public void GetInfo(SyncSession session) => session .SendAsync(new CharacterInfoResponse() { Character = ResponseHelper.GetCharacter(session), Place = ResponseHelper.GetPlace(session, _instance), }) .SendAsync(new CharacterSkillInfoResponse() { }) .SendAsync(new InfiniteTowerLoadInfoResponse() { }) .SendAsync(new CharacterGestureLoadResponse() { Values = session.Gestures }) .SendAsync(new CharacterProfileResponse() { About = session.Profile.About, Note = session.Profile.Note, Status = session.Profile.Status, }) .SendAsync(new CharacterPostInfoResponse() { Values = Array.Empty <object>() }) .SendAsync(new CharacterStatsUpdateResponse() { Character = session.Character.Id, Values = session.Stats.Select(s => new CharacterStatsUpdateResponse.Entity() { Id = s.Id, Value = s.Value }) });
public void GetInfo(SyncSession session) => session .SendAsync(new ChannelInfoResponse() { Location = _instance.Location.Id, Values = _channels.Values.Select(s => new ChannelInfoResponse.Entity() { Id = (ushort)(1 + s.Id), Status = s.Status }) });
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.SendAsync(new ChatMessageResponse() { Character = session.Character.Id, Chat = ChatType.System, Message = "Command executed" }); return; } session.SendAsync(new ChatMessageResponse() { Character = session.Character.Id, Chat = ChatType.Red, Message = "Command not found" }); return; } session.Channel !.BroadcastAsync(new ChatMessageResponse() { Character = session.Character.Id, Chat = request.Type, Message = request.Message }); }
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.SendAsync(new AuthGateConnectionEndPointResponse { Ip = gate.Ip, Port = gate.Port }); }
public void GetOthers(SyncSession session) { session.SendAsync(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); }
public void Leave(SyncSession session) { session.SendAsync(new PartyDeleteResponse()); }
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.SendAsync(new SWorldCurrentDataResponse()); session.SendAsync(new WorldVersionResponse() { Id = 0, Main = 1, Sub = 837, Data = 16888 }); if (_tables.BattlePass.Count > 0) { PassInfoTableEntity entity = _tables.BattlePass.Values.First(); session.SendAsync(new BattlePassLoadResponse() { Id = entity.Id, HavePoint = 2000, NextReward = 3, StartDate = DateTimeOffset.UtcNow.ToUnixTimeSeconds(), EndDate = DateTimeOffset.UtcNow.AddMonths(1).ToUnixTimeSeconds(), IsPremium = 1 }); } session.SendAsync(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.SendAsync(new DistrictEnterResponse() { Place = new() { Location = _instance.Location.Id, Position = session.Character.Place.Position, Rotation = session.Character.Place.Rotation, } });
public static void ToggleWeapon(SyncSession session, CharacterToggleWeaponRequest request) => session .SendAsync(request);
public void GetList(SyncSession session) => session .SendAsync(GetPersonalInfo(session)) .SendAsync(_features);
public static void GetPostInfo(SyncSession session) => session .SendAsync(new PostInfoResponse() { });