Commit ddb95afc authored by alexstocks's avatar alexstocks

update conn.go:gettyWSConn{websocket.Conn} -> conn.go:gettyWSConn{*websocket.Conn}

parent 0e2aa36b
......@@ -17,20 +17,16 @@ import (
)
import (
log "github.com/AlexStocks/log4go"
// log "github.com/AlexStocks/log4go"
"github.com/gorilla/websocket"
)
var (
launchTime time.Time
launchTime time.Time = time.Now()
// ErrInvalidConnection = errors.New("connection has been closed.")
)
func init() {
launchTime = time.Now()
}
/////////////////////////////////////////
// connection interfacke
/////////////////////////////////////////
......@@ -41,6 +37,8 @@ type iConn interface {
UpdateActive()
GetActive() time.Time
write(p []byte) error
// don't distinguish between tcp connection and websocket connection. Because
// gorilla/websocket/conn.go:(Conn)Close also invoke net.Conn.Close
close(int)
}
......@@ -161,7 +159,7 @@ func (this *gettyTCPConn) close(waitSec int) {
type gettyWSConn struct {
gettyConn
conn websocket.Conn
conn *websocket.Conn
}
// create websocket connection
......@@ -179,7 +177,7 @@ func newGettyWSConn(conn *websocket.Conn) *gettyWSConn {
}
gettyWSConn := &gettyWSConn{
conn: *conn,
conn: conn,
gettyConn: gettyConn{
ID: atomic.AddUint32(&connID, 1),
local: localAddr,
......@@ -192,7 +190,6 @@ func newGettyWSConn(conn *websocket.Conn) *gettyWSConn {
}
func (this *gettyWSConn) handlePong(string) error {
log.Debug("get pong package")
this.UpdateActive()
return nil
}
......
......@@ -20,7 +20,9 @@
>
> 4 add conn.go:(gettyConn)GetActive, which can used as (Session)GetActive
>
> 5 version: 0.4.03
> 5 modify conn.go:gettyWSConn{websocket.Conn} -> conn.go:gettyWSConn{*websocket.Conn}
>
> 6 version: 0.4.03
- 2016/10/11
> 1 fix bug: use websocket.BinaryMessage in conn.go:(gettyWSConn)write
......
......@@ -147,7 +147,6 @@ func newWSHandler(server *Server, newSession NewSessionCallback) *wsHandler {
}
func (this *wsHandler) serveWSRequest(w http.ResponseWriter, r *http.Request) {
log.Debug("get client request:%#v", r)
if r.Method != "GET" {
// w.WriteHeader(http.StatusMethodNotAllowed)
http.Error(w, "Method not allowed", 405)
......
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