Added error message to request acks.
This commit is contained in:
parent
8277ea0154
commit
21cb5c9453
18
Server.cs
18
Server.cs
@ -78,20 +78,22 @@ namespace HermesSocketLibrary
|
||||
await socket.Send(5, new LoggingMessage("Received no data in the message.", HermesLoggingLevel.Warn));
|
||||
continue;
|
||||
}
|
||||
else if (obj.OpCode == 0)
|
||||
obj.Data = JsonSerializer.Deserialize<HeartbeatMessage>(obj.Data.ToString(), _options);
|
||||
|
||||
string data = obj.Data.ToString()!;
|
||||
if (obj.OpCode == 0)
|
||||
obj.Data = JsonSerializer.Deserialize<HeartbeatMessage>(data, _options);
|
||||
else if (obj.OpCode == 1)
|
||||
obj.Data = JsonSerializer.Deserialize<HermesLoginMessage>(obj.Data.ToString(), _options);
|
||||
obj.Data = JsonSerializer.Deserialize<HermesLoginMessage>(data, _options);
|
||||
else if (obj.OpCode == 3)
|
||||
obj.Data = JsonSerializer.Deserialize<RequestMessage>(obj.Data.ToString(), _options);
|
||||
obj.Data = JsonSerializer.Deserialize<RequestMessage>(data, _options);
|
||||
else if (obj.OpCode == 5)
|
||||
obj.Data = JsonSerializer.Deserialize<LoggingMessage>(obj.Data.ToString(), _options);
|
||||
obj.Data = JsonSerializer.Deserialize<LoggingMessage>(data, _options);
|
||||
else if (obj.OpCode == 6)
|
||||
obj.Data = JsonSerializer.Deserialize<ChatterMessage>(obj.Data.ToString(), _options);
|
||||
obj.Data = JsonSerializer.Deserialize<ChatterMessage>(data, _options);
|
||||
else if (obj.OpCode == 7)
|
||||
obj.Data = JsonSerializer.Deserialize<EmoteDetailsMessage>(obj.Data.ToString(), _options);
|
||||
obj.Data = JsonSerializer.Deserialize<EmoteDetailsMessage>(data, _options);
|
||||
else if (obj.OpCode == 8)
|
||||
obj.Data = JsonSerializer.Deserialize<EmoteUsageMessage>(obj.Data.ToString(), _options);
|
||||
obj.Data = JsonSerializer.Deserialize<EmoteUsageMessage>(data, _options);
|
||||
else
|
||||
{
|
||||
await socket.Send(5, new LoggingMessage("Received an invalid message: " + message, HermesLoggingLevel.Error));
|
||||
|
@ -35,17 +35,18 @@ namespace HermesSocketServer.Socket.Handlers
|
||||
_logger.Error(e, $"Failed to grant a request of type '{data.Type}'.");
|
||||
}
|
||||
|
||||
if (result == null || !result.Success)
|
||||
if (result == null)
|
||||
return;
|
||||
|
||||
var ack = new RequestAckMessage()
|
||||
{
|
||||
Request = data,
|
||||
Data = result.Result,
|
||||
Nounce = data.Nounce
|
||||
Data = result.Success ? result.Result : null,
|
||||
Nounce = data.Nounce,
|
||||
Error = result.Success ? null : result.Result?.ToString()
|
||||
};
|
||||
|
||||
if (!result.NotifyClientsOnAccount)
|
||||
if (!result.NotifyClientsOnAccount || !result.Success)
|
||||
{
|
||||
await sender.Send(4, ack);
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user