Added /quit, the server IRC client gets cleaned up properly when quitting, pulled command handling out into a separate file
This commit is contained in:
parent
d11aa3ff4e
commit
99ef788906
8 changed files with 83 additions and 49 deletions
18
session.go
18
session.go
|
@ -30,9 +30,9 @@ func NewSession() *Session {
|
|||
|
||||
func (s *Session) getIRC(server string) (*IRC, bool) {
|
||||
s.ircLock.Lock()
|
||||
defer s.ircLock.Unlock()
|
||||
|
||||
irc, ok := s.irc[server]
|
||||
s.ircLock.Unlock()
|
||||
|
||||
return irc, ok
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,20 @@ func (s *Session) setIRC(server string, irc *IRC) {
|
|||
s.ircLock.Unlock()
|
||||
}
|
||||
|
||||
func (s *Session) deleteIRC(server string) {
|
||||
s.ircLock.Lock()
|
||||
delete(s.irc, server)
|
||||
s.ircLock.Unlock()
|
||||
}
|
||||
|
||||
func (s *Session) numIRC() int {
|
||||
s.ircLock.Lock()
|
||||
n := len(s.irc)
|
||||
s.ircLock.Unlock()
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func (s *Session) setWS(addr string, ws *websocket.Conn) {
|
||||
socket := NewWebSocket(ws)
|
||||
go socket.write()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue