Add SERVER_MESSAGE and JustSendMessage to communication package

This commit is contained in:
qowevisa 2024-05-01 17:32:18 +03:00
parent f471ef13a2
commit e70a34b10a

View File

@ -7,6 +7,7 @@ import (
const (
SERVER_COMMAND = 1 + iota
SERVER_MESSAGE
CLIENT_RESPONSE
P2P_MESSAGE
)
@ -32,6 +33,14 @@ func AskClientNickname() ([]byte, error) {
return c.Bytes()
}
func JustGetMessage(msg []byte) ([]byte, error) {
c := communicationMessage{
Type: SERVER_MESSAGE,
Data: msg,
}
return c.Bytes()
}
func (c *communicationMessage) Bytes() ([]byte, error) {
var buf bytes.Buffer
encoder := gob.NewEncoder(&buf)