1
This commit is contained in:
parent
1ab3d3cc9a
commit
9a0acf9f39
@ -6,13 +6,13 @@ import (
|
||||
|
||||
/*
|
||||
http的请求分为两种风格
|
||||
go like: go风格回调的时候不会join主线程,被回调方需要处理线程同步问题
|
||||
js like: js风格回调时候会自动join主线程,被回调方无需处理线程同步问题
|
||||
go style: go风格回调的时候不会join主线程,被回调方需要处理线程同步问题
|
||||
js style: js风格回调时候会自动join主线程,被回调方无需处理线程同步问题
|
||||
*/
|
||||
|
||||
const (
|
||||
GO_LIKE_REQUEST = 1
|
||||
JS_LIKE_REQUEST = 2
|
||||
GO_STYLE_REQUEST = 1
|
||||
JS_STYLE_REQUEST = 2
|
||||
|
||||
NORMAL_CHANNEL = 1
|
||||
QUICK_CHANNEL = 2
|
||||
@ -49,44 +49,44 @@ func (this *HttpCliMgr) init() {
|
||||
func (this *HttpCliMgr) unInit() {
|
||||
}
|
||||
|
||||
func (this *HttpCliMgr) SendGoLikeRequest(
|
||||
func (this *HttpCliMgr) SendGoStyleRequest(
|
||||
url string, params map[string]string,
|
||||
cb func (HttpCliResponse)) {
|
||||
this.internalSendRequest(
|
||||
GO_LIKE_REQUEST,
|
||||
GO_STYLE_REQUEST,
|
||||
NORMAL_CHANNEL,
|
||||
url,
|
||||
params,
|
||||
cb)
|
||||
}
|
||||
|
||||
func (this *HttpCliMgr) SendJsLikeRequest(
|
||||
func (this *HttpCliMgr) SendJsStyleRequest(
|
||||
url string, params map[string]string,
|
||||
cb func (HttpCliResponse)) {
|
||||
this.internalSendRequest(
|
||||
JS_LIKE_REQUEST,
|
||||
JS_STYLE_REQUEST,
|
||||
NORMAL_CHANNEL,
|
||||
url,
|
||||
params,
|
||||
cb)
|
||||
}
|
||||
|
||||
func (this *HttpCliMgr) SendQuickChannelGoLikeRequest(
|
||||
func (this *HttpCliMgr) SendQuickChannelGoStyleRequest(
|
||||
url string, params map[string]string,
|
||||
cb func (HttpCliResponse)) {
|
||||
this.internalSendRequest(
|
||||
GO_LIKE_REQUEST,
|
||||
GO_STYLE_REQUEST,
|
||||
QUICK_CHANNEL,
|
||||
url,
|
||||
params,
|
||||
cb)
|
||||
}
|
||||
|
||||
func (this *HttpCliMgr) SendQuickChannelJsLikeRequest(
|
||||
func (this *HttpCliMgr) SendQuickChannelJsStyleRequest(
|
||||
url string, params map[string]string,
|
||||
cb func (HttpCliResponse)) {
|
||||
this.internalSendRequest(
|
||||
JS_LIKE_REQUEST,
|
||||
JS_STYLE_REQUEST,
|
||||
QUICK_CHANNEL,
|
||||
url,
|
||||
params,
|
||||
@ -97,7 +97,7 @@ func (this *HttpCliMgr) internalSendRequest(
|
||||
style int32, channel int32,
|
||||
url string, params map[string]string,
|
||||
cb func (HttpCliResponse)) {
|
||||
if !(style == GO_LIKE_REQUEST || style == JS_LIKE_REQUEST) {
|
||||
if !(style == GO_STYLE_REQUEST || style == JS_STYLE_REQUEST) {
|
||||
panic("HttpCliMgr sytel error")
|
||||
}
|
||||
if !(channel == NORMAL_CHANNEL || channel == QUICK_CHANNEL) {
|
||||
@ -110,7 +110,7 @@ func (this *HttpCliMgr) internalSendRequest(
|
||||
}
|
||||
rsp := new(httpCliResponse)
|
||||
rsp.init(data, err)
|
||||
if style == GO_LIKE_REQUEST {
|
||||
if style == GO_STYLE_REQUEST {
|
||||
cb(rsp)
|
||||
} else {
|
||||
_app.AddIMMsg(IM_HTTP_CLI_MGR_RESPONSE, []interface{} {
|
||||
|
Loading…
x
Reference in New Issue
Block a user