简体   繁体   English

java kryonet - ChatMessage - 类未注册

[英]java kryonet - ChatMessage - Class is not registered

i just started to use kryonet.我刚开始使用 kryonet。

the chat example works fine when run from the examples folder.从示例文件夹运行时,聊天示例工作正常。

if i copy the chat client, server, and network files into another source folder in eclipse, i get IllegalArgumentException: Class is not registered: com.esotericsoftware.kryonet.examples.chat.Network$RegisterName (please see below).如果我将聊天客户端、服务器和网络文件复制到 eclipse 中的另一个源文件夹中,我会收到 IllegalArgumentException:未注册类:com.esotericsoftware.kryonet.examples.chat.Network$RegisterName(请参见下文)。

i added printouts around the: "kryo.register(ChatMessage.class);", so i know that this is being called.我在“kryo.register(ChatMessage.class);”周围添加了打印输出,所以我知道这是被调用的。

the client hangs trying to connect.客户端挂起尝试连接。

any pointers will be appreciated.任何指针将不胜感激。

thanks谢谢

00:05  INFO: [kryonet] Connecting: localhost/127.0.0.1:22222
00:05 DEBUG: [kryonet] Port 59450/TCP connected to: localhost/127.0.0.1:22222
00:05 DEBUG: [kryo] Read: RegisterTCP
00:05  INFO: [kryonet] Connection 1 connected: localhost/127.0.0.1
Exception in thread "Client" java.lang.IllegalArgumentException: Class is not registered: com.esotericsoftware.kryonet.examples.chat.Network$RegisterName
Note: To register this class use: kryo.register(com.esotericsoftware.kryonet.examples.chat.Network$RegisterName.class);
    at com.esotericsoftware.kryo.Kryo.getRegistration(Kryo.java:461)
    at com.esotericsoftware.kryo.util.DefaultClassResolver.writeClass(DefaultClassResolver.java:79)
    at com.esotericsoftware.kryo.Kryo.writeClass(Kryo.java:491)
    at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:596)
    at com.esotericsoftware.kryonet.KryoSerialization.write(KryoSerialization.java:66)
    at com.esotericsoftware.kryonet.TcpConnection.send(TcpConnection.java:210)
    at com.esotericsoftware.kryonet.Connection.sendTCP(Connection.java:87)
    at com.tayek.kryo.ChatClient$1.connected(ChatClient.java:55)
    at com.esotericsoftware.kryonet.Connection.notifyConnected(Connection.java:242)
    at com.esotericsoftware.kryonet.Client.update(Client.java:284)
    at com.esotericsoftware.kryonet.Client.run(Client.java:356)
    at java.lang.Thread.run(Unknown Source)
Exception in thread "Client" java.lang.IllegalArgumentException: Class is not registered: com.esotericsoftware.kryonet.examples.chat.Network$RegisterName
Note: To register this class use: kryo.register(com.esotericsoftware.kryonet.examples.chat.Network$RegisterName.class);

The stack trace says that Network$RegisterName class is not registered.堆栈跟踪表明Network$RegisterName类未注册。

Register this class and your project will start working as normal.注册这个类,您的项目将开始正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM