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); } 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{} { diff --git a/prototils.go b/prototils.go index eb700ba..612f38f 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,22 @@ type WSProxyPackHead_S struct { ExtLen uint16 } +func (this *WspCliConn) IsValid() bool { + return this.Conn == nil || this.SocketHandle == 0 +} + +func (this *WspCliConn) Reset() { + this.Conn = nil + 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])