client to server process outbound generic method
This commit is contained in:
parent
fccb32b0b1
commit
8879ef3f02
@ -44,6 +44,25 @@ func ProcessOutboundTextMessage(peer *Peer, text string, srv *InternalServer) ([
|
||||
return protoPackedServerMsg, nil
|
||||
}
|
||||
|
||||
// TODO refactor protobuf to avid 2 methods
|
||||
func ProcessOutboundMessage(peer *Peer, toServerMessage *meowlib.ToServerMessage, srv *InternalServer) ([]byte, error) {
|
||||
byteToServerMessage, err := proto.Marshal(toServerMessage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Encrypting it
|
||||
encToServerMessage, encToServerMessageSignature, err := srv.AsymEncryptMessage(byteToServerMessage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Packing it
|
||||
protoPackedServerMsg, err := srv.PackServerMessage(encToServerMessage, encToServerMessageSignature)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return protoPackedServerMsg, nil
|
||||
}
|
||||
|
||||
func ProcessServerResponse(srv *InternalServer, msg []byte) (*meowlib.FromServerMessage, error) {
|
||||
fsmsg := &meowlib.FromServerMessage{}
|
||||
payload, signature, err := srv.UnPackServerMessage(msg)
|
||||
|
Loading…
Reference in New Issue
Block a user