Commit 630edfeb authored by AlexStocks's avatar AlexStocks

use getty Session interface

parent e61e9aae
...@@ -63,7 +63,7 @@ func (this *EchoClient) close() { ...@@ -63,7 +63,7 @@ func (this *EchoClient) close() {
client.lock.Unlock() client.lock.Unlock()
} }
func (this *EchoClient) selectSession() *getty.Session { func (this *EchoClient) selectSession() getty.Session {
// get route server session // get route server session
this.lock.RLock() this.lock.RLock()
defer this.lock.RUnlock() defer this.lock.RUnlock()
...@@ -76,7 +76,7 @@ func (this *EchoClient) selectSession() *getty.Session { ...@@ -76,7 +76,7 @@ func (this *EchoClient) selectSession() *getty.Session {
return this.sessions[rand.Int31n(int32(count))].session return this.sessions[rand.Int31n(int32(count))].session
} }
func (this *EchoClient) addSession(session *getty.Session) { func (this *EchoClient) addSession(session getty.Session) {
log.Debug("add session{%s}", session.Stat()) log.Debug("add session{%s}", session.Stat())
if session == nil { if session == nil {
return return
...@@ -87,7 +87,7 @@ func (this *EchoClient) addSession(session *getty.Session) { ...@@ -87,7 +87,7 @@ func (this *EchoClient) addSession(session *getty.Session) {
this.lock.Unlock() this.lock.Unlock()
} }
func (this *EchoClient) removeSession(session *getty.Session) { func (this *EchoClient) removeSession(session getty.Session) {
if session == nil { if session == nil {
return return
} }
...@@ -106,7 +106,7 @@ func (this *EchoClient) removeSession(session *getty.Session) { ...@@ -106,7 +106,7 @@ func (this *EchoClient) removeSession(session *getty.Session) {
this.lock.Unlock() this.lock.Unlock()
} }
func (this *EchoClient) updateSession(session *getty.Session) { func (this *EchoClient) updateSession(session getty.Session) {
if session == nil { if session == nil {
return return
} }
...@@ -123,7 +123,7 @@ func (this *EchoClient) updateSession(session *getty.Session) { ...@@ -123,7 +123,7 @@ func (this *EchoClient) updateSession(session *getty.Session) {
this.lock.Unlock() this.lock.Unlock()
} }
func (this *EchoClient) getClientEchoSession(session *getty.Session) (clientEchoSession, error) { func (this *EchoClient) getClientEchoSession(session getty.Session) (clientEchoSession, error) {
var ( var (
err error err error
echoSession clientEchoSession echoSession clientEchoSession
...@@ -145,7 +145,7 @@ func (this *EchoClient) getClientEchoSession(session *getty.Session) (clientEcho ...@@ -145,7 +145,7 @@ func (this *EchoClient) getClientEchoSession(session *getty.Session) (clientEcho
return echoSession, err return echoSession, err
} }
func (this *EchoClient) heartbeat(session *getty.Session) { func (this *EchoClient) heartbeat(session getty.Session) {
var pkg EchoPackage var pkg EchoPackage
pkg.H.Magic = echoPkgMagic pkg.H.Magic = echoPkgMagic
pkg.H.LogID = (uint32)(src.Int63()) pkg.H.LogID = (uint32)(src.Int63())
......
...@@ -28,7 +28,7 @@ var ( ...@@ -28,7 +28,7 @@ var (
//////////////////////////////////////////// ////////////////////////////////////////////
type clientEchoSession struct { type clientEchoSession struct {
session *getty.Session session getty.Session
reqNum int32 reqNum int32
} }
...@@ -39,23 +39,23 @@ func newEchoMessageHandler() *EchoMessageHandler { ...@@ -39,23 +39,23 @@ func newEchoMessageHandler() *EchoMessageHandler {
return &EchoMessageHandler{} return &EchoMessageHandler{}
} }
func (this *EchoMessageHandler) OnOpen(session *getty.Session) error { func (this *EchoMessageHandler) OnOpen(session getty.Session) error {
client.addSession(session) client.addSession(session)
return nil return nil
} }
func (this *EchoMessageHandler) OnError(session *getty.Session, err error) { func (this *EchoMessageHandler) OnError(session getty.Session, err error) {
log.Info("session{%s} got error{%v}, will be closed.", session.Stat(), err) log.Info("session{%s} got error{%v}, will be closed.", session.Stat(), err)
client.removeSession(session) client.removeSession(session)
} }
func (this *EchoMessageHandler) OnClose(session *getty.Session) { func (this *EchoMessageHandler) OnClose(session getty.Session) {
log.Info("session{%s} is closing......", session.Stat()) log.Info("session{%s} is closing......", session.Stat())
client.removeSession(session) client.removeSession(session)
} }
func (this *EchoMessageHandler) OnMessage(session *getty.Session, pkg interface{}) { func (this *EchoMessageHandler) OnMessage(session getty.Session, pkg interface{}) {
p, ok := pkg.(*EchoPackage) p, ok := pkg.(*EchoPackage)
if !ok { if !ok {
log.Error("illegal packge{%#v}", pkg) log.Error("illegal packge{%#v}", pkg)
...@@ -66,7 +66,7 @@ func (this *EchoMessageHandler) OnMessage(session *getty.Session, pkg interface{ ...@@ -66,7 +66,7 @@ func (this *EchoMessageHandler) OnMessage(session *getty.Session, pkg interface{
client.updateSession(session) client.updateSession(session)
} }
func (this *EchoMessageHandler) OnCron(session *getty.Session) { func (this *EchoMessageHandler) OnCron(session getty.Session) {
clientEchoSession, err := client.getClientEchoSession(session) clientEchoSession, err := client.getClientEchoSession(session)
if err != nil { if err != nil {
log.Error("client.getClientSession(session{%s}) = error{%#v}", session.Stat(), err) log.Error("client.getClientSession(session{%s}) = error{%#v}", session.Stat(), err)
......
...@@ -69,7 +69,7 @@ func initProfiling() { ...@@ -69,7 +69,7 @@ func initProfiling() {
}() }()
} }
func newSession(session *getty.Session) error { func newSession(session getty.Session) error {
var ( var (
ok bool ok bool
tcpConn *net.TCPConn tcpConn *net.TCPConn
......
...@@ -27,7 +27,7 @@ func NewEchoPackageHandler() *EchoPackageHandler { ...@@ -27,7 +27,7 @@ func NewEchoPackageHandler() *EchoPackageHandler {
return &EchoPackageHandler{} return &EchoPackageHandler{}
} }
func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{}, int, error) { func (this *EchoPackageHandler) Read(ss getty.Session, data []byte) (interface{}, int, error) {
var ( var (
err error err error
len int len int
...@@ -48,7 +48,7 @@ func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{ ...@@ -48,7 +48,7 @@ func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{
return &pkg, len, nil return &pkg, len, nil
} }
func (this *EchoPackageHandler) Write(ss *getty.Session, pkg interface{}) error { func (this *EchoPackageHandler) Write(ss getty.Session, pkg interface{}) error {
var ( var (
ok bool ok bool
err error err error
......
...@@ -25,7 +25,7 @@ var ( ...@@ -25,7 +25,7 @@ var (
) )
type PackageHandler interface { type PackageHandler interface {
Handle(*getty.Session, *EchoPackage) error Handle(getty.Session, *EchoPackage) error
} }
//////////////////////////////////////////// ////////////////////////////////////////////
...@@ -34,7 +34,7 @@ type PackageHandler interface { ...@@ -34,7 +34,7 @@ type PackageHandler interface {
type HeartbeatHandler struct{} type HeartbeatHandler struct{}
func (this *HeartbeatHandler) Handle(session *getty.Session, pkg *EchoPackage) error { func (this *HeartbeatHandler) Handle(session getty.Session, pkg *EchoPackage) error {
log.Debug("get echo heartbeat package{%s}", pkg) log.Debug("get echo heartbeat package{%s}", pkg)
var rspPkg EchoPackage var rspPkg EchoPackage
...@@ -51,7 +51,7 @@ func (this *HeartbeatHandler) Handle(session *getty.Session, pkg *EchoPackage) e ...@@ -51,7 +51,7 @@ func (this *HeartbeatHandler) Handle(session *getty.Session, pkg *EchoPackage) e
type MessageHandler struct{} type MessageHandler struct{}
func (this *MessageHandler) Handle(session *getty.Session, pkg *EchoPackage) error { func (this *MessageHandler) Handle(session getty.Session, pkg *EchoPackage) error {
log.Debug("get echo package{%s}", pkg) log.Debug("get echo package{%s}", pkg)
return session.WritePkg(pkg) return session.WritePkg(pkg)
} }
...@@ -61,7 +61,7 @@ func (this *MessageHandler) Handle(session *getty.Session, pkg *EchoPackage) err ...@@ -61,7 +61,7 @@ func (this *MessageHandler) Handle(session *getty.Session, pkg *EchoPackage) err
//////////////////////////////////////////// ////////////////////////////////////////////
type clientEchoSession struct { type clientEchoSession struct {
session *getty.Session session getty.Session
active time.Time active time.Time
reqNum int32 reqNum int32
} }
...@@ -70,7 +70,7 @@ type EchoMessageHandler struct { ...@@ -70,7 +70,7 @@ type EchoMessageHandler struct {
handlers map[uint32]PackageHandler handlers map[uint32]PackageHandler
rwlock sync.RWMutex rwlock sync.RWMutex
sessionMap map[*getty.Session]*clientEchoSession sessionMap map[getty.Session]*clientEchoSession
} }
func newEchoMessageHandler() *EchoMessageHandler { func newEchoMessageHandler() *EchoMessageHandler {
...@@ -78,10 +78,10 @@ func newEchoMessageHandler() *EchoMessageHandler { ...@@ -78,10 +78,10 @@ func newEchoMessageHandler() *EchoMessageHandler {
handlers[heartbeatCmd] = &HeartbeatHandler{} handlers[heartbeatCmd] = &HeartbeatHandler{}
handlers[echoCmd] = &MessageHandler{} handlers[echoCmd] = &MessageHandler{}
return &EchoMessageHandler{sessionMap: make(map[*getty.Session]*clientEchoSession), handlers: handlers} return &EchoMessageHandler{sessionMap: make(map[getty.Session]*clientEchoSession), handlers: handlers}
} }
func (this *EchoMessageHandler) OnOpen(session *getty.Session) error { func (this *EchoMessageHandler) OnOpen(session getty.Session) error {
var ( var (
err error err error
) )
...@@ -102,21 +102,21 @@ func (this *EchoMessageHandler) OnOpen(session *getty.Session) error { ...@@ -102,21 +102,21 @@ func (this *EchoMessageHandler) OnOpen(session *getty.Session) error {
return nil return nil
} }
func (this *EchoMessageHandler) OnError(session *getty.Session, err error) { func (this *EchoMessageHandler) OnError(session getty.Session, err error) {
log.Info("session{%s} got error{%v}, will be closed.", session.Stat(), err) log.Info("session{%s} got error{%v}, will be closed.", session.Stat(), err)
this.rwlock.Lock() this.rwlock.Lock()
delete(this.sessionMap, session) delete(this.sessionMap, session)
this.rwlock.Unlock() this.rwlock.Unlock()
} }
func (this *EchoMessageHandler) OnClose(session *getty.Session) { func (this *EchoMessageHandler) OnClose(session getty.Session) {
log.Info("session{%s} is closing......", session.Stat()) log.Info("session{%s} is closing......", session.Stat())
this.rwlock.Lock() this.rwlock.Lock()
delete(this.sessionMap, session) delete(this.sessionMap, session)
this.rwlock.Unlock() this.rwlock.Unlock()
} }
func (this *EchoMessageHandler) OnMessage(session *getty.Session, pkg interface{}) { func (this *EchoMessageHandler) OnMessage(session getty.Session, pkg interface{}) {
p, ok := pkg.(*EchoPackage) p, ok := pkg.(*EchoPackage)
if !ok { if !ok {
log.Error("illegal packge{%#v}", pkg) log.Error("illegal packge{%#v}", pkg)
...@@ -139,7 +139,7 @@ func (this *EchoMessageHandler) OnMessage(session *getty.Session, pkg interface{ ...@@ -139,7 +139,7 @@ func (this *EchoMessageHandler) OnMessage(session *getty.Session, pkg interface{
} }
} }
func (this *EchoMessageHandler) OnCron(session *getty.Session) { func (this *EchoMessageHandler) OnCron(session getty.Session) {
var ( var (
flag bool flag bool
active time.Time active time.Time
......
...@@ -27,7 +27,7 @@ func NewEchoPackageHandler() *EchoPackageHandler { ...@@ -27,7 +27,7 @@ func NewEchoPackageHandler() *EchoPackageHandler {
return &EchoPackageHandler{} return &EchoPackageHandler{}
} }
func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{}, int, error) { func (this *EchoPackageHandler) Read(ss getty.Session, data []byte) (interface{}, int, error) {
var ( var (
err error err error
len int len int
...@@ -48,7 +48,7 @@ func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{ ...@@ -48,7 +48,7 @@ func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{
return &pkg, len, nil return &pkg, len, nil
} }
func (this *EchoPackageHandler) Write(ss *getty.Session, pkg interface{}) error { func (this *EchoPackageHandler) Write(ss getty.Session, pkg interface{}) error {
var ( var (
ok bool ok bool
err error err error
......
...@@ -74,7 +74,7 @@ func initProfiling() { ...@@ -74,7 +74,7 @@ func initProfiling() {
}() }()
} }
func newSession(session *getty.Session) error { func newSession(session getty.Session) error {
var ( var (
ok bool ok bool
tcpConn *net.TCPConn tcpConn *net.TCPConn
......
...@@ -62,7 +62,7 @@ func (this *EchoClient) close() { ...@@ -62,7 +62,7 @@ func (this *EchoClient) close() {
client.lock.Unlock() client.lock.Unlock()
} }
func (this *EchoClient) selectSession() *getty.Session { func (this *EchoClient) selectSession() getty.Session {
// get route server session // get route server session
this.lock.RLock() this.lock.RLock()
defer this.lock.RUnlock() defer this.lock.RUnlock()
...@@ -75,7 +75,7 @@ func (this *EchoClient) selectSession() *getty.Session { ...@@ -75,7 +75,7 @@ func (this *EchoClient) selectSession() *getty.Session {
return this.sessions[rand.Int31n(int32(count))].session return this.sessions[rand.Int31n(int32(count))].session
} }
func (this *EchoClient) addSession(session *getty.Session) { func (this *EchoClient) addSession(session getty.Session) {
log.Debug("add session{%s}", session.Stat()) log.Debug("add session{%s}", session.Stat())
if session == nil { if session == nil {
return return
...@@ -86,7 +86,7 @@ func (this *EchoClient) addSession(session *getty.Session) { ...@@ -86,7 +86,7 @@ func (this *EchoClient) addSession(session *getty.Session) {
this.lock.Unlock() this.lock.Unlock()
} }
func (this *EchoClient) removeSession(session *getty.Session) { func (this *EchoClient) removeSession(session getty.Session) {
if session == nil { if session == nil {
return return
} }
...@@ -105,7 +105,7 @@ func (this *EchoClient) removeSession(session *getty.Session) { ...@@ -105,7 +105,7 @@ func (this *EchoClient) removeSession(session *getty.Session) {
this.lock.Unlock() this.lock.Unlock()
} }
func (this *EchoClient) updateSession(session *getty.Session) { func (this *EchoClient) updateSession(session getty.Session) {
if session == nil { if session == nil {
return return
} }
...@@ -122,7 +122,7 @@ func (this *EchoClient) updateSession(session *getty.Session) { ...@@ -122,7 +122,7 @@ func (this *EchoClient) updateSession(session *getty.Session) {
this.lock.Unlock() this.lock.Unlock()
} }
func (this *EchoClient) getClientEchoSession(session *getty.Session) (clientEchoSession, error) { func (this *EchoClient) getClientEchoSession(session getty.Session) (clientEchoSession, error) {
var ( var (
err error err error
echoSession clientEchoSession echoSession clientEchoSession
......
...@@ -28,7 +28,7 @@ var ( ...@@ -28,7 +28,7 @@ var (
//////////////////////////////////////////// ////////////////////////////////////////////
type clientEchoSession struct { type clientEchoSession struct {
session *getty.Session session getty.Session
reqNum int32 reqNum int32
} }
...@@ -39,23 +39,23 @@ func newEchoMessageHandler() *EchoMessageHandler { ...@@ -39,23 +39,23 @@ func newEchoMessageHandler() *EchoMessageHandler {
return &EchoMessageHandler{} return &EchoMessageHandler{}
} }
func (this *EchoMessageHandler) OnOpen(session *getty.Session) error { func (this *EchoMessageHandler) OnOpen(session getty.Session) error {
client.addSession(session) client.addSession(session)
return nil return nil
} }
func (this *EchoMessageHandler) OnError(session *getty.Session, err error) { func (this *EchoMessageHandler) OnError(session getty.Session, err error) {
log.Info("session{%s} got error{%v}, will be closed.", session.Stat(), err) log.Info("session{%s} got error{%v}, will be closed.", session.Stat(), err)
client.removeSession(session) client.removeSession(session)
} }
func (this *EchoMessageHandler) OnClose(session *getty.Session) { func (this *EchoMessageHandler) OnClose(session getty.Session) {
log.Info("session{%s} is closing......", session.Stat()) log.Info("session{%s} is closing......", session.Stat())
client.removeSession(session) client.removeSession(session)
} }
func (this *EchoMessageHandler) OnMessage(session *getty.Session, pkg interface{}) { func (this *EchoMessageHandler) OnMessage(session getty.Session, pkg interface{}) {
p, ok := pkg.(*EchoPackage) p, ok := pkg.(*EchoPackage)
if !ok { if !ok {
log.Error("illegal packge{%#v}", pkg) log.Error("illegal packge{%#v}", pkg)
...@@ -66,7 +66,7 @@ func (this *EchoMessageHandler) OnMessage(session *getty.Session, pkg interface{ ...@@ -66,7 +66,7 @@ func (this *EchoMessageHandler) OnMessage(session *getty.Session, pkg interface{
client.updateSession(session) client.updateSession(session)
} }
func (this *EchoMessageHandler) OnCron(session *getty.Session) { func (this *EchoMessageHandler) OnCron(session getty.Session) {
clientEchoSession, err := client.getClientEchoSession(session) clientEchoSession, err := client.getClientEchoSession(session)
if err != nil { if err != nil {
log.Error("client.getClientSession(session{%s}) = error{%#v}", session.Stat(), err) log.Error("client.getClientSession(session{%s}) = error{%#v}", session.Stat(), err)
......
...@@ -69,7 +69,7 @@ func initProfiling() { ...@@ -69,7 +69,7 @@ func initProfiling() {
}() }()
} }
func newSession(session *getty.Session) error { func newSession(session getty.Session) error {
var ( var (
ok bool ok bool
tcpConn *net.TCPConn tcpConn *net.TCPConn
......
...@@ -27,7 +27,7 @@ func NewEchoPackageHandler() *EchoPackageHandler { ...@@ -27,7 +27,7 @@ func NewEchoPackageHandler() *EchoPackageHandler {
return &EchoPackageHandler{} return &EchoPackageHandler{}
} }
func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{}, int, error) { func (this *EchoPackageHandler) Read(ss getty.Session, data []byte) (interface{}, int, error) {
var ( var (
err error err error
len int len int
...@@ -48,7 +48,7 @@ func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{ ...@@ -48,7 +48,7 @@ func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{
return &pkg, len, nil return &pkg, len, nil
} }
func (this *EchoPackageHandler) Write(ss *getty.Session, pkg interface{}) error { func (this *EchoPackageHandler) Write(ss getty.Session, pkg interface{}) error {
var ( var (
ok bool ok bool
err error err error
......
...@@ -25,7 +25,7 @@ var ( ...@@ -25,7 +25,7 @@ var (
) )
type PackageHandler interface { type PackageHandler interface {
Handle(*getty.Session, *EchoPackage) error Handle(getty.Session, *EchoPackage) error
} }
//////////////////////////////////////////// ////////////////////////////////////////////
...@@ -34,7 +34,7 @@ type PackageHandler interface { ...@@ -34,7 +34,7 @@ type PackageHandler interface {
type MessageHandler struct{} type MessageHandler struct{}
func (this *MessageHandler) Handle(session *getty.Session, pkg *EchoPackage) error { func (this *MessageHandler) Handle(session getty.Session, pkg *EchoPackage) error {
log.Debug("get echo package{%s}", pkg) log.Debug("get echo package{%s}", pkg)
return session.WritePkg(pkg) return session.WritePkg(pkg)
} }
...@@ -44,7 +44,7 @@ func (this *MessageHandler) Handle(session *getty.Session, pkg *EchoPackage) err ...@@ -44,7 +44,7 @@ func (this *MessageHandler) Handle(session *getty.Session, pkg *EchoPackage) err
//////////////////////////////////////////// ////////////////////////////////////////////
type clientEchoSession struct { type clientEchoSession struct {
session *getty.Session session getty.Session
reqNum int32 reqNum int32
} }
...@@ -52,17 +52,17 @@ type EchoMessageHandler struct { ...@@ -52,17 +52,17 @@ type EchoMessageHandler struct {
handlers map[uint32]PackageHandler handlers map[uint32]PackageHandler
rwlock sync.RWMutex rwlock sync.RWMutex
sessionMap map[*getty.Session]*clientEchoSession sessionMap map[getty.Session]*clientEchoSession
} }
func newEchoMessageHandler() *EchoMessageHandler { func newEchoMessageHandler() *EchoMessageHandler {
handlers := make(map[uint32]PackageHandler) handlers := make(map[uint32]PackageHandler)
handlers[echoCmd] = &MessageHandler{} handlers[echoCmd] = &MessageHandler{}
return &EchoMessageHandler{sessionMap: make(map[*getty.Session]*clientEchoSession), handlers: handlers} return &EchoMessageHandler{sessionMap: make(map[getty.Session]*clientEchoSession), handlers: handlers}
} }
func (this *EchoMessageHandler) OnOpen(session *getty.Session) error { func (this *EchoMessageHandler) OnOpen(session getty.Session) error {
var ( var (
err error err error
) )
...@@ -83,21 +83,21 @@ func (this *EchoMessageHandler) OnOpen(session *getty.Session) error { ...@@ -83,21 +83,21 @@ func (this *EchoMessageHandler) OnOpen(session *getty.Session) error {
return nil return nil
} }
func (this *EchoMessageHandler) OnError(session *getty.Session, err error) { func (this *EchoMessageHandler) OnError(session getty.Session, err error) {
log.Info("session{%s} got error{%v}, will be closed.", session.Stat(), err) log.Info("session{%s} got error{%v}, will be closed.", session.Stat(), err)
this.rwlock.Lock() this.rwlock.Lock()
delete(this.sessionMap, session) delete(this.sessionMap, session)
this.rwlock.Unlock() this.rwlock.Unlock()
} }
func (this *EchoMessageHandler) OnClose(session *getty.Session) { func (this *EchoMessageHandler) OnClose(session getty.Session) {
log.Info("session{%s} is closing......", session.Stat()) log.Info("session{%s} is closing......", session.Stat())
this.rwlock.Lock() this.rwlock.Lock()
delete(this.sessionMap, session) delete(this.sessionMap, session)
this.rwlock.Unlock() this.rwlock.Unlock()
} }
func (this *EchoMessageHandler) OnMessage(session *getty.Session, pkg interface{}) { func (this *EchoMessageHandler) OnMessage(session getty.Session, pkg interface{}) {
p, ok := pkg.(*EchoPackage) p, ok := pkg.(*EchoPackage)
if !ok { if !ok {
log.Error("illegal packge{%#v}, %s", pkg, string(pkg.([]byte))) log.Error("illegal packge{%#v}, %s", pkg, string(pkg.([]byte)))
...@@ -119,7 +119,7 @@ func (this *EchoMessageHandler) OnMessage(session *getty.Session, pkg interface{ ...@@ -119,7 +119,7 @@ func (this *EchoMessageHandler) OnMessage(session *getty.Session, pkg interface{
} }
} }
func (this *EchoMessageHandler) OnCron(session *getty.Session) { func (this *EchoMessageHandler) OnCron(session getty.Session) {
var ( var (
flag bool flag bool
active time.Time active time.Time
......
...@@ -28,7 +28,7 @@ func NewEchoPackageHandler() *EchoPackageHandler { ...@@ -28,7 +28,7 @@ func NewEchoPackageHandler() *EchoPackageHandler {
return &EchoPackageHandler{} return &EchoPackageHandler{}
} }
func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{}, int, error) { func (this *EchoPackageHandler) Read(ss getty.Session, data []byte) (interface{}, int, error) {
// log.Debug("get client package:%s", gxstrings.String(data)) // log.Debug("get client package:%s", gxstrings.String(data))
var ( var (
err error err error
...@@ -52,7 +52,7 @@ func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{ ...@@ -52,7 +52,7 @@ func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{
// return data, len(data), nil // return data, len(data), nil
} }
func (this *EchoPackageHandler) Write(ss *getty.Session, pkg interface{}) error { func (this *EchoPackageHandler) Write(ss getty.Session, pkg interface{}) error {
var ( var (
ok bool ok bool
err error err error
......
...@@ -74,7 +74,7 @@ func initProfiling() { ...@@ -74,7 +74,7 @@ func initProfiling() {
}() }()
} }
func newSession(session *getty.Session) error { func newSession(session getty.Session) error {
var ( var (
ok bool ok bool
tcpConn *net.TCPConn tcpConn *net.TCPConn
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment