1
This commit is contained in:
@@ -44,6 +44,7 @@ func SendToVendor(msg []byte) {
|
||||
return
|
||||
}
|
||||
Send(temp, sendData.Data.(map[string]interface{})["app_id"])
|
||||
return
|
||||
}
|
||||
if sendData.VendorID == VendorIDELM {
|
||||
param := sendData.Data.(ebaiapi.BusinessSendMsgReq)
|
||||
@@ -53,18 +54,6 @@ func SendToVendor(msg []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
//if err != nil {
|
||||
// ClientRender(Fail, FailMsg, map[string]string{
|
||||
// "errMsg": fmt.Sprintf("%v", err),
|
||||
// })
|
||||
// return err
|
||||
//} else {
|
||||
// ClientRender(SuccessCode, SuccessMsg, map[string]interface{}{
|
||||
// "vendorID": sendData.VendorID,
|
||||
// "msg": "ok",
|
||||
// })
|
||||
// return nil
|
||||
//}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -92,16 +81,16 @@ func Send(data []byte, appID interface{}) {
|
||||
for {
|
||||
_, msg, err := conn.ReadMessage()
|
||||
temp := string(msg)
|
||||
res := JsonCommon(HeartSuccessWord)
|
||||
fmt.Printf("Send %s receive: %s\n", conn.RemoteAddr(), string(msg))
|
||||
if err != nil {
|
||||
break
|
||||
} else if temp == res {
|
||||
continue
|
||||
} else {
|
||||
if temp != HeartSuccessWord {
|
||||
ReadMsgFromVendor(VendorIDMT, "", msg)
|
||||
}
|
||||
ReadMsgFromVendor(VendorIDMT, "", msg)
|
||||
}
|
||||
fmt.Printf("%s receive: %s\n", conn.RemoteAddr(), string(msg))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// MtInit 发送心跳
|
||||
@@ -135,53 +124,57 @@ func MtInit() {
|
||||
for {
|
||||
_, msg, err := conn.ReadMessage()
|
||||
temp := string(msg)
|
||||
if err != nil || temp != "HB" {
|
||||
res := JsonCommon(HeartCheckSuccess)
|
||||
fmt.Printf("MtInit %s receive: %s\n", conn.RemoteAddr(), string(msg))
|
||||
if err != nil {
|
||||
break
|
||||
} else if temp == res {
|
||||
continue
|
||||
} else {
|
||||
ReadMsgFromVendor(VendorIDMT, "", msg)
|
||||
}
|
||||
fmt.Printf("%s receive: %s\n", conn.RemoteAddr(), string(msg))
|
||||
}
|
||||
}, url.ClientIDMain)
|
||||
|
||||
//副连接
|
||||
if url.UrlSub != "" {
|
||||
jxutils.CallMsgHandlerAsync(func() {
|
||||
connSub, respSub, errSub := websocket.DefaultDialer.Dial(url.UrlSub, nil)
|
||||
if errSub != nil || respSub.StatusCode != 101 {
|
||||
fmt.Printf("连接失败:%v http响应不成功", errSub)
|
||||
}
|
||||
|
||||
//关闭
|
||||
defer func(conn *websocket.Conn) {
|
||||
err := conn.Close()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}(connSub)
|
||||
|
||||
//client连接事件
|
||||
client := NewClient(url.ClientIDSub, connSub, ClientTypeMt)
|
||||
Manager.Connect <- client
|
||||
|
||||
errSub = connSub.WriteMessage(websocket.TextMessage, data)
|
||||
if errSub != nil {
|
||||
fmt.Println(errSub)
|
||||
}
|
||||
|
||||
for {
|
||||
_, msg, err := connSub.ReadMessage()
|
||||
temp := string(msg)
|
||||
if err != nil || temp != HeartCheckSuccess {
|
||||
break
|
||||
} else {
|
||||
ReadMsgFromVendor(VendorIDMT, "", msg)
|
||||
}
|
||||
fmt.Printf("%s connSub:receive: %s\n", connSub.RemoteAddr(), string(msg))
|
||||
}
|
||||
|
||||
}, url.ClientIDSub)
|
||||
}
|
||||
//if url.UrlSub != "" {
|
||||
// jxutils.CallMsgHandlerAsync(func() {
|
||||
// connSub, respSub, errSub := websocket.DefaultDialer.Dial(url.UrlSub, nil)
|
||||
// if errSub != nil || respSub.StatusCode != 101 {
|
||||
// fmt.Printf("连接失败:%v http响应不成功", errSub)
|
||||
// }
|
||||
//
|
||||
// //关闭
|
||||
// defer func(conn *websocket.Conn) {
|
||||
// err := conn.Close()
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
// }(connSub)
|
||||
//
|
||||
// //client连接事件
|
||||
// client := NewClient(url.ClientIDSub, connSub, ClientTypeMt)
|
||||
// Manager.Connect <- client
|
||||
//
|
||||
// errSub = connSub.WriteMessage(websocket.TextMessage, data)
|
||||
// if errSub != nil {
|
||||
// fmt.Println(errSub)
|
||||
// }
|
||||
//
|
||||
// for {
|
||||
// _, msg, err := connSub.ReadMessage()
|
||||
// temp := string(msg)
|
||||
// res := JsonCommon(HeartCheckSuccess)
|
||||
// if err != nil || temp == res {
|
||||
// break
|
||||
// } else {
|
||||
// ReadMsgFromVendor(VendorIDMT, "", msg)
|
||||
// }
|
||||
// fmt.Printf("MtInit %s connSub:receive: %s\n", connSub.RemoteAddr(), string(msg))
|
||||
// }
|
||||
//
|
||||
// }, url.ClientIDSub)
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user