Commit 1af7c15f authored by AlexStocks's avatar AlexStocks

update wss

parent 759b4f22
......@@ -38,7 +38,7 @@ type MessageHandler struct{}
func (this *MessageHandler) Handle(session getty.Session, pkg *EchoPackage) error {
log.Debug("get echo package{%s}", pkg)
fmt.Printf("get echo package{%s}\n", pkg)
return session.WritePkg(pkg)
return session.WritePkg(pkg, conf.GettySessionParam.waitTimeout)
}
////////////////////////////////////////////
......
......@@ -10,6 +10,10 @@
## develop history ##
---
- 2018/03/10
> improvement
* using getty 0.8.1
- 2017/04/27
> improvement
* enable wss client just using cert file;
......
......@@ -173,9 +173,10 @@ func echo() {
pkg.H.Len = (uint16)(len(pkg.B)) + 1
if session := client.selectSession(); session != nil {
err := session.WritePkg(&pkg)
err := session.WritePkg(&pkg, conf.GettySessionParam.waitTimeout)
if err != nil {
log.Warn("session.WritePkg(session{%s}, pkg{%s}) = error{%v}", session.Stat(), pkg, err)
log.Warn("session.WritePkg(session{%s}, pkg{%s}, timeout{%d}) = error{%v}",
session.Stat(), pkg, conf.GettySessionParam.waitTimeout, err)
session.Close()
client.removeSession(session)
}
......
......@@ -57,7 +57,7 @@ $(function() {
if (socket.readyState != socket.OPEN) {
if (!silence) {
addChatMessage({
Message: '!!Connection closed'
Message: '!!Connection closed\n'
});
}
return
......@@ -133,7 +133,7 @@ $(function() {
socket.close();
socket = null;
addChatMessage({
Message: '!!SYSTEM-WS-Close, connection disconnect'
Message: '!!SYSTEM-WS-Close, connection disconnect\n'
})
}
}
......@@ -234,13 +234,13 @@ $(function() {
// console.log("socket.onclose" + e.reason)
disconnect();
addChatMessage({
Message: e.reason + '!!SYSTEM-WS-Close, connection closed'
Message: e.reason + '!!SYSTEM-WS-Close, connection closed\n'
});
};
socket.onerror = function() {
addChatMessage({
Message: '!!SYSTEM-WS-Error, connection closed'
Message: '!!SYSTEM-WS-Error, connection closed\n'
});
}
});
......@@ -38,7 +38,7 @@ type MessageHandler struct{}
func (this *MessageHandler) Handle(session getty.Session, pkg *EchoPackage) error {
log.Debug("get echo package{%s}", pkg)
fmt.Printf("get echo package{%s}\n", pkg)
return session.WritePkg(pkg)
return session.WritePkg(pkg, conf.GettySessionParam.waitTimeout)
}
////////////////////////////////////////////
......@@ -126,6 +126,7 @@ func (this *EchoMessageHandler) OnCron(session getty.Session) {
flag bool
active time.Time
)
this.rwlock.RLock()
if _, ok := this.sessionMap[session]; ok {
active = session.GetActive()
......@@ -136,6 +137,7 @@ func (this *EchoMessageHandler) OnCron(session getty.Session) {
}
}
this.rwlock.RUnlock()
if flag {
this.rwlock.Lock()
delete(this.sessionMap, session)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment