mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 08:47:39 +00:00
Fix packet handling
This commit is contained in:
parent
3d2e0d0451
commit
539fa16160
@ -77,7 +77,7 @@ public final class GameServerPacketHandler {
|
||||
|
||||
// Invoke event.
|
||||
var event = new ReceivePacketEvent(session, opcode, payload);
|
||||
if (!event.call()) // If event is not canceled, continue.
|
||||
if (event.call()) // If event is not canceled, continue.
|
||||
handler.handle(session, header, event.getPacketData());
|
||||
} catch (Exception ex) {
|
||||
Grasscutter.getLogger().warn("Unable to handle packet.", ex);
|
||||
|
@ -148,7 +148,7 @@ public class GameSession implements KcpChannel {
|
||||
if (packet.shouldEncrypt) {
|
||||
Crypto.xor(bytes, packet.useDispatchKey() ? Crypto.DISPATCH_KEY : this.encryptKey);
|
||||
}
|
||||
tunnel.writeData(bytes);
|
||||
this.tunnel.writeData(bytes);
|
||||
} catch (Exception ignored) {
|
||||
Grasscutter.getLogger().debug("Unable to send packet to client.");
|
||||
}
|
||||
@ -228,8 +228,8 @@ public class GameSession implements KcpChannel {
|
||||
// Handle
|
||||
getServer().getPacketHandler().handle(this, opcode, header, payload);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception exception) {
|
||||
Grasscutter.getLogger().warn("Unable to handle packet.", exception);
|
||||
} finally {
|
||||
// byteBuf.release(); //Needn't
|
||||
packet.release();
|
||||
|
@ -70,10 +70,8 @@ public final class GameSessionManager implements KcpListener {
|
||||
}
|
||||
|
||||
// Handle the message in a separate thread.
|
||||
executor.submit(() -> {
|
||||
var bytes = Utils.byteBufToArray(byteBuf);
|
||||
session.onMessage(bytes);
|
||||
});
|
||||
var bytes = Utils.byteBufToArray(byteBuf);
|
||||
executor.submit(() -> session.onMessage(bytes));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user