public async Task MoveChannelAsync(ClientSession.ClientSession clientSession, int channelId) { var server = await _channelHttpClient.GetChannelAsync(channelId).ConfigureAwait(false); if (server == null || server.Type != ServerType.WorldServer) { return; } await clientSession.SendPacketAsync(new MzPacket { Port = server.DisplayPort ?? server.Port, Ip = server.DisplayHost ?? server.Host, CharacterSlot = clientSession.Character.Slot }); await clientSession.SendPacketAsync(new ItPacket { Mode = 1 }); await _authHttpClient.SetAwaitingConnectionAsync(-1, clientSession.Account.Name); await clientSession.Character.SaveAsync(); await clientSession.DisconnectAsync(); }
public async Task BroadcastPacketAsync(PostedPacket packet, int channelId) { var channel = await _channelHttpClient.GetChannelAsync(channelId).ConfigureAwait(false); if (channel != null) { await SendPacketToChannelAsync(packet, channel.WebApi !.ToString()).ConfigureAwait(false); } }
public async Task <HttpClient?> ConnectAsync(int channelId) { using var client = _httpClientFactory.CreateClient(); var channel = await _channelHttpClient.GetChannelAsync(channelId).ConfigureAwait(false); if (channel == null) { return(null); } client.BaseAddress = new Uri(channel.WebApi !.ToString()); return(client); }
public async Task <HttpClient?> ConnectAsync(int channelId) { using var client = _httpClientFactory.CreateClient(); var channel = await _channelHttpClient.GetChannelAsync(channelId).ConfigureAwait(false); if (channel == null) { return(null); } client.BaseAddress = new Uri(channel.WebApi !.ToString()); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", channel.Token); return(client); }