basic capability negotiation

- multi-prefix is supported as an example
This commit is contained in:
Jeremy Latt
2014-02-28 19:21:33 -08:00
parent 542744d52a
commit 36602c9a3c
7 changed files with 206 additions and 100 deletions
+36 -33
View File
@@ -12,36 +12,41 @@ func IsNickname(nick string) bool {
}
type Client struct {
atime time.Time
awayMessage string
channels ChannelSet
commands chan editableCommand
ctime time.Time
flags map[UserMode]bool
hasQuit bool
hops uint
hostname string
idleTimer *time.Timer
loginTimer *time.Timer
nick string
phase Phase
quitTimer *time.Timer
realname string
server *Server
socket *Socket
username string
atime time.Time
authorized bool
awayMessage string
capabilities CapabilitySet
capState CapState
channels ChannelSet
commands chan editableCommand
ctime time.Time
flags map[UserMode]bool
hasQuit bool
hops uint
hostname string
idleTimer *time.Timer
loginTimer *time.Timer
nick string
phase Phase
quitTimer *time.Timer
realname string
server *Server
socket *Socket
username string
}
func NewClient(server *Server, conn net.Conn) *Client {
now := time.Now()
client := &Client{
atime: now,
channels: make(ChannelSet),
commands: make(chan editableCommand),
ctime: now,
flags: make(map[UserMode]bool),
phase: server.InitPhase(),
server: server,
atime: now,
capState: CapNone,
capabilities: make(CapabilitySet),
channels: make(ChannelSet),
commands: make(chan editableCommand),
ctime: now,
flags: make(map[UserMode]bool),
phase: Registration,
server: server,
}
client.socket = NewSocket(conn, client.commands)
client.loginTimer = time.AfterFunc(LOGIN_TIMEOUT, client.connectionTimeout)
@@ -68,6 +73,12 @@ func (client *Client) run() {
}
}
func (client *Client) connectionTimeout() {
client.commands <- &QuitCommand{
message: "connection timeout",
}
}
//
// idle timer goroutine
//
@@ -76,14 +87,6 @@ func (client *Client) connectionIdle() {
client.server.idle <- client
}
//
// quit timer goroutine
//
func (client *Client) connectionTimeout() {
client.server.timeout <- client
}
//
// server goroutine
//