3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 10:42:52 +01:00

reduce writes

This commit is contained in:
Jeremy Latt 2014-02-18 19:31:59 -08:00
parent dcb4ac90e2
commit f090c616b3
4 changed files with 11 additions and 11 deletions

View File

@ -113,13 +113,13 @@ func (channel *Channel) Join(client *Client, key string) {
return
}
client.channels.Add(channel)
channel.members.Add(client)
if len(channel.members) == 1 {
channel.members[client][ChannelCreator] = true
channel.members[client][ChannelOperator] = true
}
client.channels.Add(channel)
channel.Reply(RplJoin(client, channel))
channel.GetTopic(client)
channel.Names(client)

View File

@ -40,8 +40,8 @@ func NewStringReply(source Identifier, code StringCode,
}
func (reply *StringReply) Format(client *Client) []string {
message := fmt.Sprintf(":%s %s %s",
reply.id, reply.code, reply.message)
message := fmt.Sprintf(":%s %s %s%s",
reply.id, reply.code, reply.message, CRLF)
return []string{message}
}
@ -64,8 +64,8 @@ func NewNumericReply(source Identifier, code NumericCode, format string,
}
func (reply *NumericReply) Format(client *Client) []string {
message := fmt.Sprintf(":%s %s %s %s",
reply.id, reply.code, client.Nick(), reply.message)
message := fmt.Sprintf(":%s %s %s %s%s",
reply.id, reply.code, client.Nick(), reply.message, CRLF)
return []string{message}
}

View File

@ -376,9 +376,9 @@ func (m *JoinCommand) HandleServer(s *Server) {
return
}
for name := range m.channels {
for name, key := range m.channels {
channel := s.GetOrMakeChannel(name)
channel.Join(client, m.channels[name])
channel.Join(client, key)
}
}

View File

@ -24,7 +24,7 @@ type Socket struct {
func NewSocket(conn net.Conn) *Socket {
socket := &Socket{
conn: conn,
done: make(chan bool),
done: make(chan bool, 1),
reader: bufio.NewReader(conn),
receive: make(chan string, 16),
send: make(chan string, 16),
@ -86,9 +86,6 @@ func (socket *Socket) writeLines() {
if _, err := socket.writer.WriteString(line); socket.isError(err, W) {
break
}
if _, err := socket.writer.WriteString(CRLF); socket.isError(err, W) {
break
}
if err := socket.writer.Flush(); socket.isError(err, W) {
break
@ -98,6 +95,9 @@ func (socket *Socket) writeLines() {
}
case done = <-socket.done:
if DEBUG_NET {
log.Printf("%s done", socket)
}
continue
}
}