mirror of
https://github.com/kataras/iris.git
synced 2025-03-13 21:36:28 +01:00
This commit is contained in:
parent
6544863edc
commit
5d369b7c73
|
@ -8,14 +8,14 @@ import (
|
|||
|
||||
// Currently only these 5 values are used for real
|
||||
const (
|
||||
// DefaultWriteTimeout 30 * time.Second
|
||||
DefaultWriteTimeout = 30 * time.Second
|
||||
// DefaultPongTimeout 120 * time.Second
|
||||
DefaultPongTimeout = 120 * time.Second
|
||||
// DefaultWriteTimeout 15 * time.Second
|
||||
DefaultWriteTimeout = 15 * time.Second
|
||||
// DefaultPongTimeout 60 * time.Second
|
||||
DefaultPongTimeout = 60 * time.Second
|
||||
// DefaultPingPeriod (DefaultPongTimeout * 9) / 10
|
||||
DefaultPingPeriod = (DefaultPongTimeout * 9) / 10
|
||||
// DefaultMaxMessageSize 2048
|
||||
DefaultMaxMessageSize = 2048
|
||||
// DefaultMaxMessageSize 1024
|
||||
DefaultMaxMessageSize = 1024
|
||||
)
|
||||
|
||||
//
|
||||
|
@ -23,16 +23,16 @@ const (
|
|||
// Websocket the config contains options for 'websocket' package
|
||||
type Websocket struct {
|
||||
// WriteTimeout time allowed to write a message to the connection.
|
||||
// Default value is 30 * time.Second
|
||||
// Default value is 15 * time.Second
|
||||
WriteTimeout time.Duration
|
||||
// PongTimeout allowed to read the next pong message from the connection
|
||||
// Default value is 120 * time.Second
|
||||
// Default value is 60 * time.Second
|
||||
PongTimeout time.Duration
|
||||
// PingPeriod send ping messages to the connection with this period. Must be less than PongTimeout
|
||||
// Default value is (PongTimeout * 9) / 10
|
||||
PingPeriod time.Duration
|
||||
// MaxMessageSize max message size allowed from connection
|
||||
// Default value is 2048
|
||||
// Default value is 1024
|
||||
MaxMessageSize int64
|
||||
// Endpoint is the path which the websocket server will listen for clients/connections
|
||||
// Default value is empty string, if you don't set it the Websocket server is disabled.
|
||||
|
|
|
@ -15,9 +15,10 @@ var (
|
|||
assetsURL = "https://github.com/iris-contrib/iris-control-assets/archive/master.zip"
|
||||
assetsUnzipname = "iris-control-assets"
|
||||
assetsPath = ""
|
||||
workingDir = ""
|
||||
)
|
||||
|
||||
// init just sets the assetsPath
|
||||
// init just sets the assetsPath & current workingDir
|
||||
func init() {
|
||||
homepath := ""
|
||||
if runtime.GOOS == "windows" {
|
||||
|
@ -26,6 +27,8 @@ func init() {
|
|||
homepath = os.Getenv("HOME")
|
||||
}
|
||||
assetsPath = homepath + utils.PathSeparator + ".iris" + utils.PathSeparator + "iris-control-assets" + utils.PathSeparator
|
||||
|
||||
workingDir, _ = os.Getwd()
|
||||
}
|
||||
|
||||
func installAssets() {
|
||||
|
|
|
@ -5,3 +5,11 @@ This package is new and unique, if you notice a bug or issue [post it here](http
|
|||
# How to use
|
||||
|
||||
[E-Book section](https://kataras.gitbooks.io/iris/content/package-websocket.html)
|
||||
|
||||
|
||||
## Notes
|
||||
|
||||
On **OSX + Safari**, we had an issue which is **fixed** now. BUT by the browser's Engine Design the socket is not closed until the whole browser window is closed,
|
||||
so the **connection.OnDisconnect** event will fire when the user closes the **window browser**, **not just the browser's tab**.
|
||||
|
||||
- Relative issue: https://github.com/kataras/iris/issues/175
|
||||
|
|
|
@ -94,6 +94,22 @@ func (c *connection) writer() {
|
|||
select {
|
||||
case msg, ok := <-c.send:
|
||||
if !ok {
|
||||
defer func() {
|
||||
|
||||
// FIX FOR: https://github.com/kataras/iris/issues/175
|
||||
// AS I TESTED ON TRIDENT ENGINE (INTERNET EXPLORER/SAFARI):
|
||||
// NAVIGATE TO SITE, CLOSE THE TAB, NOTHING HAPPENS
|
||||
// CLOSE THE WHOLE BROWSER, THEN THE c.conn is NOT NILL BUT ALL ITS FUNCTIONS PANICS, MEANS THAT IS THE STRUCT IS NOT NIL BUT THE WRITER/READER ARE NIL
|
||||
// THE ONLY SOLUTION IS TO RECOVER HERE AT ANY PANIC
|
||||
// THE FRAMETYPE = 8, c.closeSend = true
|
||||
// NOTE THAT THE CLIENT IS NOT DISCONNECTED UNTIL THE WHOLE WINDOW BROWSER CLOSED, this is engine's bug.
|
||||
//
|
||||
if err := recover(); err != nil {
|
||||
ticker.Stop()
|
||||
c.server.free <- c
|
||||
c.underline.Close()
|
||||
}
|
||||
}()
|
||||
c.write(websocket.CloseMessage, []byte{})
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user