forked from External/ergo
initial commit
This commit is contained in:
commit
a427e2bb47
6 changed files with 175 additions and 0 deletions
28
src/irc/client.go
Normal file
28
src/irc/client.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package irc
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
|
||||
type Client struct {
|
||||
conn net.Conn
|
||||
ch chan Message
|
||||
}
|
||||
|
||||
func NewClient(conn net.Conn) *Client {
|
||||
return &Client{conn, NewMessageChan(NewStringChan(conn))}
|
||||
}
|
||||
|
||||
// Write messages from the client to the server.
|
||||
func (c *Client) Communicate(server chan Message) {
|
||||
for message := range c.ch {
|
||||
message.client = c
|
||||
server <- message
|
||||
}
|
||||
c.Close()
|
||||
}
|
||||
|
||||
func (c *Client) Close() {
|
||||
c.conn.Close()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue