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
6a7f8a34
Commit
6a7f8a34
authored
Nov 11, 2018
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Imp: add remark for OnMessage to let user handle the OnMessage asynchronously
parent
a5d4d7b1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
getty.go
getty.go
+9
-3
session.go
session.go
+2
-1
No files found.
getty.go
View file @
6a7f8a34
...
...
@@ -56,9 +56,15 @@ type EventListener interface {
// invoked periodically, its period can be set by (Session)SetCronPeriod
OnCron
(
Session
)
// invoked when receive packge. Pls attention that do not handle long time logic processing in this func.
// You'd better set the package's maximum length. If the message's length is greater than it, u should
// should return err in Reader{Read} and getty will close this connection soon.
// invoked when getty received a package. Pls attention that do not handle long time
// logic processing in this func. You'd better set the package's maximum length.
// If the message's length is greater than it, u should should return err in
// Reader{Read} and getty will close this connection soon.
//
// If ur logic processing in this func will take a long time, u should start a goroutine
// pool(like working thread pool in cpp) to handle the processing asynchronously. Or u
// can do the logic processing in other asynchronous way.
// !!!In short, ur OnMessage callback func should return asap.
//
// If this is a udp event listener, the second parameter type is UDPContext.
OnMessage
(
Session
,
interface
{})
...
...
session.go
View file @
6a7f8a34
...
...
@@ -489,7 +489,8 @@ LOOP:
if
flag
{
log
.
Debug
(
"%#v <-s.rQ"
,
inPkg
)
pkg
:=
inPkg
go
s
.
listener
.
OnMessage
(
s
,
pkg
)
// go s.listener.OnMessage(s, pkg)
s
.
listener
.
OnMessage
(
s
,
pkg
)
s
.
incReadPkgNum
()
}
else
{
log
.
Info
(
"[session.handleLoop] drop readin package{%#v}"
,
inPkg
)
...
...
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