diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-04-28 17:00:17 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-04-28 17:00:17 -0400 |
commit | e683f156b7eb8e761c254704538914d86f309801 (patch) | |
tree | e239803c2f775cbb914a8c7db44189974728781a /ProtocolBuffers.hs | |
parent | e833b89e2a1a1c2acbc0eb8bed1760ef0e50f3c5 (diff) | |
download | debug-me-e683f156b7eb8e761c254704538914d86f309801.tar.gz |
control window and chatting
Works!
Diffstat (limited to 'ProtocolBuffers.hs')
-rw-r--r-- | ProtocolBuffers.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ProtocolBuffers.hs b/ProtocolBuffers.hs index 53dfca0..51cc552 100644 --- a/ProtocolBuffers.hs +++ b/ProtocolBuffers.hs @@ -7,6 +7,9 @@ - The message types in here define protocol buffers, so should be changed - with care. These messages correspond to the main data types in the Types - module. + - + - Note that the type level numbers used with fields should never be + - changed. -} module ProtocolBuffers where @@ -63,6 +66,10 @@ data ControlActionP { sessionKeyAcceptedP :: Required 14 (Message PublicKeyP) } | SessionKeyRejectedP { sessionKeyRejectedP :: Required 15 (Message PublicKeyP) } + | ChatMessageP + { chatMessageSenderName :: Required 16 (Value B.ByteString) + , chatMessage :: Required 17 (Value B.ByteString) + } deriving (Generic) data SignatureP @@ -166,6 +173,10 @@ instance ProtocolBuffer ControlActionP T.ControlAction where { sessionKeyAcceptedP = putField $ toProtocolBuffer t } toProtocolBuffer (T.SessionKeyRejected t) = SessionKeyRejectedP { sessionKeyRejectedP = putField $ toProtocolBuffer t } + toProtocolBuffer (T.ChatMessage sendername t) = ChatMessageP + { chatMessageSenderName = putField (val sendername) + , chatMessage = putField (val t) + } fromProtocolBuffer p@(RejectedP {}) = T.Rejected $ fromProtocolBuffer $ getField $ rejectedP p fromProtocolBuffer p@(SessionKeyP {}) = T.SessionKey $ @@ -174,6 +185,9 @@ instance ProtocolBuffer ControlActionP T.ControlAction where fromProtocolBuffer $ getField $ sessionKeyAcceptedP p fromProtocolBuffer p@(SessionKeyRejectedP {}) = T.SessionKeyRejected $ fromProtocolBuffer $ getField $ sessionKeyRejectedP p + fromProtocolBuffer p@(ChatMessageP {}) = T.ChatMessage + (Val $ getField $ chatMessageSenderName p) + (Val $ getField $ chatMessage p) instance ProtocolBuffer SignatureP T.Signature where toProtocolBuffer (T.Ed25519Signature t) = Ed25519SignatureP |