---
# System prepended metadata

title: Untitled

---

```haskell=
type PeerId = string

data Member:
  peer_id: PeerId
  relay_id: PeerId

service Chat:
  get_members(chat_id: string) -> []Member
  persist_message(chat_id: string, message: string, author: PeerId)

service ChatSubscriber:
  notify: string, string -> ()

func sendMessage(node: PeerId, chat_id: string, message: string, log: string -> ()):
  on node:
    Chat(node)
    members <- Chat.get_members(chat_id)
    for m <- members par:
      on m.peer_id via m.relay:
        ChatSubscriber(m.peer_id)
        ChatSubscriber.notify(chat_id, message)
    co log("Notified all chat members")
    Chat.persist_message(chat_id, message, %init_peer_id%)
    co log("Message saved")
```
