本文整理汇总了Java中cn.nukkit.utils.Binary.appendBytes方法的典型用法代码示例。如果您正苦于以下问题:Java Binary.appendBytes方法的具体用法?Java Binary.appendBytes怎么用?Java Binary.appendBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.utils.Binary
的用法示例。
在下文中一共展示了Binary.appendBytes方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invalidSession
import cn.nukkit.utils.Binary; //导入方法依赖的package包/类
protected void invalidSession(String identifier) {
byte[] buffer = Binary.appendBytes(
RakNet.PACKET_INVALID_SESSION,
new byte[]{(byte) (identifier.length() & 0xff)},
identifier.getBytes(StandardCharsets.UTF_8)
);
this.server.pushMainToThreadPacket(buffer);
}
示例2: closeSession
import cn.nukkit.utils.Binary; //导入方法依赖的package包/类
public void closeSession(String identifier, String reason) {
byte[] buffer = Binary.appendBytes(
RakNet.PACKET_CLOSE_SESSION,
new byte[]{(byte) (identifier.length() & 0xff)},
identifier.getBytes(StandardCharsets.UTF_8),
new byte[]{(byte) (reason.length() & 0xff)},
reason.getBytes(StandardCharsets.UTF_8)
);
this.server.pushMainToThreadPacket(buffer);
}
示例3: streamEncapsulated
import cn.nukkit.utils.Binary; //导入方法依赖的package包/类
public void streamEncapsulated(Session session, EncapsulatedPacket packet, int flags) {
String id = session.getAddress() + ":" + session.getPort();
byte[] buffer = Binary.appendBytes(
RakNet.PACKET_ENCAPSULATED,
new byte[]{(byte) (id.length() & 0xff)},
id.getBytes(StandardCharsets.UTF_8),
new byte[]{(byte) (flags & 0xff)},
packet.toBinary(true)
);
this.server.pushThreadToMainPacket(buffer);
}
示例4: streamRAW
import cn.nukkit.utils.Binary; //导入方法依赖的package包/类
public void streamRAW(String address, int port, byte[] payload) {
byte[] buffer = Binary.appendBytes(
RakNet.PACKET_RAW,
new byte[]{(byte) (address.length() & 0xff)},
address.getBytes(StandardCharsets.UTF_8),
Binary.writeShort(port),
payload
);
this.server.pushThreadToMainPacket(buffer);
}
示例5: streamOpen
import cn.nukkit.utils.Binary; //导入方法依赖的package包/类
protected void streamOpen(Session session) {
String identifier = FastAppender.get(session.getAddress(), ":", session.getPort());
byte[] buffer = Binary.appendBytes(
RakNet.PACKET_OPEN_SESSION,
new byte[]{(byte) (identifier.length() & 0xff)},
identifier.getBytes(StandardCharsets.UTF_8),
new byte[]{(byte) (session.getAddress().length() & 0xff)},
session.getAddress().getBytes(StandardCharsets.UTF_8),
Binary.writeShort(session.getPort()),
Binary.writeLong(session.getID())
);
this.server.pushThreadToMainPacket(buffer);
}
示例6: streamOpen
import cn.nukkit.utils.Binary; //导入方法依赖的package包/类
protected void streamOpen(Session session) {
String identifier = session.getAddress() + ":" + session.getPort();
byte[] buffer = Binary.appendBytes(
RakNet.PACKET_OPEN_SESSION,
new byte[]{(byte) (identifier.length() & 0xff)},
identifier.getBytes(StandardCharsets.UTF_8),
new byte[]{(byte) (session.getAddress().length() & 0xff)},
session.getAddress().getBytes(StandardCharsets.UTF_8),
Binary.writeShort(session.getPort()),
Binary.writeLong(session.getID())
);
this.server.pushThreadToMainPacket(buffer);
}
示例7: sendRaw
import cn.nukkit.utils.Binary; //导入方法依赖的package包/类
public void sendRaw(String address, int port, byte[] payload) {
byte[] buffer = Binary.appendBytes(
RakNet.PACKET_RAW,
new byte[]{(byte) (address.length() & 0xff)},
address.getBytes(StandardCharsets.UTF_8),
Binary.writeShort(port),
payload
);
this.server.pushMainToThreadPacket(buffer);
}
示例8: streamACK
import cn.nukkit.utils.Binary; //导入方法依赖的package包/类
protected void streamACK(String identifier, int identifierACK) {
byte[] buffer = Binary.appendBytes(
RakNet.PACKET_ACK_NOTIFICATION,
new byte[]{(byte) (identifier.length() & 0xff)},
identifier.getBytes(StandardCharsets.UTF_8),
Binary.writeInt(identifierACK)
);
this.server.pushThreadToMainPacket(buffer);
}
示例9: blockAddress
import cn.nukkit.utils.Binary; //导入方法依赖的package包/类
public void blockAddress(String address, int timeout) {
byte[] buffer = Binary.appendBytes(
RakNet.PACKET_BLOCK_ADDRESS,
new byte[]{(byte) (address.length() & 0xff)},
address.getBytes(StandardCharsets.UTF_8),
Binary.writeInt(timeout)
);
this.server.pushMainToThreadPacket(buffer);
}
示例10: sendOption
import cn.nukkit.utils.Binary; //导入方法依赖的package包/类
public void sendOption(String name, String value) {
byte[] buffer = Binary.appendBytes(
RakNet.PACKET_SET_OPTION,
new byte[]{(byte) (name.length() & 0xff)},
name.getBytes(StandardCharsets.UTF_8),
value.getBytes(StandardCharsets.UTF_8)
);
this.server.pushMainToThreadPacket(buffer);
}
示例11: sendEncapsulated
import cn.nukkit.utils.Binary; //导入方法依赖的package包/类
public void sendEncapsulated(String identifier, EncapsulatedPacket packet, int flags) {
byte[] buffer = Binary.appendBytes(
RakNet.PACKET_ENCAPSULATED,
new byte[]{(byte) (identifier.length() & 0xff)},
identifier.getBytes(StandardCharsets.UTF_8),
new byte[]{(byte) (flags & 0xff)},
packet.toBinary(true)
);
this.server.pushMainToThreadPacket(buffer);
}
示例12: streamInvalid
import cn.nukkit.utils.Binary; //导入方法依赖的package包/类
protected void streamInvalid(String identifier) {
byte[] buffer = Binary.appendBytes(
RakNet.PACKET_INVALID_SESSION,
new byte[]{(byte) (identifier.length() & 0xff)},
identifier.getBytes(StandardCharsets.UTF_8)
);
this.server.pushThreadToMainPacket(buffer);
}
示例13: streamOption
import cn.nukkit.utils.Binary; //导入方法依赖的package包/类
protected void streamOption(String name, String value) {
byte[] buffer = Binary.appendBytes(
RakNet.PACKET_SET_OPTION,
new byte[]{(byte) (name.length() & 0xff)},
name.getBytes(StandardCharsets.UTF_8),
value.getBytes(StandardCharsets.UTF_8)
);
this.server.pushThreadToMainPacket(buffer);
}
示例14: put
import cn.nukkit.utils.Binary; //导入方法依赖的package包/类
protected void put(byte[] b) {
this.buffer = Binary.appendBytes(this.buffer, b);
}