本文整理汇总了Java中org.spongepowered.api.network.ChannelBuf类的典型用法代码示例。如果您正苦于以下问题:Java ChannelBuf类的具体用法?Java ChannelBuf怎么用?Java ChannelBuf使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChannelBuf类属于org.spongepowered.api.network包,在下文中一共展示了ChannelBuf类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handlePayload
import org.spongepowered.api.network.ChannelBuf; //导入依赖的package包/类
@Override
public void handlePayload(ChannelBuf data, RemoteConnection connection, Platform.Type side) {
for (Map.Entry<Predicate<ChannelBuf>, Consumer<ChannelBuf>> entry : map.entrySet()) {
if (entry.getKey().test(data)) {
entry.getValue().accept(data);
map.remove(entry.getKey());
return;
}
}
}
示例2: handlePayload
import org.spongepowered.api.network.ChannelBuf; //导入依赖的package包/类
@Override
public void handlePayload(ChannelBuf channelBuf, RemoteConnection remoteConnection, Platform.Type type) {
try {
String message = new String(channelBuf.array(), StandardCharsets.UTF_8);
JSONObject jsonObject = new JSONObject(message);
Vote v = new Vote(jsonObject);
listener.onForward(v);
} catch (Exception e) {
p.getLogger().error("There was an unknown error when processing a forwarded vote.", e);
}
}
示例3: addListener
import org.spongepowered.api.network.ChannelBuf; //导入依赖的package包/类
private static void addListener(Predicate<ChannelBuf> predicate, Consumer<ChannelBuf> consumer) {
listener.map.put(predicate, consumer);
}
示例4: handlePayload
import org.spongepowered.api.network.ChannelBuf; //导入依赖的package包/类
@Override
public void handlePayload(@Nonnull ChannelBuf buf, @Nonnull RemoteConnection connection, @Nonnull Platform.Type type) {
String msg = buf.readUTF();
onMessage(msg, null);
}
示例5: readFrom
import org.spongepowered.api.network.ChannelBuf; //导入依赖的package包/类
@Override
public void readFrom(ChannelBuf buf) {
buf.readUTF();
}
示例6: writeTo
import org.spongepowered.api.network.ChannelBuf; //导入依赖的package包/类
@Override
public void writeTo(ChannelBuf buf) {
buf.writeUTF(text);
}
示例7: sendTo
import org.spongepowered.api.network.ChannelBuf; //导入依赖的package包/类
@Override
public void sendTo(Player player, Consumer<ChannelBuf> payload) {
checkState(this.bound);
getRegistrar().sendPayload(player, getName(), payload::accept);
}
示例8: sendToServer
import org.spongepowered.api.network.ChannelBuf; //导入依赖的package包/类
@Override
public void sendToServer(Consumer<ChannelBuf> payload) {
checkState(this.bound);
checkNotNull(payload, "payload");
}
示例9: sendToAll
import org.spongepowered.api.network.ChannelBuf; //导入依赖的package包/类
@Override
public void sendToAll(Consumer<ChannelBuf> payload) {
checkState(this.bound);
getRegistrar().sendPayloadToAll(getName(), payload::accept);
}
示例10: ChannelBufInputStream
import org.spongepowered.api.network.ChannelBuf; //导入依赖的package包/类
public ChannelBufInputStream(ChannelBuf channelBuf) {
this.channelBuf = channelBuf;
}