Exemple #1
0
//给所有客户端发送消息
func SendMsgForAll(message string) {
	messageSend := msgc.Message{
		ProtoId:    msgc.MSGID_Text,
		CreateTime: time.Now().Unix(),
		Content:    []byte(message),
	}
	for idOne, nodeOne := range nodeStore.GetAllNodes() {
		if clientConn, ok := engine.GetController().GetSession(string(nodeOne.IdInfo.Build())); ok {
			messageSend.TargetId = idOne
			data, _ := json.Marshal(messageSend)
			clientConn.Send(msgc.SendMessageNum, &data)
		}
	}
}
Exemple #2
0
/*
	查看本地保存的所有节点id
*/
func See() {
	allNodes := nodeStore.GetAllNodes()
	for key, _ := range allNodes {
		fmt.Println(key)
	}
}