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
ef9876b2
Commit
ef9876b2
authored
Oct 13, 2016
by
alexstocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add conn.go:(gettyWSConn)writePing
parent
ee832003
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
9 deletions
+29
-9
conn.go
conn.go
+4
-0
dev.list
dev.list
+9
-2
server.go
server.go
+1
-1
session.go
session.go
+12
-3
version.go
version.go
+3
-3
No files found.
conn.go
View file @
ef9876b2
...
...
@@ -183,6 +183,10 @@ func (this *gettyWSConn) write(p []byte) error {
return
this
.
conn
.
WriteMessage
(
websocket
.
BinaryMessage
,
p
)
}
func
(
this
*
gettyWSConn
)
writePing
()
error
{
return
this
.
conn
.
WriteMessage
(
websocket
.
PingMessage
,
[]
byte
{})
}
// close websocket connection
func
(
this
*
gettyWSConn
)
close
(
waitSec
int
)
{
this
.
conn
.
UnderlyingConn
()
.
(
*
net
.
TCPConn
)
.
SetLinger
(
waitSec
)
...
...
dev.list
View file @
ef9876b2
...
...
@@ -11,10 +11,17 @@
## develop history ##
---
- 2016/10/13
> 1 add conn.go:(gettyWSConn)writePing
>
> 2 modify session.go:(Session)handleLoop:Websocket session will send ping frame automatically every peroid.
>
> 3 version: 0.4.03
- 2016/10/11
> 1 fix bug: use websocket.BinaryMessage in conn.go:(gettyWSConn)write
>
> 2 version: 0.4.02
> 2 version: 0.4.02
- 2016/10/10
> 1 delete session.go:Session{errFlag} to invoke codec.go:EventListener{OnClose&OnError} both when got a error
...
...
@@ -25,7 +32,7 @@
>
> 4 add modify session.go:(Session)maxMsgLen for websocket session
>
> 5 version: 0.4.01
> 5 version: 0.4.01
- 2016/10/09
> 1 add client.go:NewWSSClient
...
...
server.go
View file @
ef9876b2
...
...
@@ -141,7 +141,7 @@ func newWSHandler(server *Server, newSession NewSessionCallback) *wsHandler {
upgrader
:
websocket
.
Upgrader
{
// in default, ReadBufferSize & WriteBufferSize is 4k
// HandshakeTimeout: server.HTTPTimeout,
CheckOrigin
:
func
(
_
*
http
.
Request
)
bool
{
return
true
},
CheckOrigin
:
func
(
_
*
http
.
Request
)
bool
{
return
true
},
// allow connections from any origin
},
}
}
...
...
session.go
View file @
ef9876b2
...
...
@@ -204,7 +204,7 @@ func (this *Session) SetWriter(writer Writer) {
this
.
writer
=
writer
}
// period is in millisecond
// period is in millisecond
. Websocket session will send ping frame automatically every peroid.
func
(
this
*
Session
)
SetCronPeriod
(
period
int
)
{
if
period
<
1
{
panic
(
"@period < 1"
)
...
...
@@ -400,8 +400,10 @@ func (this *Session) RunEventLoop() {
func
(
this
*
Session
)
handleLoop
()
{
var
(
err
error
flag
bool
err
error
flag
bool
wsFlag
bool
wsConn
*
gettyWSConn
// start time.Time
counter
gxtime
.
CountWatch
// ticker *time.Ticker // use wheel instead, 2016/09/26
...
...
@@ -428,6 +430,7 @@ func (this *Session) handleLoop() {
this
.
gc
()
}()
wsConn
,
wsFlag
=
this
.
iConn
.
(
*
gettyWSConn
)
flag
=
true
// do not do any read/write/cron operation while got write error
// ticker = time.NewTicker(this.period) // use wheel instead, 2016/09/26
LOOP
:
...
...
@@ -474,6 +477,12 @@ LOOP:
// case <-ticker.C: // use wheel instead, 2016/09/26
case
<-
wheel
.
After
(
this
.
period
)
:
if
flag
{
if
wsFlag
{
err
=
wsConn
.
writePing
()
if
err
!=
nil
{
log
.
Warn
(
"wsConn.writePing() = error{%#v}"
,
err
)
}
}
this
.
listener
.
OnCron
(
this
)
}
}
...
...
version.go
View file @
ef9876b2
...
...
@@ -10,9 +10,9 @@
package
getty
const
(
Version
=
"0.4.0
2
"
DATE
=
"2016/10/1
2
"
Version
=
"0.4.0
3
"
DATE
=
"2016/10/1
3
"
GETTY_MAJOR
=
0
GETTY_MINOR
=
4
GETTY_BUILD
=
2
GETTY_BUILD
=
3
)
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