Add SERVER_MESSAGE and JustSendMessage to communication package
This commit is contained in:
parent
f471ef13a2
commit
e70a34b10a
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SERVER_COMMAND = 1 + iota
|
SERVER_COMMAND = 1 + iota
|
||||||
|
SERVER_MESSAGE
|
||||||
CLIENT_RESPONSE
|
CLIENT_RESPONSE
|
||||||
P2P_MESSAGE
|
P2P_MESSAGE
|
||||||
)
|
)
|
||||||
|
@ -32,6 +33,14 @@ func AskClientNickname() ([]byte, error) {
|
||||||
return c.Bytes()
|
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) {
|
func (c *communicationMessage) Bytes() ([]byte, error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
encoder := gob.NewEncoder(&buf)
|
encoder := gob.NewEncoder(&buf)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user