本文整理汇总了Java中co.aikar.timings.Timings.getSendDataPacketTiming方法的典型用法代码示例。如果您正苦于以下问题:Java Timings.getSendDataPacketTiming方法的具体用法?Java Timings.getSendDataPacketTiming怎么用?Java Timings.getSendDataPacketTiming使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类co.aikar.timings.Timings
的用法示例。
在下文中一共展示了Timings.getSendDataPacketTiming方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: batchDataPacket
import co.aikar.timings.Timings; //导入方法依赖的package包/类
public boolean batchDataPacket(DataPacket packet) {
if (!this.connected) {
return false;
}
try (Timing timing = Timings.getSendDataPacketTiming(packet)) {
DataPacketSendEvent event = new DataPacketSendEvent(this, packet);
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
timing.stopTiming();
return false;
}
if (!this.batchedPackets.containsKey(packet.getChannel())) {
this.batchedPackets.put(packet.getChannel(), new ArrayList<>());
}
this.batchedPackets.get(packet.getChannel()).add(packet.clone());
}
return true;
}
示例2: dataPacket
import co.aikar.timings.Timings; //导入方法依赖的package包/类
public int dataPacket(DataPacket packet, boolean needACK) {
if (!this.connected) {
return -1;
}
try (Timing timing = Timings.getSendDataPacketTiming(packet)) {
DataPacketSendEvent ev = new DataPacketSendEvent(this, packet);
this.server.getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
timing.stopTiming();
return -1;
}
Integer identifier = this.interfaz.putPacket(this, packet, needACK, false);
if (needACK && identifier != null) {
this.needACK.put(identifier, false);
timing.stopTiming();
return identifier;
}
}
return 0;
}
示例3: directDataPacket
import co.aikar.timings.Timings; //导入方法依赖的package包/类
public int directDataPacket(DataPacket packet, boolean needACK) {
if (!this.connected) {
return -1;
}
try (Timing timing = Timings.getSendDataPacketTiming(packet)) {
DataPacketSendEvent ev = new DataPacketSendEvent(this, packet);
this.server.getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
timing.stopTiming();
return -1;
}
Integer identifier = this.interfaz.putPacket(this, packet, needACK, true);
if (needACK && identifier != null) {
this.needACK.put(identifier, false);
timing.stopTiming();
return identifier;
}
}
return 0;
}
示例4: dataPacket
import co.aikar.timings.Timings; //导入方法依赖的package包/类
public int dataPacket(DataPacket packet, boolean needACK) {
if (!this.connected) {
return -1;
}
if(this.printPackets)
this.getServer().getLogger().info(TextFormat.YELLOW + "[SEND] " + TextFormat.WHITE + packet.getName());
try (Timing timing = Timings.getSendDataPacketTiming(packet)) {
DataPacketSendEvent ev = new DataPacketSendEvent(this, packet);
this.server.getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
timing.stopTiming();
return -1;
}
Integer identifier = this.interfaz.putPacket(this, packet, needACK, false);
if (needACK && identifier != null) {
this.needACK.put(identifier.intValue(), false);
timing.stopTiming();
return identifier;
}
}
return 0;
}
示例5: directDataPacket
import co.aikar.timings.Timings; //导入方法依赖的package包/类
public int directDataPacket(DataPacket packet, boolean needACK) {
if (!this.connected) {
return -1;
}
if(this.printPackets)
this.getServer().getLogger().info(TextFormat.LIGHT_PURPLE + "[SEND-DIRECT] " + TextFormat.WHITE + packet.getClass().getSimpleName());
try (Timing timing = Timings.getSendDataPacketTiming(packet)) {
DataPacketSendEvent ev = new DataPacketSendEvent(this, packet);
this.server.getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
timing.stopTiming();
return -1;
}
Integer identifier = this.interfaz.putPacket(this, packet, needACK, true);
if (needACK && identifier != null) {
this.needACK.put(identifier.intValue(), false);
timing.stopTiming();
return identifier;
}
}
return 0;
}
示例6: sendPacket
import co.aikar.timings.Timings; //导入方法依赖的package包/类
public void sendPacket(PEPacket packet, boolean immediate) {
if (packet == null)
return;
// System.out.println("Sending [" + packet.getClass().getSimpleName() + "] ");
try (Timing timing = Timings.getSendDataPacketTiming(packet)) {
packet.encode();
byte[] buffer;
try {
buffer = Zlib.deflate(Binary.appendBytes(Binary.writeUnsignedVarInt(packet.getBuffer().length), packet.getBuffer()), 6);
} catch (Exception e) {
timing.stopTiming();
e.printStackTrace();
return;
}
// handler.sendEncapsulated(identifier, encapsulated, RakNet.FLAG_NEED_ACK |
// (overridedImmediate ? RakNet.PRIORITY_IMMEDIATE : RakNet.PRIORITY_NORMAL));
raknetClient.sendMessage(Reliability.RELIABLE_ORDERED, 0,
new net.marfgamer.jraknet.Packet(Binary.appendBytes((byte) 0xfe, buffer)));
}
}