aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2021-05-16 14:01:15 +0200
committerTom Smeding <tom@tomsmeding.com>2021-05-16 14:01:15 +0200
commit7d0797d622d1165c06a1d41df6943c8daefa8102 (patch)
tree4b4224295e77aa9b544187302875f7087a764920
parente8b87640c32706719658a9d047c7295065f681a9 (diff)
WIP doesn't build but was in stashhaskell-mock
-rw-r--r--mock/Server.hs31
-rw-r--r--mock/Util.hs8
2 files changed, 18 insertions, 21 deletions
diff --git a/mock/Server.hs b/mock/Server.hs
index b4dea2c..1fd2b97 100644
--- a/mock/Server.hs
+++ b/mock/Server.hs
@@ -17,33 +17,22 @@ import Types
import Util
--- | Message from the client gate to the server process. The response of the
--- server is written to the MVar.
-data ServerIn = ServerIn ServerIn' (TMVar [ServerOut])
-
-data ServerIn'
- = IAnon Cmd
- | IAs User Cmd
+newtype ConnId = ConnId Int
deriving (Show)
-data ServerOut
- = OResponse Response
- | OLogin User
- | OLogout
- | ODisconnect
- | OBroadcast BroadcastAudience Push -- ^ Will not broadcast to the sender of the ServerIn
+data ServerIn
+ = IOpen ConnId
+ | IClose ConnId
+ | ICmd ConnId Cmd
deriving (Show)
-data BroadcastAudience
- = AudUser User -- ^ All sessions of the user
- | AudRoom Room -- ^ All sessions of all users in the room
- | AudVisibleUsers User -- ^ All sessions of all users in all rooms that this user is in
+data ServerOutAction
+ = OClose ConnId
+ | OResponse ConnId Response
+ | OPush ConnId Push
deriving (Show)
-data ClientAction
- = CAResponse Response
- | CAPush Push
- | CADisconnect
+newtype ServerOut = ServerOut [ServerOutAction]
deriving (Show)
data ClientState
diff --git a/mock/Util.hs b/mock/Util.hs
new file mode 100644
index 0000000..be12f56
--- /dev/null
+++ b/mock/Util.hs
@@ -0,0 +1,8 @@
+module Util where
+
+
+newtype Opaque a = Opaque { unOpaque :: a }
+ deriving (Eq, Ord)
+
+instance Show (Opaque a) where
+ show _ = "Opaque"