From 9a0acf9f39369b15cb8b0e277897ef5ce1ec5abb Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 14 Aug 2023 13:20:34 +0800 Subject: [PATCH 1/6] 1 --- httpclimgr.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/httpclimgr.go b/httpclimgr.go index 13a175a..27c5910 100644 --- a/httpclimgr.go +++ b/httpclimgr.go @@ -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{} { From 8dd91e03f2c1da32a0f828f65337c450aa1a3bd9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 14 Aug 2023 13:26:54 +0800 Subject: [PATCH 2/6] 1 --- prototils.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/prototils.go b/prototils.go index eb700ba..62f51e7 100644 --- a/prototils.go +++ b/prototils.go @@ -5,6 +5,11 @@ import ( "net" ) +type WspCliConn struct { + Conn net.Conn + SocketHandle uint16 +} + type MsgHdr struct { MsgId uint16 SeqId uint32 @@ -67,6 +72,15 @@ type WSProxyPackHead_S struct { ExtLen uint16 } +func (this *WspCliConn) IsValid() bool { + return this.Conn == nil || this.SocketHandle == 0 +} + +func (this *WspCliConn) Reset() bool { + this.Conn = nil + this.SocketHandle == 0 +} + func (this *WSProxyPackHead_C) Read(data []byte, offset int) { this.PackLen = q5.MkUInt16(data[offset + 0], data[offset + 1]) this.MsgId = q5.MkUInt16(data[offset + 2], data[offset + 3]) From 346ae3ac4aea0ac347a90a629d08c63dc4c4b885 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 14 Aug 2023 13:28:25 +0800 Subject: [PATCH 3/6] 1 --- prototils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prototils.go b/prototils.go index 62f51e7..1bc761a 100644 --- a/prototils.go +++ b/prototils.go @@ -78,7 +78,7 @@ func (this *WspCliConn) IsValid() bool { func (this *WspCliConn) Reset() bool { this.Conn = nil - this.SocketHandle == 0 + this.SocketHandle = 0 } func (this *WSProxyPackHead_C) Read(data []byte, offset int) { From 3aa17f7c0744e102d7720f16801b4b2bd2693c95 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 14 Aug 2023 13:29:05 +0800 Subject: [PATCH 4/6] 1 --- prototils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prototils.go b/prototils.go index 1bc761a..f446eab 100644 --- a/prototils.go +++ b/prototils.go @@ -76,7 +76,7 @@ func (this *WspCliConn) IsValid() bool { return this.Conn == nil || this.SocketHandle == 0 } -func (this *WspCliConn) Reset() bool { +func (this *WspCliConn) Reset() { this.Conn = nil this.SocketHandle = 0 } From 7c4682d82b60d39963b55f9bd7f5db567067f022 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 14 Aug 2023 13:33:49 +0800 Subject: [PATCH 5/6] 1 --- prototils.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/prototils.go b/prototils.go index f446eab..612f38f 100644 --- a/prototils.go +++ b/prototils.go @@ -81,6 +81,13 @@ func (this *WspCliConn) Reset() { this.SocketHandle = 0 } +func (this *MsgHdr) GetSocket() WspCliConn{ + socket := WspCliConn{} + socket.Conn = this.Conn + socket.SocketHandle = this.SocketHandle + return socket +} + func (this *WSProxyPackHead_C) Read(data []byte, offset int) { this.PackLen = q5.MkUInt16(data[offset + 0], data[offset + 1]) this.MsgId = q5.MkUInt16(data[offset + 2], data[offset + 3]) From 7e8d448ef7ba407e6f663e25041f087282f90e61 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 14 Aug 2023 13:59:50 +0800 Subject: [PATCH 6/6] 1 --- dataset.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dataset.go b/dataset.go index 26460d7..ff7027a 100644 --- a/dataset.go +++ b/dataset.go @@ -11,6 +11,7 @@ type DataSet struct { } func (this *DataSet) Next() bool { + ret := this.rows.Next() this.GetColumns() this.values = []interface{}{} for i := 0 ; i < len(this.columns); i++ { @@ -18,7 +19,7 @@ func (this *DataSet) Next() bool { this.values = append(this.values, &str) } this.rows.Scan(this.values...) - return this.rows.Next() + return ret } func (this *DataSet) GetColumns() []string { @@ -32,6 +33,7 @@ func (this *DataSet) GetColumns() []string { } func (this *DataSet) GetByName(name string) *string { + this.GetColumns() for i := 0; i < len(this.columns); i++ { if this.columns[i] == name { return this.GetByIndex(int32(i)) @@ -41,6 +43,7 @@ func (this *DataSet) GetByName(name string) *string { } func (this *DataSet) GetByIndex(index int32) *string { + this.GetColumns() return this.values[index].(*string); }