move Handshake to data/network.go

This commit is contained in:
Lennart Buhl 2016-02-06 15:18:07 +01:00
parent 72c850c0e7
commit 35e143094e
4 changed files with 7 additions and 7 deletions

View File

@ -30,7 +30,7 @@ var (
func register(con net.Conn, id int) error {
w, h := 0, 0 //data.TestNC()
enc := gob.NewEncoder(con) // Encoder
err := enc.Encode(handshake{ID: id, H: h, W: w})
err := enc.Encode(data.Handshake{ID: id, H: h, W: w})
return err
}

View File

@ -6,8 +6,6 @@ import (
"github.com/spf13/cobra"
)
type handshake struct{ ID, W, H int }
var CmdGosl = &cobra.Command{
Use: "gosl [command]",
Short: "Run a gosl instance",

View File

@ -39,7 +39,7 @@ var clients map[int]goslClient = make(map[int]goslClient)
var clientKeys []int = make([]int, 100)
func handleConn(conn *net.TCPConn) {
var hs handshake
var hs data.Handshake
log.Println("Got a connection!")
// handshake
dec := gob.NewDecoder(conn) // Decoder

View File

@ -5,10 +5,12 @@ import (
)
type Handshake struct {
Client int
Name string
ID int
// Name string
W int
H int
}
func (h Handshake) String() string {
return (h.Name + ": " + strconv.Itoa(h.Client))
return (strconv.Itoa(h.ID) + ": " + strconv.Itoa(h.W) + "×" + strconv.Itoa(h.H))
}