hostname string
conn net.Conn
registered bool
- ping_sent bool
- timestamp time.Time
nickname string
username string
realname string
}
+type ClientAlivenessState struct {
+ ping_sent bool
+ timestamp time.Time
+}
+
func (client Client) String() string {
return client.nickname + "!" + client.username + "@" + client.conn.RemoteAddr().String()
}
// Client processor blockingly reads everything remote client sends,
// splits messages by CRLF and send them to Daemon gorouting for processing
// it futher. Also it can signalize that client is unavailable (disconnected).
-func (client *Client) Processor(sink chan ClientEvent) {
+func (client *Client) Processor(sink chan<- ClientEvent) {
var buf_net []byte
buf := make([]byte, 0)
- log.Println("New client", client)
+ log.Println(client, "New client")
sink <- ClientEvent{client, EVENT_NEW, ""}
for {
buf_net = make([]byte, BUF_SIZE)
sink <- ClientEvent{client, EVENT_DEL, ""}
break
}
- client.timestamp = time.Now()
- client.ping_sent = false
buf_net = bytes.TrimRight(buf_net, "\x00")
buf = append(buf, buf_net...)
if !bytes.HasSuffix(buf, []byte(CRLF)) {
func (client *Client) ReplyNoChannel(channel string) {
client.ReplyNicknamed("403", channel, "No such channel")
}
+
+func (client *Client) ReplyNoNickChan(channel string) {
+ client.ReplyNicknamed("401", channel, "No such nick/channel")
+}