当前位置:网站首页>Unity sends a post request to the golang server for parsing and returning
Unity sends a post request to the golang server for parsing and returning
2022-07-29 07:13:00 【Handsome_ shuai_】
Unity send out Post Request to GoLang The server parses and returns
Use Unity send out Post Ask to GoLang Of Http The server ,Http After receiving the response, the server returns it to the client program
GoLang
type ServerHttp struct {
HttpServerName string
}
func NewServerHttp(serverName string) *ServerHttp {
s := &ServerHttp{
HttpServerName: serverName,
}
return s
}
func (s *ServerHttp) Serve() {
go func() {
http.HandleFunc("/Account", s.accountHandle)
serverHttp := &http.Server{
Addr: global.HttpServerUrl,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
err := serverHttp.ListenAndServe()
if err != nil {
logger.PopError(err)
return
}
logger.PopDebug("========Http The server is turned on successfully !!!========")
select {
}
}()
}
func (s *ServerHttp) accountHandle(resWriter http.ResponseWriter, req *http.Request) {
err := req.ParseForm()
if err != nil {
fmt.Println(err)
return
}
val := req.Form.Get("id")
fmt.Println(val)
_, err = resWriter.Write([]byte(val))
if err != nil {
fmt.Println(err)
return
}
}
Unity
IEnumerator Start()
{
WWWForm wwwForm = new WWWForm();
wwwForm.AddField("id",666);
UnityWebRequest webRequest = UnityWebRequest.Post("http://127.0.0.1:9301/Account", wwwForm);
yield return webRequest.SendWebRequest();
if (webRequest.error!=null)
{
Debug.LogWarning(webRequest.error);
}
Debug.Log(webRequest.downloadHandler.text);
}
边栏推荐
- 上采样之反卷积操作
- 最新百亿量化私募名单
- Record - step on the pit - real-time data warehouse development - doris/pg/flink
- MySQL 有这一篇就够(呕心狂敲37k字,只为博君一点赞!!!)
- Simulation volume leetcode [general] 150. evaluation of inverse Polish expression
- Operator3-设计一个operator
- 以太网接口介绍
- Image noise and matrix inversion
- 基于C语言实现图书借阅管理系统
- 1172. The plate stack has a sequence table + stack
猜你喜欢

最新百亿量化私募名单

Vite3.0都发布了,你还能卷得动吗(新特性一览)

win11系统错误:由于找不到 iertutil.dll,无法继续执行代码。重新安装程序可能会解决此问题

Record - step on the pit - real-time data warehouse development - doris/pg/flink

Problems encountered in vmware16 installing virtual machines

buck电路boot和ph引脚实测

CVPR2022Oral专题系列(一):低光增强

dba

JS 鸡生蛋与蛋生鸡问题,Object与Function究竟谁出现的更早?Function算不算Function的实例?

OCR光学字符识别方法汇总
随机推荐
Unity发送Post请求给GoLang服务端解析并返回
基于C语言设计的学生成绩排名系统
以太网接口介绍
Flink实时仓库-DWD层(交易域-加购维度退化处理)模板代码
Some tips of vim text editor
Nodejs安装教程
VMware16创建虚拟机:无法创建新虚拟机,不具备执行此操作的权限
使用VsCode配置MySQL实现连接、查询、等功能
Hj37 statistics of the total number of rabbits per month Fibonacci series
Cesium reflection
剑指 Offer II 115:重建序列
Improved pillar with fine grained feature for 3D object detection paper notes
Redis基础篇
模拟卷Leetcode【普通】222. 完全二叉树的节点个数
模拟卷Leetcode【普通】150. 逆波兰表达式求值
LeetCode 879. 盈利计划
Revolution of game assets
Analog volume leetcode [normal] 093. Restore IP address
[cf1054h] epic Revolution -- number theory, convolution, arbitrary modulus NTT
聊天机器人有何用处?有何类型?看完这些就明白了!