Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
getty
Commits
630edfeb
Commit
630edfeb
authored
Feb 03, 2017
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use getty Session interface
parent
e61e9aae
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
56 additions
and
56 deletions
+56
-56
client.go
echo/tcp-echo/client/app/client.go
+6
-6
handler.go
echo/tcp-echo/client/app/handler.go
+6
-6
main.go
echo/tcp-echo/client/app/main.go
+1
-1
readwriter.go
echo/tcp-echo/client/app/readwriter.go
+2
-2
handler.go
echo/tcp-echo/server/app/handler.go
+11
-11
readwriter.go
echo/tcp-echo/server/app/readwriter.go
+2
-2
server.go
echo/tcp-echo/server/app/server.go
+1
-1
client.go
echo/ws-echo/client/app/client.go
+5
-5
handler.go
echo/ws-echo/client/app/handler.go
+6
-6
main.go
echo/ws-echo/client/app/main.go
+1
-1
readwriter.go
echo/ws-echo/client/app/readwriter.go
+2
-2
handler.go
echo/ws-echo/server/app/handler.go
+10
-10
readwriter.go
echo/ws-echo/server/app/readwriter.go
+2
-2
server.go
echo/ws-echo/server/app/server.go
+1
-1
No files found.
echo/tcp-echo/client/app/client.go
View file @
630edfeb
...
...
@@ -63,7 +63,7 @@ func (this *EchoClient) close() {
client
.
lock
.
Unlock
()
}
func
(
this
*
EchoClient
)
selectSession
()
*
getty
.
Session
{
func
(
this
*
EchoClient
)
selectSession
()
getty
.
Session
{
// get route server session
this
.
lock
.
RLock
()
defer
this
.
lock
.
RUnlock
()
...
...
@@ -76,7 +76,7 @@ func (this *EchoClient) selectSession() *getty.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
())
if
session
==
nil
{
return
...
...
@@ -87,7 +87,7 @@ func (this *EchoClient) addSession(session *getty.Session) {
this
.
lock
.
Unlock
()
}
func
(
this
*
EchoClient
)
removeSession
(
session
*
getty
.
Session
)
{
func
(
this
*
EchoClient
)
removeSession
(
session
getty
.
Session
)
{
if
session
==
nil
{
return
}
...
...
@@ -106,7 +106,7 @@ func (this *EchoClient) removeSession(session *getty.Session) {
this
.
lock
.
Unlock
()
}
func
(
this
*
EchoClient
)
updateSession
(
session
*
getty
.
Session
)
{
func
(
this
*
EchoClient
)
updateSession
(
session
getty
.
Session
)
{
if
session
==
nil
{
return
}
...
...
@@ -123,7 +123,7 @@ func (this *EchoClient) updateSession(session *getty.Session) {
this
.
lock
.
Unlock
()
}
func
(
this
*
EchoClient
)
getClientEchoSession
(
session
*
getty
.
Session
)
(
clientEchoSession
,
error
)
{
func
(
this
*
EchoClient
)
getClientEchoSession
(
session
getty
.
Session
)
(
clientEchoSession
,
error
)
{
var
(
err
error
echoSession
clientEchoSession
...
...
@@ -145,7 +145,7 @@ func (this *EchoClient) getClientEchoSession(session *getty.Session) (clientEcho
return
echoSession
,
err
}
func
(
this
*
EchoClient
)
heartbeat
(
session
*
getty
.
Session
)
{
func
(
this
*
EchoClient
)
heartbeat
(
session
getty
.
Session
)
{
var
pkg
EchoPackage
pkg
.
H
.
Magic
=
echoPkgMagic
pkg
.
H
.
LogID
=
(
uint32
)(
src
.
Int63
())
...
...
echo/tcp-echo/client/app/handler.go
View file @
630edfeb
...
...
@@ -28,7 +28,7 @@ var (
////////////////////////////////////////////
type
clientEchoSession
struct
{
session
*
getty
.
Session
session
getty
.
Session
reqNum
int32
}
...
...
@@ -39,23 +39,23 @@ func newEchoMessageHandler() *EchoMessageHandler {
return
&
EchoMessageHandler
{}
}
func
(
this
*
EchoMessageHandler
)
OnOpen
(
session
*
getty
.
Session
)
error
{
func
(
this
*
EchoMessageHandler
)
OnOpen
(
session
getty
.
Session
)
error
{
client
.
addSession
(
session
)
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
)
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
())
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
)
if
!
ok
{
log
.
Error
(
"illegal packge{%#v}"
,
pkg
)
...
...
@@ -66,7 +66,7 @@ func (this *EchoMessageHandler) OnMessage(session *getty.Session, pkg interface{
client
.
updateSession
(
session
)
}
func
(
this
*
EchoMessageHandler
)
OnCron
(
session
*
getty
.
Session
)
{
func
(
this
*
EchoMessageHandler
)
OnCron
(
session
getty
.
Session
)
{
clientEchoSession
,
err
:=
client
.
getClientEchoSession
(
session
)
if
err
!=
nil
{
log
.
Error
(
"client.getClientSession(session{%s}) = error{%#v}"
,
session
.
Stat
(),
err
)
...
...
echo/tcp-echo/client/app/main.go
View file @
630edfeb
...
...
@@ -69,7 +69,7 @@ func initProfiling() {
}()
}
func
newSession
(
session
*
getty
.
Session
)
error
{
func
newSession
(
session
getty
.
Session
)
error
{
var
(
ok
bool
tcpConn
*
net
.
TCPConn
...
...
echo/tcp-echo/client/app/readwriter.go
View file @
630edfeb
...
...
@@ -27,7 +27,7 @@ func NewEchoPackageHandler() *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
(
err
error
len
int
...
...
@@ -48,7 +48,7 @@ func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{
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
(
ok
bool
err
error
...
...
echo/tcp-echo/server/app/handler.go
View file @
630edfeb
...
...
@@ -25,7 +25,7 @@ var (
)
type
PackageHandler
interface
{
Handle
(
*
getty
.
Session
,
*
EchoPackage
)
error
Handle
(
getty
.
Session
,
*
EchoPackage
)
error
}
////////////////////////////////////////////
...
...
@@ -34,7 +34,7 @@ type PackageHandler interface {
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
)
var
rspPkg
EchoPackage
...
...
@@ -51,7 +51,7 @@ func (this *HeartbeatHandler) Handle(session *getty.Session, pkg *EchoPackage) e
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
)
return
session
.
WritePkg
(
pkg
)
}
...
...
@@ -61,7 +61,7 @@ func (this *MessageHandler) Handle(session *getty.Session, pkg *EchoPackage) err
////////////////////////////////////////////
type
clientEchoSession
struct
{
session
*
getty
.
Session
session
getty
.
Session
active
time
.
Time
reqNum
int32
}
...
...
@@ -70,7 +70,7 @@ type EchoMessageHandler struct {
handlers
map
[
uint32
]
PackageHandler
rwlock
sync
.
RWMutex
sessionMap
map
[
*
getty
.
Session
]
*
clientEchoSession
sessionMap
map
[
getty
.
Session
]
*
clientEchoSession
}
func
newEchoMessageHandler
()
*
EchoMessageHandler
{
...
...
@@ -78,10 +78,10 @@ func newEchoMessageHandler() *EchoMessageHandler {
handlers
[
heartbeatCmd
]
=
&
HeartbeatHandler
{}
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
(
err
error
)
...
...
@@ -102,21 +102,21 @@ func (this *EchoMessageHandler) OnOpen(session *getty.Session) error {
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
)
this
.
rwlock
.
Lock
()
delete
(
this
.
sessionMap
,
session
)
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
())
this
.
rwlock
.
Lock
()
delete
(
this
.
sessionMap
,
session
)
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
)
if
!
ok
{
log
.
Error
(
"illegal packge{%#v}"
,
pkg
)
...
...
@@ -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
(
flag
bool
active
time
.
Time
...
...
echo/tcp-echo/server/app/readwriter.go
View file @
630edfeb
...
...
@@ -27,7 +27,7 @@ func NewEchoPackageHandler() *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
(
err
error
len
int
...
...
@@ -48,7 +48,7 @@ func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{
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
(
ok
bool
err
error
...
...
echo/tcp-echo/server/app/server.go
View file @
630edfeb
...
...
@@ -74,7 +74,7 @@ func initProfiling() {
}()
}
func
newSession
(
session
*
getty
.
Session
)
error
{
func
newSession
(
session
getty
.
Session
)
error
{
var
(
ok
bool
tcpConn
*
net
.
TCPConn
...
...
echo/ws-echo/client/app/client.go
View file @
630edfeb
...
...
@@ -62,7 +62,7 @@ func (this *EchoClient) close() {
client
.
lock
.
Unlock
()
}
func
(
this
*
EchoClient
)
selectSession
()
*
getty
.
Session
{
func
(
this
*
EchoClient
)
selectSession
()
getty
.
Session
{
// get route server session
this
.
lock
.
RLock
()
defer
this
.
lock
.
RUnlock
()
...
...
@@ -75,7 +75,7 @@ func (this *EchoClient) selectSession() *getty.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
())
if
session
==
nil
{
return
...
...
@@ -86,7 +86,7 @@ func (this *EchoClient) addSession(session *getty.Session) {
this
.
lock
.
Unlock
()
}
func
(
this
*
EchoClient
)
removeSession
(
session
*
getty
.
Session
)
{
func
(
this
*
EchoClient
)
removeSession
(
session
getty
.
Session
)
{
if
session
==
nil
{
return
}
...
...
@@ -105,7 +105,7 @@ func (this *EchoClient) removeSession(session *getty.Session) {
this
.
lock
.
Unlock
()
}
func
(
this
*
EchoClient
)
updateSession
(
session
*
getty
.
Session
)
{
func
(
this
*
EchoClient
)
updateSession
(
session
getty
.
Session
)
{
if
session
==
nil
{
return
}
...
...
@@ -122,7 +122,7 @@ func (this *EchoClient) updateSession(session *getty.Session) {
this
.
lock
.
Unlock
()
}
func
(
this
*
EchoClient
)
getClientEchoSession
(
session
*
getty
.
Session
)
(
clientEchoSession
,
error
)
{
func
(
this
*
EchoClient
)
getClientEchoSession
(
session
getty
.
Session
)
(
clientEchoSession
,
error
)
{
var
(
err
error
echoSession
clientEchoSession
...
...
echo/ws-echo/client/app/handler.go
View file @
630edfeb
...
...
@@ -28,7 +28,7 @@ var (
////////////////////////////////////////////
type
clientEchoSession
struct
{
session
*
getty
.
Session
session
getty
.
Session
reqNum
int32
}
...
...
@@ -39,23 +39,23 @@ func newEchoMessageHandler() *EchoMessageHandler {
return
&
EchoMessageHandler
{}
}
func
(
this
*
EchoMessageHandler
)
OnOpen
(
session
*
getty
.
Session
)
error
{
func
(
this
*
EchoMessageHandler
)
OnOpen
(
session
getty
.
Session
)
error
{
client
.
addSession
(
session
)
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
)
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
())
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
)
if
!
ok
{
log
.
Error
(
"illegal packge{%#v}"
,
pkg
)
...
...
@@ -66,7 +66,7 @@ func (this *EchoMessageHandler) OnMessage(session *getty.Session, pkg interface{
client
.
updateSession
(
session
)
}
func
(
this
*
EchoMessageHandler
)
OnCron
(
session
*
getty
.
Session
)
{
func
(
this
*
EchoMessageHandler
)
OnCron
(
session
getty
.
Session
)
{
clientEchoSession
,
err
:=
client
.
getClientEchoSession
(
session
)
if
err
!=
nil
{
log
.
Error
(
"client.getClientSession(session{%s}) = error{%#v}"
,
session
.
Stat
(),
err
)
...
...
echo/ws-echo/client/app/main.go
View file @
630edfeb
...
...
@@ -69,7 +69,7 @@ func initProfiling() {
}()
}
func
newSession
(
session
*
getty
.
Session
)
error
{
func
newSession
(
session
getty
.
Session
)
error
{
var
(
ok
bool
tcpConn
*
net
.
TCPConn
...
...
echo/ws-echo/client/app/readwriter.go
View file @
630edfeb
...
...
@@ -27,7 +27,7 @@ func NewEchoPackageHandler() *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
(
err
error
len
int
...
...
@@ -48,7 +48,7 @@ func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{
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
(
ok
bool
err
error
...
...
echo/ws-echo/server/app/handler.go
View file @
630edfeb
...
...
@@ -25,7 +25,7 @@ var (
)
type
PackageHandler
interface
{
Handle
(
*
getty
.
Session
,
*
EchoPackage
)
error
Handle
(
getty
.
Session
,
*
EchoPackage
)
error
}
////////////////////////////////////////////
...
...
@@ -34,7 +34,7 @@ type PackageHandler interface {
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
)
return
session
.
WritePkg
(
pkg
)
}
...
...
@@ -44,7 +44,7 @@ func (this *MessageHandler) Handle(session *getty.Session, pkg *EchoPackage) err
////////////////////////////////////////////
type
clientEchoSession
struct
{
session
*
getty
.
Session
session
getty
.
Session
reqNum
int32
}
...
...
@@ -52,17 +52,17 @@ type EchoMessageHandler struct {
handlers
map
[
uint32
]
PackageHandler
rwlock
sync
.
RWMutex
sessionMap
map
[
*
getty
.
Session
]
*
clientEchoSession
sessionMap
map
[
getty
.
Session
]
*
clientEchoSession
}
func
newEchoMessageHandler
()
*
EchoMessageHandler
{
handlers
:=
make
(
map
[
uint32
]
PackageHandler
)
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
(
err
error
)
...
...
@@ -83,21 +83,21 @@ func (this *EchoMessageHandler) OnOpen(session *getty.Session) error {
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
)
this
.
rwlock
.
Lock
()
delete
(
this
.
sessionMap
,
session
)
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
())
this
.
rwlock
.
Lock
()
delete
(
this
.
sessionMap
,
session
)
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
)
if
!
ok
{
log
.
Error
(
"illegal packge{%#v}, %s"
,
pkg
,
string
(
pkg
.
([]
byte
)))
...
...
@@ -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
(
flag
bool
active
time
.
Time
...
...
echo/ws-echo/server/app/readwriter.go
View file @
630edfeb
...
...
@@ -28,7 +28,7 @@ func NewEchoPackageHandler() *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))
var
(
err
error
...
...
@@ -52,7 +52,7 @@ func (this *EchoPackageHandler) Read(ss *getty.Session, data []byte) (interface{
// 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
(
ok
bool
err
error
...
...
echo/ws-echo/server/app/server.go
View file @
630edfeb
...
...
@@ -74,7 +74,7 @@ func initProfiling() {
}()
}
func
newSession
(
session
*
getty
.
Session
)
error
{
func
newSession
(
session
getty
.
Session
)
error
{
var
(
ok
bool
tcpConn
*
net
.
TCPConn
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment