Example #1
0
//创建发送包
func newPackWithInfo(sta int, con interface{}) []byte {
	m := make(map[string]interface{})
	m[status] = sta

	conjs, err := json.Marshal(con)
	if err != nil {
		log.LogWarn(logprefix, "警告,编码发送数据包的附带信息时发生小错误", err)
	}
	m[content] = string(conjs)

	pake, err := json.Marshal(m)
	if err != nil {
		log.LogWarn(logprefix, "警告,编码发送数据包时发生小错误", err)
	}
	return pake
}
Example #2
0
func newPackWithString(sta int, con string) []byte {
	m := make(map[string]interface{})
	m[status] = sta
	m[content] = con

	pake, err := json.Marshal(m)
	if err != nil {
		log.LogWarn(logprefix, "警告,编码发送数据包时发生小错误", err)
	}
	return pake
}