Skip to content
Snippets Groups Projects
Commit cef5d289 authored by dario's avatar dario
Browse files

implement some more NetProtoShow instances

parent 1f9a9b34
No related branches found
No related tags found
No related merge requests found
......@@ -70,23 +70,36 @@ instance NetSendable TextAttribute where
netProtoShow (AttrFontBold) = fromByteString "B"
netProtoShow (AttrFontItalic) = fromByteString "I"
-- TODO: think about escaping..
instance NetSendable UserName where
netProtoShow :: UserName -> Builder
netProtoShow = fromByteString . fromUserName
-- TODO: hier nur authorId schreiben, client am anfang (in http) ne
-- liste von authorIds geben und neue ggf. broadcasten?
instance NetSendable ChatMessage where
netProtoShow :: ChatMessage -> Builder
netProtoShow = undefined -- TODO
instance NetSendable PadMetaEvent where
netProtoShow :: PadMetaEvent -> Builder
netProtoShow = undefined -- TODO
netProtoShow MetaClientEnter = fromByteString "E:" {- <> TODO -}
netProtoShow MetaClientLeave = fromByteString "L:" {- <> TODO -}
netProtoShow (MetaNickChange aid nick) =
fromByteString "N:" <> netProtoShow aid <> netProtoShow nick
netProtoShow MetaPadSettingsChange = fromByteString "S:" {- <> TODO -}
netProtoShow (MetaAllUsersNotification n) =
fromByteString "B:" <> fromByteString n
netProtoShow MetaPadCreationFinished = fromByteString "F"
instance NetSendable ClientMessage where
netProtoShow :: ClientMessage -> Builder
netProtoShow (CM_TextChange ch) =
fromByteString "E:"
fromByteString "E"
<> netProtoShow ch
netProtoShow (CM_ChatEvent cm) =
fromByteString "C:"
fromByteString "C"
<> netProtoShow cm
netProtoShow (CM_PadMetaEvent pme) =
fromByteString "M:"
fromByteString "M"
<> netProtoShow pme
......@@ -26,7 +26,7 @@ data Pos = Pos { line :: Word64, ch :: Word64 } deriving (Show, Eq)
newtype Len = Len { fromLen :: Word64 } deriving (Show, Eq)
newtype RemoteAddr = RemoteAddr BS.ByteString deriving (Show, Eq)
newtype UserName = UserName BS.ByteString deriving (Show, Eq)
newtype UserName = UserName { fromUserName :: BS.ByteString } deriving (Show, Eq)
-- TODO
......@@ -78,9 +78,12 @@ instance Eq ZonedTime where
data PadMetaEvent = MetaClientEnter {- TODO -}
| MetaClientLeave {- TODO -}
| MetaNickChange {- TODO -}
| MetaNickChange AuthorId UserName
| MetaPadSettingsChange {- TODO -}
| MetaAllUsersNotification {- TODO -}
| MetaAllUsersNotification BS.ByteString
-- the client is supposed to reload upon receiving
-- this notification
| MetaPadCreationFinished
deriving (Show, Eq)
-- this is the grand overarching type for everything that can be sent to
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment