songxinjianqwe / chat Goto Github PK
View Code? Open in Web Editor NEWJava NIO+多线程实现聊天室
Java NIO+多线程实现聊天室
while ((size = client.read(buf)) > 0) {
buf.flip();
baos.write(buf.array(), 0, size);
buf.clear();
}
在ReadEventHandler中,TCP可能粘包,此处baos存入的可能是多条消息的字节流,反序列化会导致客户端到达的部分消息丢失。(在ReadEventHandler中sleep一下就能看到此bug)
How to deploy this project?
Already imported this project to Intellij Idea, and then what should I do?
Thank you!
Can you please provide the documentation in English?
代码有解决粘包的问题吗
请问,这个在idea中如何启动呢
java.io.IOException: 你的主机中的软件中止了一个已建立的连接。
at sun.nio.ch.SocketDispatcher.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
at sun.nio.ch.IOUtil.write(IOUtil.java:65)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:469)
at cn.sinjinsong.chat.server.handler.message.MessageHandler.broadcast(MessageHandler.java:29)
at cn.sinjinsong.chat.server.handler.message.impl.BroadcastMessageHandler.handle(BroadcastMessageHandler.java:33)
at cn.sinjinsong.chat.server.ChatServer$ReadEventHandler.run(ChatServer.java:214)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
怎么操作?
我把项目导入到idea里面去,发现ChatClient.java这个里面找不到.builder()这个方法,是缺少什么包吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.