1
This commit is contained in:
parent
803c5d7912
commit
f60162262a
@ -18,6 +18,14 @@ const (
|
|||||||
QUICK_CHANNEL = 2
|
QUICK_CHANNEL = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type HttpCliRequestHandle interface {
|
||||||
|
Cancel() bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type httpCliRequestHandleImpl struct {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
type HttpCliResponse interface {
|
type HttpCliResponse interface {
|
||||||
GetErr() error
|
GetErr() error
|
||||||
GetJsonData() map[string]interface{}
|
GetJsonData() map[string]interface{}
|
||||||
@ -35,6 +43,10 @@ type httpCliResponse struct {
|
|||||||
type httpCliMgr struct {
|
type httpCliMgr struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *httpCliRequestHandleImpl) Cancel() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (this *httpCliMgr) init() {
|
func (this *httpCliMgr) init() {
|
||||||
_app.RegisterIMMsgHandle(
|
_app.RegisterIMMsgHandle(
|
||||||
IM_HTTP_CLI_MGR_RESPONSE,
|
IM_HTTP_CLI_MGR_RESPONSE,
|
||||||
@ -50,8 +62,8 @@ func (this *httpCliMgr) unInit() {
|
|||||||
|
|
||||||
func (this *httpCliMgr) SendGoStyleRequest(
|
func (this *httpCliMgr) SendGoStyleRequest(
|
||||||
url string, params map[string]string,
|
url string, params map[string]string,
|
||||||
cb func(HttpCliResponse)) {
|
cb func(HttpCliResponse)) HttpCliRequestHandle {
|
||||||
this.internalSendRequest(
|
return this.internalSendRequest(
|
||||||
GO_STYLE_REQUEST,
|
GO_STYLE_REQUEST,
|
||||||
NORMAL_CHANNEL,
|
NORMAL_CHANNEL,
|
||||||
url,
|
url,
|
||||||
@ -83,8 +95,8 @@ func (this *httpCliMgr) SyncSendGoStyleRequest(
|
|||||||
|
|
||||||
func (this *httpCliMgr) SendJsStyleRequest(
|
func (this *httpCliMgr) SendJsStyleRequest(
|
||||||
url string, params map[string]string,
|
url string, params map[string]string,
|
||||||
cb func(HttpCliResponse)) {
|
cb func(HttpCliResponse)) HttpCliRequestHandle {
|
||||||
this.internalSendRequest(
|
return this.internalSendRequest(
|
||||||
JS_STYLE_REQUEST,
|
JS_STYLE_REQUEST,
|
||||||
NORMAL_CHANNEL,
|
NORMAL_CHANNEL,
|
||||||
url,
|
url,
|
||||||
@ -94,8 +106,8 @@ func (this *httpCliMgr) SendJsStyleRequest(
|
|||||||
|
|
||||||
func (this *httpCliMgr) SendQuickChannelGoStyleRequest(
|
func (this *httpCliMgr) SendQuickChannelGoStyleRequest(
|
||||||
url string, params map[string]string,
|
url string, params map[string]string,
|
||||||
cb func(HttpCliResponse)) {
|
cb func(HttpCliResponse)) HttpCliRequestHandle {
|
||||||
this.internalSendRequest(
|
return this.internalSendRequest(
|
||||||
GO_STYLE_REQUEST,
|
GO_STYLE_REQUEST,
|
||||||
QUICK_CHANNEL,
|
QUICK_CHANNEL,
|
||||||
url,
|
url,
|
||||||
@ -105,8 +117,8 @@ func (this *httpCliMgr) SendQuickChannelGoStyleRequest(
|
|||||||
|
|
||||||
func (this *httpCliMgr) SendQuickChannelJsStyleRequest(
|
func (this *httpCliMgr) SendQuickChannelJsStyleRequest(
|
||||||
url string, params map[string]string,
|
url string, params map[string]string,
|
||||||
cb func(HttpCliResponse)) {
|
cb func(HttpCliResponse)) HttpCliRequestHandle {
|
||||||
this.internalSendRequest(
|
return this.internalSendRequest(
|
||||||
JS_STYLE_REQUEST,
|
JS_STYLE_REQUEST,
|
||||||
QUICK_CHANNEL,
|
QUICK_CHANNEL,
|
||||||
url,
|
url,
|
||||||
@ -117,13 +129,14 @@ func (this *httpCliMgr) SendQuickChannelJsStyleRequest(
|
|||||||
func (this *httpCliMgr) internalSendRequest(
|
func (this *httpCliMgr) internalSendRequest(
|
||||||
style int32, channel int32,
|
style int32, channel int32,
|
||||||
url string, params map[string]string,
|
url string, params map[string]string,
|
||||||
cb func(HttpCliResponse)) {
|
cb func(HttpCliResponse)) HttpCliRequestHandle {
|
||||||
if !(style == GO_STYLE_REQUEST || style == JS_STYLE_REQUEST) {
|
if !(style == GO_STYLE_REQUEST || style == JS_STYLE_REQUEST) {
|
||||||
panic("httpCliMgr sytel error")
|
panic("httpCliMgr sytel error")
|
||||||
}
|
}
|
||||||
if !(channel == NORMAL_CHANNEL || channel == QUICK_CHANNEL) {
|
if !(channel == NORMAL_CHANNEL || channel == QUICK_CHANNEL) {
|
||||||
panic("httpCliMgr channel error")
|
panic("httpCliMgr channel error")
|
||||||
}
|
}
|
||||||
|
handle := &httpCliRequestHandleImpl{}
|
||||||
doFunc := func() {
|
doFunc := func() {
|
||||||
data, err := q5.HttpGet(url, params)
|
data, err := q5.HttpGet(url, params)
|
||||||
if cb == nil {
|
if cb == nil {
|
||||||
@ -141,6 +154,7 @@ func (this *httpCliMgr) internalSendRequest(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
go doFunc()
|
go doFunc()
|
||||||
|
return handle
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *httpCliResponse) init(data string, err error) {
|
func (this *httpCliResponse) init(data string, err error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user