initial commit

This commit is contained in:
Jeremy Latt 2012-04-07 11:44:59 -07:00
commit a427e2bb47
6 changed files with 175 additions and 0 deletions

43
src/irc/protocol.go Normal file
View file

@ -0,0 +1,43 @@
package irc
import (
)
type Message struct {
line string
client *Client
}
func (m *Message) Encode() string {
return m.line
}
// Adapt `chan string` to a `chan Message`.
func NewMessageChan(strch chan string) chan Message {
msgch := make(chan Message)
done := make(chan bool)
go func() {
<- done
close(msgch)
}()
// str -> msg
go func() {
for str := range strch {
msgch <- Message{str, nil}
}
done <- true
}()
// msg -> str
go func() {
for message := range msgch {
strch <- message.Encode()
}
done <- true
}()
return msgch
}