mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-22 20:09:41 +01:00
don't allow send on closed channels
This commit is contained in:
parent
ca25828804
commit
7a2c9db503
@ -53,14 +53,26 @@ func (channel *Channel) Destroy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
close(channel.replies)
|
close(channel.replies)
|
||||||
|
channel.replies = nil
|
||||||
close(channel.commands)
|
close(channel.commands)
|
||||||
|
channel.commands = nil
|
||||||
|
|
||||||
channel.server.channels.Remove(channel)
|
channel.server.channels.Remove(channel)
|
||||||
|
|
||||||
channel.destroyed = true
|
channel.destroyed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (channel *Channel) Command(command ChannelCommand) {
|
||||||
|
if channel.commands == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
channel.commands <- command
|
||||||
|
}
|
||||||
|
|
||||||
func (channel *Channel) Reply(replies ...Reply) {
|
func (channel *Channel) Reply(replies ...Reply) {
|
||||||
|
if channel.replies == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
for _, reply := range replies {
|
for _, reply := range replies {
|
||||||
channel.replies <- reply
|
channel.replies <- reply
|
||||||
}
|
}
|
||||||
|
@ -161,6 +161,7 @@ func (client *Client) Destroy() {
|
|||||||
client.conn.Close()
|
client.conn.Close()
|
||||||
|
|
||||||
close(client.replies)
|
close(client.replies)
|
||||||
|
client.replies = nil
|
||||||
|
|
||||||
if client.idleTimer != nil {
|
if client.idleTimer != nil {
|
||||||
client.idleTimer.Stop()
|
client.idleTimer.Stop()
|
||||||
@ -177,6 +178,9 @@ func (client *Client) Destroy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) Reply(replies ...Reply) {
|
func (client *Client) Reply(replies ...Reply) {
|
||||||
|
if client.replies == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
for _, reply := range replies {
|
for _, reply := range replies {
|
||||||
client.replies <- reply
|
client.replies <- reply
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ func (m *JoinCommand) HandleServer(s *Server) {
|
|||||||
cmd := &PartCommand{}
|
cmd := &PartCommand{}
|
||||||
cmd.SetClient(c)
|
cmd.SetClient(c)
|
||||||
for channel := range c.channels {
|
for channel := range c.channels {
|
||||||
channel.commands <- cmd
|
channel.Command(cmd)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user