Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
donnie4w committed Feb 12, 2023
1 parent bd87637 commit 18c7847
Show file tree
Hide file tree
Showing 265 changed files with 107,280 additions and 106,779 deletions.
3 changes: 2 additions & 1 deletion tim.DB/db.go → DB/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"database/sql"
"os"

. "tim/common"

"github.com/donnie4w/go-logger/logger"
_ "github.com/go-sql-driver/mysql"
. "tim.common"
)

var Master *sql.DB
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tim.base64Util/base64.go → base64Util/base64.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"encoding/base64"
)

func Base64Encode(src []byte) string {
func Base64Encode(bs []byte) string {
// return []byte(coder.EncodeToString(src))
return base64.StdEncoding.EncodeToString(src)
return base64.StdEncoding.EncodeToString(bs)
}

func Base64Decode(src string) ([]byte, error) {
Expand Down
35 changes: 19 additions & 16 deletions tim.client/client.go → client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
package client

import (
"context"
"errors"
"fmt"
"os"
"runtime/debug"
"sync"
"time"

"git.apache.org/thrift.git/lib/go/thrift"
. "tim/protocol"
"tim/route"

"github.com/apache/thrift/lib/go/thrift"
"github.com/donnie4w/go-logger/logger"
. "tim.protocol"
"tim.route"
)

type FLOW string
Expand All @@ -41,6 +43,7 @@ type Connect struct {
Client *ITimClient
FlowConnect FLOW
Super *Cli
ts *thrift.TSocket
}

func (this *Connect) Close() {
Expand All @@ -50,9 +53,9 @@ func (this *Connect) Close() {
logger.Error(string(debug.Stack()))
}
}()
if this.Client != nil && this.Client.Transport != nil && this.FlowConnect != CONNECT_STOP {
if this.Client != nil && this.ts != nil && this.FlowConnect != CONNECT_STOP {
this.FlowConnect = CONNECT_STOP
this.Client.Transport.Close()
this.ts.Close()
}
}

Expand Down Expand Up @@ -200,7 +203,7 @@ func (this *Cli) SendMBean(mbean *TimMBean) (err error) {
}
}
if this.Addr != "" {
err = this.Connect.Client.TimMessage(mbean)
err = this.Connect.Client.TimMessage(context.Background(), mbean)
Confirm.Add(mbean.GetThreadId(), mbean)
}
} else {
Expand Down Expand Up @@ -238,7 +241,7 @@ func (this *Cli) SendPBean(pbean *TimPBean) (err error) {
}
}
if this.Addr != "" {
err = this.Connect.Client.TimPresence(pbean)
err = this.Connect.Client.TimPresence(context.Background(), pbean)
if err != nil {
logger.Error("SendPBean error:", err.Error())
}
Expand All @@ -257,7 +260,7 @@ func (this *Cli) DisConnect() {
}
}()
if this != nil && this.Connect != nil {
this.Connect.Client.Transport.Close()
this.Connect.Close()
}
}

Expand All @@ -271,7 +274,7 @@ func (this *Cli) Ack(ab *TimAckBean) {
this.Sync.Lock()
defer this.Sync.Unlock()
if this != nil && this.Connect != nil && this.Flow == AUTH {
this.Connect.Client.TimAck(ab)
this.Connect.Client.TimAck(context.Background(), ab)
}
}

Expand All @@ -284,7 +287,7 @@ func (this *Cli) Close() {
}()
if this != nil && this.Connect != nil {
this.Flow = CLOSE
this.Connect.Client.Transport.Close()
this.Connect.Close()
}
}

