3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-14 07:59:31 +01:00

reorganize structs

This commit is contained in:
Jeremy Latt 2012-04-17 19:08:04 -07:00
parent 962d9116d6
commit 8f0bd1b07a
2 changed files with 27 additions and 25 deletions

View File

@ -1,13 +1,5 @@
package irc
type Message interface {
Handle(s *Server, c *Client)
}
type NickMessage struct {
nickname string
}
func (m *NickMessage) Handle(s *Server, c *Client) {
if s.nicks[m.nickname] != nil {
c.send <- ErrNickNameInUse(m.nickname)
@ -21,13 +13,6 @@ func (m *NickMessage) Handle(s *Server, c *Client) {
tryRegister(s, c)
}
type UserMessage struct {
user string
mode uint8
unused string
realname string
}
func (m *UserMessage) Handle(s *Server, c *Client) {
if c.username != "" {
c.send <- ErrAlreadyRegistered(c.Nick())
@ -37,25 +22,15 @@ func (m *UserMessage) Handle(s *Server, c *Client) {
tryRegister(s, c)
}
type QuitMessage struct {
message string
}
func (m *QuitMessage) Handle(s *Server, c *Client) {
c.send <- MessageError()
delete(s.nicks, c.nick)
}
type UnknownMessage struct {
command string
}
func (m *UnknownMessage) Handle(s *Server, c *Client) {
c.send <- ErrUnknownCommand(c.Nick(), m.command)
}
type PingMessage struct {}
func (m *PingMessage) Handle(s *Server, c *Client) {
c.send <- MessagePong()
}

27
src/irc/message.go Normal file
View File

@ -0,0 +1,27 @@
package irc
type Message interface {
Handle(s *Server, c *Client)
}
type NickMessage struct {
nickname string
}
type UserMessage struct {
user string
mode uint8
unused string
realname string
}
type QuitMessage struct {
message string
}
type UnknownMessage struct {
command string
}
type PingMessage struct {}