- for _, msg := range bytes.Split(buf[:len(buf)-2], []byte(CRLF)) {
- if len(msg) > 0 {
- sink <- ClientEvent{client, EVENT_MSG, string(msg)}
- }
- }
- buf = []byte{}
+ sink <- ClientEvent{c, EventMsg, string(buf[:i])}
+ copy(buf, buf[i+2:prev])
+ prev -= (i + 2)
+ goto CheckMore
+ }
+ c.Close()
+ sink <- ClientEvent{c, EventDel, ""}
+}
+
+func (c *Client) MsgSender() {
+ for msg := range c.outBuf {
+ c.conn.Write(append([]byte(msg), CRLF...))