Move dead errors into webclient.
This commit is contained in:
@@ -315,18 +315,6 @@ func (g *group) getChatHistory() []chatHistoryEntry {
|
|||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
type writerDeadError int
|
|
||||||
|
|
||||||
func (err writerDeadError) Error() string {
|
|
||||||
return "client writer died"
|
|
||||||
}
|
|
||||||
|
|
||||||
type clientDeadError int
|
|
||||||
|
|
||||||
func (err clientDeadError) Error() string {
|
|
||||||
return "client dead"
|
|
||||||
}
|
|
||||||
|
|
||||||
type groupUser struct {
|
type groupUser struct {
|
||||||
Username string `json:"username,omitempty"`
|
Username string `json:"username,omitempty"`
|
||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
|
|||||||
+5
-2
@@ -1732,12 +1732,15 @@ func clientWriter(conn *websocket.Conn, ch <-chan interface{}, done chan<- struc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ErrWriterDead = errors.New("client writer died")
|
||||||
|
var ErrClientDead = errors.New("client dead")
|
||||||
|
|
||||||
func (c *webClient) action(m interface{}) error {
|
func (c *webClient) action(m interface{}) error {
|
||||||
select {
|
select {
|
||||||
case c.actionCh <- m:
|
case c.actionCh <- m:
|
||||||
return nil
|
return nil
|
||||||
case <-c.done:
|
case <-c.done:
|
||||||
return clientDeadError(0)
|
return ErrClientDead
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1746,7 +1749,7 @@ func (c *webClient) write(m clientMessage) error {
|
|||||||
case c.writeCh <- m:
|
case c.writeCh <- m:
|
||||||
return nil
|
return nil
|
||||||
case <-c.writerDone:
|
case <-c.writerDone:
|
||||||
return writerDeadError(0)
|
return ErrWriterDead
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user