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