chore: configure await
This commit is contained in:
parent
600f4a2f50
commit
6589a9f890
6 changed files with 16 additions and 12 deletions
|
@ -29,14 +29,14 @@ public class AuthSession : TcpSession
|
|||
return base.Send(buffer);
|
||||
}
|
||||
|
||||
public void Send(IPacket packet)
|
||||
public Task SendAsync(IPacket packet)
|
||||
{
|
||||
var type = packet.GetType();
|
||||
this._logger.LogInformation("Packet of type {Type} is being serialized", type.Name);
|
||||
var packetIdAttribute = type.GetCustomAttribute<PacketIdAttribute>();
|
||||
if (packetIdAttribute == null)
|
||||
{
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var opcode = packetIdAttribute.Code;
|
||||
|
@ -63,7 +63,8 @@ public class AuthSession : TcpSession
|
|||
this._logger.LogInformation("Packet data being parsed is: {Data}", BitConverter.ToString(packetData.ToArray()));
|
||||
this._logger.LogInformation("Packet being parsed is: {Data}", BitConverter.ToString(buffer.ToArray()));
|
||||
|
||||
this.Send(buffer);
|
||||
this.SendAsync(buffer);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override void OnReceived(byte[] buffer, long offset, long size)
|
||||
|
|
|
@ -80,11 +80,11 @@ public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
|
|||
};
|
||||
}
|
||||
|
||||
authSession.Send(responsePacket);
|
||||
await authSession.SendAsync(responsePacket).ConfigureAwait(false);
|
||||
if (guildNameResponsePacket.GuildNames.Length > 0 &&
|
||||
guildNameResponsePacket.GuildNames.Select(n => n != string.Empty).Any())
|
||||
{
|
||||
authSession.Send(guildNameResponsePacket);
|
||||
await authSession.SendAsync(guildNameResponsePacket).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,12 +107,12 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
|||
.Select(item => item.ItemId)
|
||||
.ToArray(),
|
||||
}).FirstAsync().ConfigureAwait(true);
|
||||
authSession?.Send(new CharacterCreationResponsePacket
|
||||
await authSession.SendAsync(new CharacterCreationResponsePacket
|
||||
{
|
||||
Character = character,
|
||||
Slot = amountOfCharacters - 1,
|
||||
isDuplicate = false,
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static int CalculateCurrentHealth(ushort level, JobSpecificMapping firstJobConfig)
|
||||
|
|
|
@ -30,13 +30,13 @@ public class CharacterDeletionHandler : IPacketHandler<CharacterDeletePacket>
|
|||
var response = new CharacterDeleteResponsePacket { IsDeleted = 0 };
|
||||
if (character == null)
|
||||
{
|
||||
authSession.Send(response);
|
||||
await authSession.SendAsync(response).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
//_wonderkingContext.Characters.Remove(character);
|
||||
//await _wonderkingContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
|
||||
authSession.Send(response);
|
||||
await authSession.SendAsync(response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,11 @@ public class CharacterNameCheckHandler : IPacketHandler<CharacterNameCheckPacket
|
|||
{
|
||||
var isTaken = _wonderkingContext.Characters.Any(c => c.Name == packet.Name);
|
||||
var responsePacket = new CharacterNameCheckPacketResponse { IsTaken = isTaken };
|
||||
var authSession = session as AuthSession;
|
||||
authSession?.Send(responsePacket);
|
||||
if (session is AuthSession authSession)
|
||||
{
|
||||
return authSession.SendAsync(responsePacket);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,6 +119,6 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket>
|
|||
}
|
||||
|
||||
_logger.LogInformation("LoginResponsePacket: {@LoginResponsePacket}", loginResponsePacket);
|
||||
sess?.Send(loginResponsePacket);
|
||||
sess?.SendAsync(loginResponsePacket);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue