mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
reduce writes
This commit is contained in:
parent
dcb4ac90e2
commit
f090c616b3
@ -113,13 +113,13 @@ func (channel *Channel) Join(client *Client, key string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client.channels.Add(channel)
|
||||||
channel.members.Add(client)
|
channel.members.Add(client)
|
||||||
if len(channel.members) == 1 {
|
if len(channel.members) == 1 {
|
||||||
channel.members[client][ChannelCreator] = true
|
channel.members[client][ChannelCreator] = true
|
||||||
channel.members[client][ChannelOperator] = true
|
channel.members[client][ChannelOperator] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
client.channels.Add(channel)
|
|
||||||
channel.Reply(RplJoin(client, channel))
|
channel.Reply(RplJoin(client, channel))
|
||||||
channel.GetTopic(client)
|
channel.GetTopic(client)
|
||||||
channel.Names(client)
|
channel.Names(client)
|
||||||
|
@ -40,8 +40,8 @@ func NewStringReply(source Identifier, code StringCode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (reply *StringReply) Format(client *Client) []string {
|
func (reply *StringReply) Format(client *Client) []string {
|
||||||
message := fmt.Sprintf(":%s %s %s",
|
message := fmt.Sprintf(":%s %s %s%s",
|
||||||
reply.id, reply.code, reply.message)
|
reply.id, reply.code, reply.message, CRLF)
|
||||||
return []string{message}
|
return []string{message}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,8 +64,8 @@ func NewNumericReply(source Identifier, code NumericCode, format string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (reply *NumericReply) Format(client *Client) []string {
|
func (reply *NumericReply) Format(client *Client) []string {
|
||||||
message := fmt.Sprintf(":%s %s %s %s",
|
message := fmt.Sprintf(":%s %s %s %s%s",
|
||||||
reply.id, reply.code, client.Nick(), reply.message)
|
reply.id, reply.code, client.Nick(), reply.message, CRLF)
|
||||||
return []string{message}
|
return []string{message}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,9 +376,9 @@ func (m *JoinCommand) HandleServer(s *Server) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for name := range m.channels {
|
for name, key := range m.channels {
|
||||||
channel := s.GetOrMakeChannel(name)
|
channel := s.GetOrMakeChannel(name)
|
||||||
channel.Join(client, m.channels[name])
|
channel.Join(client, key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ type Socket struct {
|
|||||||
func NewSocket(conn net.Conn) *Socket {
|
func NewSocket(conn net.Conn) *Socket {
|
||||||
socket := &Socket{
|
socket := &Socket{
|
||||||
conn: conn,
|
conn: conn,
|
||||||
done: make(chan bool),
|
done: make(chan bool, 1),
|
||||||
reader: bufio.NewReader(conn),
|
reader: bufio.NewReader(conn),
|
||||||
receive: make(chan string, 16),
|
receive: make(chan string, 16),
|
||||||
send: 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) {
|
if _, err := socket.writer.WriteString(line); socket.isError(err, W) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if _, err := socket.writer.WriteString(CRLF); socket.isError(err, W) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := socket.writer.Flush(); socket.isError(err, W) {
|
if err := socket.writer.Flush(); socket.isError(err, W) {
|
||||||
break
|
break
|
||||||
@ -98,6 +95,9 @@ func (socket *Socket) writeLines() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case done = <-socket.done:
|
case done = <-socket.done:
|
||||||
|
if DEBUG_NET {
|
||||||
|
log.Printf("%s done", socket)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user