mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-14 16:09:32 +01:00
reorganize structs
This commit is contained in:
parent
962d9116d6
commit
8f0bd1b07a
@ -1,13 +1,5 @@
|
|||||||
package irc
|
package irc
|
||||||
|
|
||||||
type Message interface {
|
|
||||||
Handle(s *Server, c *Client)
|
|
||||||
}
|
|
||||||
|
|
||||||
type NickMessage struct {
|
|
||||||
nickname string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *NickMessage) Handle(s *Server, c *Client) {
|
func (m *NickMessage) Handle(s *Server, c *Client) {
|
||||||
if s.nicks[m.nickname] != nil {
|
if s.nicks[m.nickname] != nil {
|
||||||
c.send <- ErrNickNameInUse(m.nickname)
|
c.send <- ErrNickNameInUse(m.nickname)
|
||||||
@ -21,13 +13,6 @@ func (m *NickMessage) Handle(s *Server, c *Client) {
|
|||||||
tryRegister(s, c)
|
tryRegister(s, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserMessage struct {
|
|
||||||
user string
|
|
||||||
mode uint8
|
|
||||||
unused string
|
|
||||||
realname string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *UserMessage) Handle(s *Server, c *Client) {
|
func (m *UserMessage) Handle(s *Server, c *Client) {
|
||||||
if c.username != "" {
|
if c.username != "" {
|
||||||
c.send <- ErrAlreadyRegistered(c.Nick())
|
c.send <- ErrAlreadyRegistered(c.Nick())
|
||||||
@ -37,25 +22,15 @@ func (m *UserMessage) Handle(s *Server, c *Client) {
|
|||||||
tryRegister(s, c)
|
tryRegister(s, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
type QuitMessage struct {
|
|
||||||
message string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *QuitMessage) Handle(s *Server, c *Client) {
|
func (m *QuitMessage) Handle(s *Server, c *Client) {
|
||||||
c.send <- MessageError()
|
c.send <- MessageError()
|
||||||
delete(s.nicks, c.nick)
|
delete(s.nicks, c.nick)
|
||||||
}
|
}
|
||||||
|
|
||||||
type UnknownMessage struct {
|
|
||||||
command string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *UnknownMessage) Handle(s *Server, c *Client) {
|
func (m *UnknownMessage) Handle(s *Server, c *Client) {
|
||||||
c.send <- ErrUnknownCommand(c.Nick(), m.command)
|
c.send <- ErrUnknownCommand(c.Nick(), m.command)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PingMessage struct {}
|
|
||||||
|
|
||||||
func (m *PingMessage) Handle(s *Server, c *Client) {
|
func (m *PingMessage) Handle(s *Server, c *Client) {
|
||||||
c.send <- MessagePong()
|
c.send <- MessagePong()
|
||||||
}
|
}
|
||||||
|
27
src/irc/message.go
Normal file
27
src/irc/message.go
Normal 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 {}
|
Loading…
Reference in New Issue
Block a user