Exemplo n.º 1
0
func EC(paramMap map[string]string) interface{} {
	HostAdd := util.GetMMSDAServer()
	client := mcpacknpc.NewClient(HostAdd)
	request := packEC(paramMap)
	reply := new(Reply)
	start := time.Now().Nanosecond() //test
	client.Call(request, reply)
	returnda := parserReply(reply)
	beego.Notice("++++daTime+++++", (time.Now().Nanosecond() - start)) //test
	if paramMap["tp"] == "api" {
		return returnda
	} else {
		baidu := baidubase64.NewBaiduB64()
		retMap := make(map[string]interface{}, 1)
		retByte, err := json.Marshal(returnda)
		if err != nil {
			beego.Notice("json error:", err)
			return returnda
		}
		retMap["data"] = baidu.BaiduB64Encode(string(retByte), 0)
		//retMap["data"] = base64.StdEncoding.EncodeToString(retByte)
		return retMap
	}

}
Exemplo n.º 2
0
func CQ(paramMap map[string]string) *ReturnMMSDA {
	//server := []string{HostAdd}
	HostAdd := util.GetMMSDAServer()
	client := mcpacknpc.NewClient(HostAdd)
	request := packCQ(paramMap)
	reply := new(Reply)
	client.Call(request, reply)
	returnda := parserReply(reply)
	return returnda
}
Exemplo n.º 3
0
func main() {
	sid := make([]uint32, 1)
	sid[0] = 2014
	urlPack := UrlPack{} //UrlPack{voice_search: 2}
	urlPack.Voice_search = 2
	byteUrlPack, _ := mcpack.Marshal(urlPack)
	normalreq := Normalreq{} //{sid: sid, rsse_num: 10, rsse_type: 139}
	normalreq.Sid = sid
	normalreq.Rsse_num = 10
	normalreq.Rsse_type = 139
	normalreq.UrlPack = byteUrlPack
	//	cd, err := iconv.Open("gbk", "utf-8")
	//	if err != nil {
	//		fmt.Println(err)
	//	}
	//	gbk := cd.ConvString("失落伐克欧洲杯")
	enc := mahonia.NewEncoder("gbk")
	gbk := enc.ConvertString("失落伐克欧洲杯")
	normalreq.Word = gbk
	//jsonnormalreq, _ := json.Marshal(normalreq)
	//fmt.Println(string(jsonnormalreq))

	req := Req{}
	req.Cmd = 0
	req.Cmd64 = 0
	cmdreq := make([]uint64, 2)
	cmdreq[0] = 0
	cmdreq[1] = 2097152
	req.Cmdreq = cmdreq
	//req.Sub_cmdreq = cmdreq
	req.Normalreq = normalreq
	request := Request{}
	reqList := make([]Req, 1)
	reqList[0] = req
	request.Req = reqList
	request.Req_module = "imms"
	request.Server = "mmsda"
	///////////////////////
	//	jsonrequest, _ := json.Marshal(request)
	//	fmt.Println(string(jsonrequest))
	//	content, _ := mcpack.Marshal(request)
	//	fmt.Println(hex.Dump(content))
	//	msg := Request{}
	//	mcpack.Unmarshal(content, &msg)
	//	jsonMsg, _ := json.Marshal(msg)
	//	fmt.Println(string(jsonMsg))
	//return
	/////////////////////
	server := []string{HostAdd}
	client := mcpacknpc.NewClient(server)
	reply := new(Reply)
	now := time.Now()
	nanos := now.UnixNano()
	num := make(chan int, 64)
	for i := 0; i < 300000; i++ {
		num <- i
		go mmsda(client, &request, reply, num)
	}
	end := now.UnixNano()
	fmt.Println("time", (end - nanos))
	//	client.Call(request, reply)
	//	fmt.Println(reply)
	//	jsonother, _ := json.Marshal(reply)
	//	fmt.Println(string(jsonother))
	//	dec := mahonia.NewDecoder("gbk")
	//	fmt.Println(dec.ConvertString(reply.Result[0].Normal.Danormalanalysis.Voiceguidesidentify.Fullreplace_query))
	//fmt.Println(reply.Result[0].Normal.Danormalanalysis.Voiceguidesidentify.Fullreplace_query)

}