41 lines
893 B
Go
41 lines
893 B
Go
package sircd
|
|
|
|
import (
|
|
"log"
|
|
"net"
|
|
"bytes"
|
|
)
|
|
|
|
func newClientIRCConnection(conn net.Conn, log *log.Logger) *clientIRCConnection {
|
|
c := new(clientIRCConnection)
|
|
c.conn = conn
|
|
c.log = log
|
|
c.inputBytes = new(bytes.Buffer)
|
|
c.outputBytes = new(bytes.Buffer)
|
|
c.ReadSocket()
|
|
return c
|
|
}
|
|
|
|
type clientIRCConnection struct {
|
|
Id uint64
|
|
conn net.Conn
|
|
log *log.Logger
|
|
inputBytes *bytes.Buffer
|
|
outputBytes *bytes.Buffer
|
|
}
|
|
|
|
func (c *clientIRCConnection) ReadSocket() {
|
|
// Read the incoming connection into the buffer.
|
|
buf := make([]byte, 1024*1024)
|
|
bytesRead, err := c.conn.Read(buf)
|
|
c.log.Printf("conn<%d>: read %d bytes from net", c.Id, bytesRead)
|
|
if err != nil {
|
|
c.log.Println("Error reading:", err.Error())
|
|
}
|
|
c.inputBytes.Write(buf)
|
|
}
|
|
|
|
func (c *clientIRCConnection) ParseMessages() {
|
|
c.log.Fatalln("not implemented")
|
|
}
|