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
16eda0f9
Commit
16eda0f9
authored
Oct 09, 2016
by
alexstocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add session.go:(Session)gettyConn
parent
7c2d384d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
12 deletions
+27
-12
dev.list
dev.list
+2
-0
session.go
session.go
+25
-12
No files found.
dev.list
View file @
16eda0f9
...
...
@@ -15,6 +15,8 @@
> 1 add client.go:NewWSSClient
>
> 2 add server.go:RunWSEventLoopWithTLS
>
> 3 add session.go:(Session*)gettyConn
- 2016/10/08
> 1 add websocket connection & client & server
...
...
session.go
View file @
16eda0f9
...
...
@@ -141,15 +141,31 @@ func (this *Session) Conn() net.Conn {
return
nil
}
func
(
this
*
Session
)
gettyConn
()
*
gettyConn
{
if
tc
,
ok
:=
this
.
conn
.
(
*
gettyTCPConn
);
ok
{
return
&
(
tc
.
gettyConn
)
}
if
wc
,
ok
:=
this
.
conn
.
(
*
gettyWSConn
);
ok
{
return
&
(
wc
.
gettyConn
)
}
return
nil
}
// return the connect statistic data
func
(
this
*
Session
)
Stat
()
string
{
var
conn
*
gettyConn
if
conn
=
this
.
gettyConn
();
conn
==
nil
{
return
""
}
return
fmt
.
Sprintf
(
outputFormat
,
this
.
sessionToken
(),
atomic
.
LoadUint32
(
&
(
this
.
conn
.
(
*
gettyConn
)
.
readCount
)),
atomic
.
LoadUint32
(
&
(
this
.
conn
.
(
*
gettyConn
)
.
writeCount
)),
atomic
.
LoadUint32
(
&
(
this
.
conn
.
(
*
gettyConn
)
.
readPkgCount
)),
atomic
.
LoadUint32
(
&
(
this
.
conn
.
(
*
gettyConn
)
.
writePkgCount
)),
atomic
.
LoadUint32
(
&
(
conn
.
readCount
)),
atomic
.
LoadUint32
(
&
(
conn
.
writeCount
)),
atomic
.
LoadUint32
(
&
(
conn
.
readPkgCount
)),
atomic
.
LoadUint32
(
&
(
conn
.
writePkgCount
)),
)
}
...
...
@@ -277,7 +293,11 @@ func (this *Session) RemoveAttribute(key string) {
}
func
(
this
*
Session
)
sessionToken
()
string
{
conn
:=
this
.
conn
.
(
*
gettyConn
)
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
)
}
...
...
@@ -339,13 +359,6 @@ func (this *Session) WriteBytesArray(pkgs ...[]byte) error {
length
+=
uint32
(
len
(
pkgs
[
i
]))
}
// // check len
// if msgLen > wsConn.maxMsgLen {
// return errors.New("message too long")
// } else if msgLen < 1 {
// return errors.New("message too short")
// }
// merge the pkgs
arr
=
make
([]
byte
,
length
)
l
=
0
...
...
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