Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebsocketManager代码疑问 #35

Open
memory125 opened this issue Feb 12, 2022 · 1 comment
Open

WebsocketManager代码疑问 #35

memory125 opened this issue Feb 12, 2022 · 1 comment

Comments

@memory125
Copy link

memory125 commented Feb 12, 2022

在文件go-admin-team\go-admin-core\[email protected]\pkg\ws\ws.go中有以下初始化WebsocketManager 代码,

// 初始化 wsManager 管理器
var WebsocketManager = Manager{               // 这里可能需要&,因为后续的接口都是 *Manager
	Group:            make(map[string]map[string]*Client),
	Register:         make(chan *Client, 128),
	UnRegister:       make(chan *Client, 128),
	GroupMessage:     make(chan *GroupMessageData, 128),
	Message:          make(chan *MessageData, 128),
	BroadCastMessage: make(chan *BroadCastMessageData, 128),
	groupCount:       0,
	clientCount:      0,
}

go-admin\app\admin\router\sys_router.go中的函数sysBaseRouter

go ws.WebsocketManager.Start()
go ws.WebsocketManager.SendService()
go ws.WebsocketManager.SendAllService()

调用时,会出现红色警告,如果将ws.go中初始化WebsocketManager 更改为

// 初始化 wsManager 管理器
var WebsocketManager = &Manager{               // 这里可能需要&,因为后续的接口都是 *Manager
	Group:            make(map[string]map[string]*Client),
	Register:         make(chan *Client, 128),
	UnRegister:       make(chan *Client, 128),
	GroupMessage:     make(chan *GroupMessageData, 128),
	Message:          make(chan *MessageData, 128),
	BroadCastMessage: make(chan *BroadCastMessageData, 128),
	groupCount:       0,
	clientCount:      0,
}

将不会报告警告信息。

@wenjianzhang
Copy link
Member

您的建议很好,很希望能够收到您提交的pr!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants