support changing nicks (by reconnecting)
--HG-- branch : nmdc-ircfrontend
This commit is contained in:
parent
74e4f6cfa3
commit
c35062a3df
10
TODO.txt
10
TODO.txt
@ -2,16 +2,8 @@
|
|||||||
BUGS
|
BUGS
|
||||||
====
|
====
|
||||||
|
|
||||||
- option (maybe default?) to always use Hub-Security's name for system messages in main chat, for mirc/atomic
|
|
||||||
|
|
||||||
- flash of unstyled NMDC client tag
|
|
||||||
|
|
||||||
- Combined solution: mandate hubsec nick parameter, request CTCP VERSION prior to connection, and then apply mirc/atomic-specific fixes
|
|
||||||
|
|
||||||
- /wrong/ password message shows up, but not if no password was given for a passworded nick
|
- /wrong/ password message shows up, but not if no password was given for a passworded nick
|
||||||
|
|
||||||
- we're making a malformed NMDC client tag (no V: part)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WISHLIST
|
WISHLIST
|
||||||
@ -21,8 +13,6 @@ WISHLIST
|
|||||||
|
|
||||||
- automatic markdown bold/italic formatting
|
- automatic markdown bold/italic formatting
|
||||||
|
|
||||||
- support changing nick (via reconnecting)
|
|
||||||
|
|
||||||
- support WHOIS
|
- support WHOIS
|
||||||
|
|
||||||
- respond to CTCP VERSION with the clienttag on behalf of other users
|
- respond to CTCP VERSION with the clienttag on behalf of other users
|
||||||
|
23
server.go
23
server.go
@ -57,6 +57,7 @@ type Server struct {
|
|||||||
|
|
||||||
recievedFirstServerMessage bool
|
recievedFirstServerMessage bool
|
||||||
recievedCtcpVersion bool
|
recievedCtcpVersion bool
|
||||||
|
nickChangeAttempt int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(name string, upstream libnmdc.HubAddress, conn net.Conn) *Server {
|
func NewServer(name string, upstream libnmdc.HubAddress, conn net.Conn) *Server {
|
||||||
@ -245,8 +246,18 @@ func (s *Server) upstreamWorker() {
|
|||||||
s.sendNames() // delay doing this until now
|
s.sendNames() // delay doing this until now
|
||||||
}
|
}
|
||||||
if hubEvent.StateChange == libnmdc.CONNECTIONSTATE_DISCONNECTED {
|
if hubEvent.StateChange == libnmdc.CONNECTIONSTATE_DISCONNECTED {
|
||||||
|
if s.nickChangeAttempt > 0 {
|
||||||
|
// If this was a nick change, reconnect /immediately/
|
||||||
|
s.upstream = nil
|
||||||
|
s.clientState = CSRegistered
|
||||||
|
s.maybeStartUpstream() // launches new goroutine
|
||||||
|
|
||||||
|
} else {
|
||||||
// Abandon thread. Don't try to autoreconnect at our level, the remote client can be responsible for that
|
// Abandon thread. Don't try to autoreconnect at our level, the remote client can be responsible for that
|
||||||
s.DisconnectClient()
|
s.DisconnectClient()
|
||||||
|
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
case libnmdc.EVENT_HUBNAME_CHANGED:
|
case libnmdc.EVENT_HUBNAME_CHANGED:
|
||||||
@ -333,6 +344,18 @@ func (s *Server) handleCommand(command string, args []string) {
|
|||||||
// Required for compatibility with Lite IRC, which sends USER/NICK in the wrong order
|
// Required for compatibility with Lite IRC, which sends USER/NICK in the wrong order
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
s.ClientStateLock.Lock()
|
||||||
|
defer s.ClientStateLock.Unlock()
|
||||||
|
if s.upstream == nil {
|
||||||
|
// Not yet connected, should be safe to change nick
|
||||||
|
s.upstreamLauncher.Self.Nick = args[0]
|
||||||
|
} else {
|
||||||
|
// Need to disconnect/reconnect the upstream
|
||||||
|
s.nickChangeAttempt++
|
||||||
|
s.upstream.Disconnect()
|
||||||
|
}
|
||||||
|
|
||||||
s.reply(rplKill, "Can't change nicks on this server.")
|
s.reply(rplKill, "Can't change nicks on this server.")
|
||||||
s.DisconnectClient()
|
s.DisconnectClient()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user