Skip to content
Snippets Groups Projects
Commit 28e41603 authored by Jens Nolte's avatar Jens Nolte
Browse files

Store high-level protocol wrappers (Up/Down) in Object

parent 01389117
No related branches found
No related tags found
No related merge requests found
...@@ -242,7 +242,7 @@ class IsInterfaceSide s i => IsInterfaceHandler s i a where ...@@ -242,7 +242,7 @@ class IsInterfaceSide s i => IsInterfaceHandler s i a where
-- | Data kind -- | Data kind
data Side = Client | Server data Side = Client | Server
data Object s i = IsInterfaceSide s i => Object (ProtocolHandle s) GenericObjectId (WireCallback s i) data Object s i = IsInterfaceSide s i => Object (ProtocolHandle s) GenericObjectId (Up s i) (Down s i) (WireCallback s i)
instance IsInterface i => Show (Object s i) where instance IsInterface i => Show (Object s i) where
show = showObject show = showObject
...@@ -258,7 +258,7 @@ class IsObjectSide a where ...@@ -258,7 +258,7 @@ class IsObjectSide a where
describeDownMessage :: a -> Opcode -> BSL.ByteString -> String describeDownMessage :: a -> Opcode -> BSL.ByteString -> String
instance forall s i. IsInterface i => IsObject (Object s i) where instance forall s i. IsInterface i => IsObject (Object s i) where
objectId (Object _ oId _) = oId objectId (Object _ oId _ _ _) = oId
objectInterfaceName _ = interfaceName @i objectInterfaceName _ = interfaceName @i
instance forall s i. IsInterfaceSide s i => IsObjectSide (Object s i) where instance forall s i. IsInterfaceSide s i => IsObjectSide (Object s i) where
...@@ -452,7 +452,7 @@ initializeProtocol wlDisplayWireCallback initializationAction = do ...@@ -452,7 +452,7 @@ initializeProtocol wlDisplayWireCallback initializationAction = do
} }
writeTVar stateVar (Right state) writeTVar stateVar (Right state)
let wlDisplay = Object protocol wlDisplayId wlDisplayWireCallback let wlDisplay = Object protocol wlDisplayId undefined undefined wlDisplayWireCallback
modifyTVar' objectsVar (HM.insert wlDisplayId (SomeObject wlDisplay)) modifyTVar' objectsVar (HM.insert wlDisplayId (SomeObject wlDisplay))
result <- runReaderT (initializationAction wlDisplay) state result <- runReaderT (initializationAction wlDisplay) state
...@@ -546,7 +546,7 @@ newObjectFromId (NewId oId) callback = do ...@@ -546,7 +546,7 @@ newObjectFromId (NewId oId) callback = do
protocol <- askProtocol protocol <- askProtocol
let let
genericObjectId = toGenericObjectId oId genericObjectId = toGenericObjectId oId
object = Object protocol genericObjectId callback object = Object protocol genericObjectId undefined undefined callback
someObject = SomeObject object someObject = SomeObject object
modifyProtocolVar (.objectsVar) (HM.insert genericObjectId someObject) modifyProtocolVar (.objectsVar) (HM.insert genericObjectId someObject)
pure object pure object
...@@ -606,7 +606,7 @@ getMessageAction ...@@ -606,7 +606,7 @@ getMessageAction
=> Object s i => Object s i
-> Opcode -> Opcode
-> Get (ProtocolM s ()) -> Get (ProtocolM s ())
getMessageAction object@(Object _ _ objectHandler) opcode = do getMessageAction object@(Object _ _ _ _ objectHandler) opcode = do
verifyMessage <- getWireDown object opcode verifyMessage <- getWireDown object opcode
pure $ handleMessage objectHandler object =<< verifyMessage pure $ handleMessage objectHandler object =<< verifyMessage
......
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