Expand Down Expand Up @@ -323,7 +326,7 @@ func (this *Cli) Ping() {
logger.Debug("client ping>>>>>>>>>>>>>>>>>")
this.Sync.Lock()
defer this.Sync.Unlock()
err = this.Connect.Client.TimPing(fmt.Sprint(currentTimeMillis()))
err = this.Connect.Client.TimPing(context.Background(), fmt.Sprint(currentTimeMillis()))
logger.Debug("client ping<<<<<<<<<<<<<<<<<")
return
}()
Expand Down Expand Up @@ -352,12 +355,12 @@ func (this *Cli) Login() (err error) {
fmt.Fprintln(os.Stderr, "error resolving address:", err)
return
}
useTransport := transportFactory.GetTransport(transport)
useTransport, _ := transportFactory.GetTransport(transport)
timclient := NewITimClientFactory(useTransport, protocolFactory)
if this.Connect != nil {
this.Connect.Close()
}
this.Connect = &Connect{FlowConnect: CONNECT_START}
this.Connect = &Connect{FlowConnect: CONNECT_START, ts: transport}
this.Connect.setITimClient(timclient)
this.Connect.Super = this
if err = transport.Open(); err != nil {
Expand All @@ -369,7 +372,7 @@ func (this *Cli) Login() (err error) {
tid := new(Tid)
resource := "goclient"
tid.Domain, tid.Resource, tid.Name = this.Domain, &resource, this.Name
err = timclient.TimLogin(tid, this.Pwd)
err = timclient.TimLogin(context.Background(), tid, this.Pwd)
if err != nil {
logger.Error("cluster login err", err)
this.ReConnLimit++
Expand All @@ -396,7 +399,7 @@ func (this *Connect) processor(processorchan chan int) {
handler := new(TimImpl)
// handler.Client = this.Super
processor := NewITimProcessor(handler)
protocol := thrift.NewTCompactProtocol(this.Client.Transport)
protocol := thrift.NewTCompactProtocol(this.ts)
for {
if this == nil || this.FlowConnect == CONNECT_STOP {
break
Expand All @@ -405,7 +408,7 @@ func (this *Connect) processor(processorchan chan int) {
this.FlowConnect = CONNECT_RUN
processorchan <- 1
}
b, err := processor.Process(protocol, protocol)
b, err := processor.Process(context.Background(), protocol, protocol)
if err != nil && !b {
logger.Error("cluster processor error:", err.Error())
break
Expand Down
81 changes: 31 additions & 50 deletions tim.client/clientTimImpl.go → client/clientTimImpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
package client

import (
"context"
"errors"
"fmt"
// "time"
// "runtime/debug"

. "tim/common"
"tim/daoService"
. "tim/protocol"
"tim/route"
"tim/utils"

"github.com/donnie4w/go-logger/logger"
. "tim.common"
"tim.daoService"
. "tim.protocol"
"tim.route"
"tim.utils"
)

type TimImpl struct {
Expand All @@ -25,100 +25,87 @@ type TimImpl struct {

// Parameters:
// - Param
func (this *TimImpl) TimStream(param *TimParam) (err error) {
func (this *TimImpl) TimStream(ctx context.Context, param *TimParam) (err error) {
panic("error")
return
}
func (this *TimImpl) TimStarttls() (err error) {
func (this *TimImpl) TimStarttls(ctx context.Context) (err error) {
panic("error")
return
}

// Parameters:
// - Tid
// - Pwd
func (this *TimImpl) TimLogin(tid *Tid, pwd string) (err error) {
func (this *TimImpl) TimLogin(ctx context.Context, tid *Tid, pwd string) (err error) {
logger.Debug("Login:", tid, pwd)
panic("error")
return
}

// Parameters:
// - Ab
func (this *TimImpl) TimAck(ab *TimAckBean) (err error) {
func (this *TimImpl) TimAck(ctx context.Context, ab *TimAckBean) (err error) {
logger.Debug("TimAck=========>", ab)
panic("error")
return
}

// Parameters:
// - Pbean
func (this *TimImpl) TimPresence(pbean *TimPBean) (err error) {
func (this *TimImpl) TimPresence(ctx context.Context, pbean *TimPBean) (err error) {
logger.Debug(pbean)
panic("error")
return
}

// Parameters:
// - Mbean
func (this *TimImpl) TimMessage(mbean *TimMBean) (err error) {
func (this *TimImpl) TimMessage(ctx context.Context, mbean *TimMBean) (err error) {
logger.Debug(mbean)
panic("error")
return
}

// Parameters:
// - ThreadId
func (this *TimImpl) TimPing(threadId string) (err error) {
func (this *TimImpl) TimPing(ctx context.Context, threadId string) (err error) {
panic("error")
return
}

// Parameters:
// - E
func (this *TimImpl) TimError(e *TimError) (err error) {
func (this *TimImpl) TimError(ctx context.Context, e *TimError) (err error) {
panic("error")
return
}
func (this *TimImpl) TimLogout() (err error) {
func (this *TimImpl) TimLogout(ctx context.Context) (err error) {
panic("error")
return
}

// Parameters:
// - Tid
// - Pwd
func (this *TimImpl) TimRegist(tid *Tid, pwd string) (err error) {
func (this *TimImpl) TimRegist(ctx context.Context, tid *Tid, pwd string) (err error) {
panic("error")
return
}

// Parameters:
// - Tid
// - Pwd
func (this *TimImpl) TimRemoteUserAuth(tid *Tid, pwd string, auth *TimAuth) (r *TimRemoteUserBean, err error) {
func (this *TimImpl) TimRemoteUserAuth(ctx context.Context, id *Tid, pwd string, auth *TimAuth) (r *TimRemoteUserBean, err error) {
panic("error")
return
}

// Parameters:
// - Tid
func (this *TimImpl) TimRemoteUserGet(tid *Tid, auth *TimAuth) (r *TimRemoteUserBean, err error) {
func (this *TimImpl) TimRemoteUserGet(ctx context.Context, tid *Tid, auth *TimAuth) (r *TimRemoteUserBean, err error) {
panic("error")
return
}

// Parameters:
// - Tid
// - Ub
func (this *TimImpl) TimRemoteUserEdit(tid *Tid, ub *TimUserBean, auth *TimAuth) (r *TimRemoteUserBean, err error) {
func (this *TimImpl) TimRemoteUserEdit(ctx context.Context, tid *Tid, ub *TimUserBean, auth *TimAuth) (r *TimRemoteUserBean, err error) {
panic("error")
return
}

// Parameters:
// - Pbean
func (this *TimImpl) TimResponsePresence(pbean *TimPBean, auth *TimAuth) (r *TimResponseBean, err error) {
func (this *TimImpl) TimResponsePresence(ctx context.Context, pbean *TimPBean, auth *TimAuth) (r *TimResponseBean, err error) {
logger.Debug("TimResponsePresence", pbean, auth)
if !checkAuth(auth) {
err = errors.New(fmt.Sprint("cluster auth fail:", auth))
Expand All @@ -144,7 +131,7 @@ func _TimResponsePresence(pbean *TimPBean, auth *TimAuth) (r *TimResponseBean, e

// Parameters:
// - Mbean
func (this *TimImpl) TimResponseMessage(mbean *TimMBean, auth *TimAuth) (r *TimResponseBean, err error) {
func (this *TimImpl) TimResponseMessage(ctx context.Context, mbean *TimMBean, auth *TimAuth) (r *TimResponseBean, err error) {
logger.Debug("TimResponseMessage", mbean, auth)
if !checkAuth(auth) {
err = errors.New(fmt.Sprint("cluster auth fail:", auth))
Expand Down Expand Up @@ -184,24 +171,21 @@ func _TimResponseMessage(mbean *TimMBean, auth *TimAuth) (r *TimResponseBean, er
return
}

func (this *TimImpl) TimMessageIq(timMsgIq *TimMessageIq, iqType string) (err error) {
func (this *TimImpl) TimMessageIq(ctx context.Context, timMsgIq *TimMessageIq, iqType string) (err error) {
logger.Debug("TimMessageIq:", timMsgIq, " ", iqType)
panic("error")
return
}

// Parameters:
// - Mbean
func (this *TimImpl) TimMessageResult_(mbean *TimMBean) (err error) {
func (this *TimImpl) TimMessageResult_(ctx context.Context, mbean *TimMBean) (err error) {
logger.Debug("TimMessageResult_:", mbean)
panic("error")
return
}

func (this *TimImpl) TimRoser(roster *TimRoster) (err error) {
func (this *TimImpl) TimRoser(ctx context.Context, roster *TimRoster) (err error) {
logger.Debug("TimRoser:", roster)
panic("error")
return
}

func checkAuth(a *TimAuth) bool {
Expand All @@ -211,27 +195,24 @@ func checkAuth(a *TimAuth) bool {
return false
}

func (this *TimImpl) TimResponseMessageIq(timMsgIq *TimMessageIq, iqType string, auth *TimAuth) (r *TimMBeanList, err error) {
func (this *TimImpl) TimResponseMessageIq(ctx context.Context, timMsgIq *TimMessageIq, iqType string, auth *TimAuth) (r *TimMBeanList, err error) {
logger.Debug("TimResponseMessageIq:", timMsgIq, iqType, auth)
panic("error TimResponseMessageIq")
return
}

func (this *TimImpl) TimMessageList(mbeanList *TimMBeanList) (err error) {
func (this *TimImpl) TimMessageList(ctx context.Context, mbeanList *TimMBeanList) (err error) {
logger.Debug("TimMessageList:", mbeanList)
panic("error TimMessageList")
return
}

// Parameters:
// - PbeanList
func (this *TimImpl) TimPresenceList(pbeanList *TimPBeanList) (err error) {
func (this *TimImpl) TimPresenceList(ctx context.Context, pbeanList *TimPBeanList) (err error) {
logger.Debug("TimPresenceList:", pbeanList)
panic("error TimPresenceList")
return
}

func (this *TimImpl) TimResponsePresenceList(pbeanList *TimPBeanList, auth *TimAuth) (r *TimResponseBean, err error) {
func (this *TimImpl) TimResponsePresenceList(ctx context.Context, pbeanList *TimPBeanList, auth *TimAuth) (r *TimResponseBean, err error) {
if !checkAuth(auth) {
err = errors.New(fmt.Sprint("cluster TimResponsePresenceList fail:", auth))
return
Expand Down Expand Up @@ -266,7 +247,7 @@ func _TimResponsePresenceList(pbeanList *TimPBeanList, auth *TimAuth) (r *TimRes
// Parameters:
// - MbeanList
// - Auth
func (this *TimImpl) TimResponseMessageList(mbeanList *TimMBeanList, auth *TimAuth) (r *TimResponseBean, err error) {
func (this *TimImpl) TimResponseMessageList(ctx context.Context, mbeanList *TimMBeanList, auth *TimAuth) (r *TimResponseBean, err error) {
if !checkAuth(auth) {
err = errors.New(fmt.Sprint("cluster TimResponseMessageList fail:", auth))
return
Expand Down Expand Up @@ -298,7 +279,7 @@ func _TimResponseMessageList(mbeanList *TimMBeanList, auth *TimAuth) (r *TimResp
return
}

func (this *TimImpl) TimProperty(tpb *TimPropertyBean) (err error) {
func (this *TimImpl) TimProperty(ctx context.Context, tpb *TimPropertyBean) (err error) {
logger.Debug("TimProperty:", tpb)
return
}
Loading

0 comments on commit 18c7847

Please sign in to comment.