示例#1
0
func Callback(param json.JSONObject) {
	if param != nil {
		is, aux := param.GetJSON("aux")
		if is {
			iss, arr := aux.GetArray("from")
			if iss {
				last, isss := arr.GetLast().(string)
				if isss {
					call_map[last](param)
					aux.RemoveLast("from")
				}
			}
		}
	}
}
示例#2
0
func CallbackWithFailResult(param json.JSONObject, reason string) {
	if param != nil {
		if !param.HasMember("result") {
			result := json.NewJSONEmpty()
			param.Put("result", result)
		}

		ok, result := param.GetJSON("result")
		if ok {
			result.Put("success", false)
			result.Put("reason", reason)
		}
		Callback(param)
	}
}
示例#3
0
func ExecuteCmd1(param json.JSONObject, callback function_callback) {
	if param != nil {
		aux_ok, aux := param.GetJSON("aux")
		if aux_ok {
			name_ok, name := aux.GetString("to")
			if name_ok {
				ExecuteCmd(name, param, callback)
			} else {
				log.E_COM("execute cmd error, reason : aux has not name paramter")
			}
		} else {
			log.E_COM("execute cmd error, reason : param has not aux paramter")
		}
	} else {
		log.E_COM("execute cmd error, reason : param is nil")
	}
}
示例#4
0
func CallbackWithSuccessResult(param json.JSONObject, data json.JSONObject) {
	if param != nil {
		if !param.HasMember("result") {
			result := json.NewJSONEmpty()
			param.Put("result", result)
		}

		ok, result := param.GetJSON("result")
		if ok {
			result.Put("success", true)
			if data != nil {
				result.Put("data", data)
			} else {
				result.Put("data", json.NewJSONEmpty())
			}
		}
		Callback(param)
	}
}