move Handshake to data/network.go
This commit is contained in:
parent
72c850c0e7
commit
35e143094e
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user