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
38afa856
Commit
38afa856
authored
Sep 05, 2016
by
alexstocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use '[]byte' instead of bytes.Buffer in codec.go:(Reader)Read
parent
e151651d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
7 deletions
+6
-7
README.md
README.md
+3
-1
codec.go
codec.go
+1
-5
session.go
session.go
+2
-1
No files found.
README.md
View file @
38afa856
...
...
@@ -14,7 +14,9 @@
-
2016/09/05
> 1 add 'errFlag = true' when got err in pkgHandler.Read loop clause in session.go:(Session)handlePackage
>
> 2 version: 0.3.03
> 2 use '[]byte' instead of bytes.Buffer in codec.go:(Reader)Read
>
> 3 version: 0.3.03
-
2016/09/04
> 1 add server.go:(Server)Listen
...
...
codec.go
View file @
38afa856
...
...
@@ -9,10 +9,6 @@
package
getty
import
(
"bytes"
)
// SessionCallback will be invoked when server accepts a new client connection or client connects to server successfully.
// if there are too many client connections or u do not want to connect a server again, u can return non-nil error. And
// then getty will close the new session.
...
...
@@ -22,7 +18,7 @@ type SessionCallback func(*Session) error
type
Reader
interface
{
// Parse pkg from buffer and if possible return a complete pkg
// If length of buf is not long enough, u should return {nil, nil}
Read
(
*
Session
,
*
bytes
.
Buffer
)
(
interface
{},
error
)
Read
(
*
Session
,
[]
byte
)
(
interface
{},
error
)
}
// Writer is used to marshal pkg and write to session
...
...
session.go
View file @
38afa856
...
...
@@ -491,7 +491,8 @@ func (this *Session) handlePackage() {
if
pktBuf
.
Len
()
<=
0
{
break
}
pkg
,
err
=
this
.
pkgHandler
.
Read
(
this
,
pktBuf
)
// pkg, err = this.pkgHandler.Read(this, pktBuf)
pkg
,
err
=
this
.
pkgHandler
.
Read
(
this
,
pktBuf
.
Bytes
())
if
err
!=
nil
{
log
.
Info
(
"%s, [session.pkgHandler.Read] = error{%+v}"
,
this
.
sessionToken
(),
err
)
errFlag
=
true
...
...
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