Comments (10)
多谢关注,后续应该会增加一些新的功能,同时欢迎提交代码
from gotcp.
简单加了个连接池,太简单了
from gotcp.
server不需要连接池吧,client才考虑
from gotcp.
连接池这个是考虑到的场景是:服务端需要给某一个客户端推送数据,比如说,需要给15号客户端发送数据,这种情况下,我如何找到15号客户端
from gotcp.
在内存中映射 uin 到 conn, 比如:map[int64]*conn,直接用map[15]就可以找到15号客户端的socket,你说的是不是这种情况? 可是这个并不是连接池
from gotcp.
我的意思就是服务端需要去维护一个客户端的列表,或者map,可以随时给客户端发送数据,我的是给map[client_ip]*conn,这样外部可以更好通过ip找到conn
from gotcp.
明白你的意思了, 不过维护客户端列表这种事情交给业务层去做比较好。
用map[client_ip]_conn这种我想不到有哪种业务模型需要这样保存,更多情况下都是有账号体系的,在登录包里面带上客户端标识UIN(比如QQ账号),服务器保存 map[UIN]_conn。
from gotcp.
框架封装这个也是可以的。目前就是用了map
from gotcp.
想要上下文 自己在OnConnect的时候加就Ok了,而且有的是有登录的,只有登录完成的才加入,所以还是业务去做吧
from gotcp.
lchjczw需要的是在线状态吧,可以方便push消息, 我觉得这些还是放在业务层去做
from gotcp.
Related Issues (16)
- 目前 server 运行起来后 客户端链接通信必须符合 type 标准,否则 server 错误推出 HOT 3
- 有个疑问 HOT 1
- 异步服务有些问题. HOT 18
- 你这支持异步写数据么? HOT 5
- 连接断掉,conn的HandleChannel里的packet未处理给丢弃了 HOT 3
- 请问如何优雅地使用gotcp框架做客户端? HOT 2
- 请问gotcp 框架的处理性能你有测试过吗? HOT 2
- ReadPacket后,未调用 OnMessage HOT 9
- conn.go中的asyncDo函数加*sync.WaitGroup的作用是什么?
- ReadPacket只能一次返回一个包呀. HOT 2
- 请教一个问题 HOT 1
- How to deal with half packet data? HOT 4
- 如何平滑重启或者停止server HOT 2
- waitGroup.Add(1) 不能放置于 goroutine 内部 HOT 1
- 关于waitgroup HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gotcp.