FromServerMessage processing
This commit is contained in:
parent
d41873f9f3
commit
684d444bc8
@ -1,6 +1,11 @@
|
||||
package client
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"forge.redroom.link/yves/meowlib"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func ProcessOutboundTextMessage(peer *Peer, text string, srv *InternalServer) ([]byte, error) {
|
||||
// Creating User message
|
||||
@ -38,3 +43,19 @@ func ProcessOutboundTextMessage(peer *Peer, text string, srv *InternalServer) ([
|
||||
}
|
||||
return protoPackedServerMsg, nil
|
||||
}
|
||||
|
||||
func ProcessServerResponse(srv *InternalServer, msg []byte) (fsmsg *meowlib.FromServerMessage, err error) {
|
||||
|
||||
payload, signature, err := srv.UnPackServerMessage(msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
decrypted, err := srv.AsymDecryptMessage(payload, signature)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := proto.Unmarshal(decrypted, fsmsg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return fsmsg, nil
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ func (p *Peer) PackUserMessage(message []byte, signature []byte) *meowlib.Packed
|
||||
return &msg
|
||||
}
|
||||
|
||||
func (ints *InternalServer) UnPackUserMessage(protoPackedMessage []byte) (payload []byte, signature []byte, err error) {
|
||||
func (p *Peer) UnPackUserMessage(protoPackedMessage []byte) (payload []byte, signature []byte, err error) {
|
||||
msg := &meowlib.PackedServerMessage{}
|
||||
if err := proto.Unmarshal(protoPackedMessage, msg); err != nil {
|
||||
return nil, nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user