diff options
Diffstat (limited to 'core/network.go')
| -rw-r--r-- | core/network.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/core/network.go b/core/network.go new file mode 100644 index 0000000..3065f19 --- /dev/null +++ b/core/network.go @@ -0,0 +1,23 @@ +package core + +import ( + "encoding/binary" + "fmt" + "net" +) + +func Send(conn net.Conn, dataType DataType, data Marshaler) error { + packet := []any{uint8(dataType)} + packet = append(packet, data.Marshal()...) + + fmt.Println(packet) + + for _, v := range packet { + err := binary.Write(conn, binary.BigEndian, v) + if err != nil { + return err + } + } + + return nil +} |
