module Sound.Sc3.Server.Command.Completion where
import Sound.Osc.Core
import qualified Sound.Sc3.Server.Command.Enum as Server.Command.Enum
with_completion_packet :: Message -> PacketOf Message -> Message
with_completion_packet :: Message -> PacketOf Message -> Message
with_completion_packet (Message Address_Pattern
c [Datum]
xs) PacketOf Message
cm =
if Address_Pattern
c Address_Pattern -> [Address_Pattern] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Address_Pattern]
Server.Command.Enum.async_cmds
then
let xs' :: [Datum]
xs' = [Datum]
xs [Datum] -> [Datum] -> [Datum]
forall a. [a] -> [a] -> [a]
++ [Blob -> Datum
Blob (PacketOf Message -> Blob
encodePacket PacketOf Message
cm)]
in Address_Pattern -> [Datum] -> Message
Message Address_Pattern
c [Datum]
xs'
else Address_Pattern -> Message
forall a. HasCallStack => Address_Pattern -> a
error (Address_Pattern
"with_completion_packet: not async: " Address_Pattern -> Address_Pattern -> Address_Pattern
forall a. [a] -> [a] -> [a]
++ Address_Pattern
c)
withCm :: Message -> Message -> Message
withCm :: Message -> Message -> Message
withCm Message
m Message
cm = Message -> PacketOf Message -> Message
with_completion_packet Message
m (Message -> PacketOf Message
forall t. Message -> PacketOf t
Packet_Message Message
cm)