mirror of
https://github.com/fhmq/hmq.git
synced 2026-04-24 10:38:34 +00:00
go
This commit is contained in:
@@ -45,7 +45,6 @@ func (b *Broker) StartListening() {
|
||||
}
|
||||
|
||||
func (b *Broker) handleConnection(conn net.Conn, idx int) {
|
||||
|
||||
//process connect packet
|
||||
buf, err := ReadPacket(conn)
|
||||
if err != nil {
|
||||
@@ -74,12 +73,14 @@ func (b *Broker) handleConnection(conn net.Conn, idx int) {
|
||||
keepalive: connMsg.KeepAlive(),
|
||||
willMsg: willmsg,
|
||||
}
|
||||
pool := MSGPool[idx%MessagePoolNum].GetPool()
|
||||
c := &client{
|
||||
broker: b,
|
||||
conn: conn,
|
||||
info: info,
|
||||
msgPool: MSGPool[idx%MessagePoolNum].GetPool(),
|
||||
msgPool: pool,
|
||||
}
|
||||
c.init()
|
||||
c.readLoop()
|
||||
pool.Reduce()
|
||||
}
|
||||
|
||||
13
main.go
13
main.go
@@ -13,10 +13,15 @@ const (
|
||||
MessagePoolNum = 1024
|
||||
MessagePoolUser = MaxUser / MessagePoolNum
|
||||
MessagePoolMessageNum = MaxUser / MessagePoolNum * 4
|
||||
|
||||
MessageBoxNum = 256
|
||||
MessageBoxUserNum = MaxUser / MessageBoxNum
|
||||
MessageBoxMessageLength = MessageBoxUserNum
|
||||
)
|
||||
|
||||
var (
|
||||
MSGPool []MessagePool
|
||||
// Messagebox []*Message
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -24,6 +29,14 @@ func init() {
|
||||
for i := 0; i < (MessagePoolNum + 2); i++ {
|
||||
MSGPool[i].Init(MessagePoolUser, MessagePoolMessageNum)
|
||||
}
|
||||
// Messagebox = make([]MessageProcess, MailBoxNum)
|
||||
// for i := 0; i < MailBoxNum; i++ {
|
||||
// gMailbox[i].Init(MailBoxMessageLength, HongBaoBoxMessageLength)
|
||||
// }
|
||||
// for i := 0; i < MailBoxNum; i++ {
|
||||
// go ProcessRequest(i)
|
||||
// }
|
||||
|
||||
}
|
||||
func main() {
|
||||
broker := broker.NewBroker()
|
||||
|
||||
Reference in New Issue
Block a user