Merge branch 'master' of git.kingsome.cn:server_common/f5

This commit is contained in:
殷勇 2023-08-14 14:03:37 +08:00
commit d8e8140172
3 changed files with 39 additions and 15 deletions

View File

@ -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);
}

View File

@ -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{} {

View File

@ -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])