sylar-yin / chat_room Goto Github PK
View Code? Open in Web Editor NEWC++聊天室服务器,基于sylar框架开发,使用http服务器做资源服务,websocket server做聊天server
Home Page: http://www.sylar.top
C++聊天室服务器,基于sylar框架开发,使用http服务器做资源服务,websocket server做聊天server
Home Page: http://www.sylar.top
2020-05-05 15:19:30 7405 io_1 15 [INFO] [system] sylar/http/ws_session.cc:32 http header Connection != Upgrade
我用的是火狐浏览器测试的,然后出错了,检查了火狐发的请求头是这样的:
Host: 192.168.56.132:8062
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0
Accept: */*
Accept-Language: zh-CN,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Sec-WebSocket-Version: 13
Origin: http://192.168.56.132:8090
Sec-WebSocket-Extensions: permessage-deflate
Sec-WebSocket-Key: 1+JeWXx4sEoAoNBT6rGwpQ==
Connection: keep-alive, Upgrade //这里多了keep-alive
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
我在ws_session.cc:27,32把字符串判断改成包含关系就可以了:
if(strstr(req->getHeader("Upgrade").c_str(), "websocket") == NULL) {
if(strstr(req->getHeader("Connection").c_str(), "Upgrade") == NULL) {
chat_room/chat/chat_servlet.cc
Line 108 in 7fd04c6
然后在chat_servlet.cc:108,应该是要判断name才对,才能判断是不是重名。
if(session_exists(name)) {
rsp->set("result", "402");
rsp->set("msg", "name exists");
return SendMessage(session, rsp);
}
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.