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
5d50a01f
Commit
5d50a01f
authored
Nov 02, 2016
by
alexstocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add session.go:(Session){ID, LocalAddr, RemoteAddr}
parent
f5224e3a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
13 deletions
+41
-13
change_log.md
change_log.md
+7
-1
conn.go
conn.go
+15
-0
session.go
session.go
+16
-9
version.go
version.go
+3
-3
No files found.
change_log.md
View file @
5d50a01f
...
...
@@ -11,13 +11,19 @@
## develop history ##
---
-
2016/11/02
> 1 add session.go:Session{ID(), LocalAddr(), RemoteAddr()}
>
> 2 add conn.go:iConn{id(), localAddr(), remoteAddr()}
>
> 2 version: 0.4.08
-
2016/11/01
> 1 session.go:Session{maxPkgLen(int)} -> Session{maxPkgLen(int32)}
>
> 2 add remarks in session.go
>
> 2 version: 0.4.07
> 2 version: 0.4.07
(0.4.06 is a obsolete version)
-
2016/10/21
> 1 session.go:(Session)RunEventLoop -> session.go:(Session)run
...
...
conn.go
View file @
5d50a01f
...
...
@@ -32,6 +32,9 @@ var (
/////////////////////////////////////////
type
iConn
interface
{
id
()
uint32
localAddr
()
string
remoteAddr
()
string
incReadPkgCount
()
incWritePkgCount
()
updateActive
()
...
...
@@ -68,6 +71,18 @@ type gettyConn struct {
peer
string
// peer address
}
func
(
this
*
gettyConn
)
id
()
uint32
{
return
this
.
ID
}
func
(
this
*
gettyConn
)
localAddr
()
string
{
return
this
.
local
}
func
(
this
*
gettyConn
)
remoteAddr
()
string
{
return
this
.
peer
}
func
(
this
*
gettyConn
)
incReadPkgCount
()
{
atomic
.
AddUint32
(
&
this
.
readPkgCount
,
1
)
}
...
...
session.go
View file @
5d50a01f
...
...
@@ -77,9 +77,6 @@ type Session struct {
lock
sync
.
RWMutex
}
// if nerr, ok = err.(net.Error); ok && nerr.Timeout() {
// break
// }
func
NewSession
()
*
Session
{
session
:=
&
Session
{
name
:
defaultSessionName
,
...
...
@@ -166,6 +163,21 @@ func (this *Session) gettyConn() *gettyConn {
return
nil
}
// get session ID
func
(
this
*
Session
)
ID
()
uint32
{
return
this
.
iConn
.
id
()
}
// get local address
func
(
this
*
Session
)
LocalAddr
()
string
{
return
this
.
iConn
.
localAddr
()
}
// get peer address
func
(
this
*
Session
)
RemoteAddr
()
string
{
return
this
.
iConn
.
remoteAddr
()
}
// return the connect statistic data
func
(
this
*
Session
)
Stat
()
string
{
var
conn
*
gettyConn
...
...
@@ -315,12 +327,7 @@ func (this *Session) GetActive() time.Time {
}
func
(
this
*
Session
)
sessionToken
()
string
{
var
conn
*
gettyConn
if
conn
=
this
.
gettyConn
();
conn
==
nil
{
return
""
}
return
fmt
.
Sprintf
(
"{%s:%d:%s<->%s}"
,
this
.
name
,
conn
.
ID
,
conn
.
local
,
conn
.
peer
)
return
fmt
.
Sprintf
(
"{%s:%d:%s<->%s}"
,
this
.
name
,
this
.
iConn
.
id
(),
this
.
iConn
.
localAddr
(),
this
.
iConn
.
remoteAddr
())
}
// Queued write, for handler
...
...
version.go
View file @
5d50a01f
...
...
@@ -10,9 +10,9 @@
package
getty
const
(
Version
=
"0.4.0
7
"
DATE
=
"2016/11/0
1
"
Version
=
"0.4.0
8
"
DATE
=
"2016/11/0
2
"
GETTY_MAJOR
=
0
GETTY_MINOR
=
4
GETTY_BUILD
=
7
GETTY_BUILD
=
8
)
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