mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
bdec751725
* protocol instance template [WIP] * protocol instances template * add methods to check correctness of participant types in protocol TH * PushConfirm and and PushMsg implementation types * check Command type + doctest
48 lines
1.6 KiB
Haskell
48 lines
1.6 KiB
Haskell
{-# OPTIONS_GHC -fno-warn-unticked-promoted-constructors #-}
|
|
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
|
-- {-# OPTIONS_GHC -ddump-splices #-}
|
|
{-# LANGUAGE AllowAmbiguousTypes #-}
|
|
{-# LANGUAGE DataKinds #-}
|
|
{-# LANGUAGE FlexibleContexts #-}
|
|
{-# LANGUAGE FlexibleInstances #-}
|
|
{-# LANGUAGE GADTs #-}
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
{-# LANGUAGE TypeOperators #-}
|
|
|
|
module Simplex.Messaging.Broker where
|
|
|
|
import ClassyPrelude
|
|
import Simplex.Messaging.Protocol
|
|
import Simplex.Messaging.Types
|
|
|
|
$(protocol Broker [d|
|
|
bcCreateConn = CreateConn <-- Recipient
|
|
bcSubscribe = Subscribe <-- Recipient
|
|
baPushConfirm = PushConfirm --> Recipient
|
|
baPushMsg = PushMsg --> Recipient
|
|
|])
|
|
|
|
|
|
bcCreateConn :: Connection Broker None Idle
|
|
-> CreateConnRequest
|
|
-> Either String (CreateConnResponse, Connection Broker New Idle)
|
|
bcCreateConn = protoCmdStub
|
|
|
|
bcSubscribe :: Connection Broker s Idle
|
|
-> ()
|
|
-> Either String ((), Connection Broker s Subscribed)
|
|
bcSubscribe = protoCmdStub
|
|
|
|
baPushConfirm :: Connection Broker New Subscribed
|
|
-> SecureConnRequest
|
|
-> Either String ()
|
|
-> Either String (Connection Broker New Subscribed)
|
|
baPushConfirm = protoActionStub
|
|
|
|
baPushMsg :: Connection Broker Secured Subscribed
|
|
-> MessagesResponse -- TODO, has to be a single message
|
|
-> Either String ()
|
|
-> Either String (Connection Broker Secured Subscribed)
|
|
baPushMsg = protoActionStub
|