rename StartSimple

This commit is contained in:
Evan Burkey 2023-09-15 14:20:51 -07:00
parent ef19fa588f
commit 0677847105
11 changed files with 48 additions and 10 deletions

View File

@ -24,7 +24,7 @@ var (
func main() { func main() {
go broadcast() go broadcast()
err := conn.StartSimple(newUserHandler) err := conn.StartSimpleTCP(newUserHandler)
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }

View File

@ -1,5 +0,0 @@
package main
func main() {
}

View File

@ -10,7 +10,7 @@ import (
) )
func main() { func main() {
err := conn.StartSimple(meansToAnEnd) err := conn.StartSimpleTCP(meansToAnEnd)
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }

View File

@ -21,7 +21,7 @@ type data struct {
} }
func main() { func main() {
err := conn.StartSimple(primetime) err := conn.StartSimpleTCP(primetime)
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }

View File

@ -9,7 +9,7 @@ import (
) )
func main() { func main() {
err := conn.StartSimple(smoketest) err := conn.StartSimpleTCP(smoketest)
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }

View File

@ -0,0 +1,7 @@
package main
import "net"
type client struct {
conn net.Conn
}

6
cmd/speeddaemon/main.go Normal file
View File

@ -0,0 +1,6 @@
package main
func main() {
srv := newServer()
srv.run()
}

30
cmd/speeddaemon/server.go Normal file
View File

@ -0,0 +1,30 @@
package main
import (
"net"
"protohackers/pkg/conn"
)
type server struct {
cameras []client
dispatchers []client
}
func newServer() *server {
return &server{
cameras: []client{},
dispatchers: []client{},
}
}
func (s *server) run() error {
err := conn.StartSimpleTCP(s.handleConnection)
if err != nil {
return err
}
return nil
}
func (s *server) handleConnection(conn net.Conn) {
}

View File

@ -10,7 +10,7 @@ const (
Port = ":3030" Port = ":3030"
) )
func StartSimple(handler func(conn net.Conn)) error { func StartSimpleTCP(handler func(conn net.Conn)) error {
l, err := net.Listen("tcp4", Port) l, err := net.Listen("tcp4", Port)
if err != nil { if err != nil {
return err return err