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 {
|
func register(con net.Conn, id int) error {
|
||||||
w, h := 0, 0 //data.TestNC()
|
w, h := 0, 0 //data.TestNC()
|
||||||
enc := gob.NewEncoder(con) // Encoder
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,6 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
type handshake struct{ ID, W, H int }
|
|
||||||
|
|
||||||
var CmdGosl = &cobra.Command{
|
var CmdGosl = &cobra.Command{
|
||||||
Use: "gosl [command]",
|
Use: "gosl [command]",
|
||||||
Short: "Run a gosl instance",
|
Short: "Run a gosl instance",
|
||||||
|
|
|
@ -39,7 +39,7 @@ var clients map[int]goslClient = make(map[int]goslClient)
|
||||||
var clientKeys []int = make([]int, 100)
|
var clientKeys []int = make([]int, 100)
|
||||||
|
|
||||||
func handleConn(conn *net.TCPConn) {
|
func handleConn(conn *net.TCPConn) {
|
||||||
var hs handshake
|
var hs data.Handshake
|
||||||
log.Println("Got a connection!")
|
log.Println("Got a connection!")
|
||||||
// handshake
|
// handshake
|
||||||
dec := gob.NewDecoder(conn) // Decoder
|
dec := gob.NewDecoder(conn) // Decoder
|
||||||
|
|
|
@ -5,10 +5,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Handshake struct {
|
type Handshake struct {
|
||||||
Client int
|
ID int
|
||||||
Name string
|
// Name string
|
||||||
|
W int
|
||||||
|
H int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h Handshake) String() string {
|
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