# Simple Event Mechanism ## Considered Technologies - WebSockets - Webhooks ### WebSockets WebSockets provide a full-duplex communication channel between a client and a server. This means that both the client and server can send data to each other simultaneously. It enables real-time, bi-directional communication, making it suitable for applications that require continuous data exchange. Use cases for WebSockets: - Real-time applications: WebSockets are ideal for applications that demand real-time updates, such as chat applications, collaborative tools, multiplayer games, stock market tickers, and live sports scoreboards. - Live data streaming: If you need to continuously stream data from a server to a client, like streaming financial data or social media feeds, WebSockets can efficiently handle this type of streaming. - Notifications and alerts: WebSockets can be used to push notifications and alerts from a server to a client in real time, ensuring immediate delivery of time-sensitive information. ### Webhooks Webhooks are a way for web applications to provide real-time data to other applications by sending HTTP POST requests to a specified URL (known as the webhook endpoint) whenever a particular event occurs. The receiving application (webhook consumer) can then process the data. Use cases for Webhooks: - Integration with third-party services: Webhooks are commonly used for integrating web applications with external services or APIs. For example, you can set up a webhook to receive notifications when a new order is placed on an e-commerce platform or when a user subscribes to your service. - Event-driven workflows: Webhooks enable event-driven architectures, where certain actions or events trigger subsequent actions in different systems. For instance, a form submission on a website can trigger a webhook that sends the form data to a CRM system for lead management. - Web data synchronization: Webhooks can be used to keep data in sync between different systems. For example, when data is updated in one system, a webhook can be triggered to notify other systems to update their corresponding data. ## Summary In summary, WebSockets are suitable for real-time, bi-directional communication, while webhooks are effective for event-driven notifications and data transfer between systems. ## Sequence Diagram ```mermaid sequenceDiagram box Green Agent participant Wallet participant Publisher end box DarkBlue Application participant Subscriber participant Controller end Wallet->>+Publisher: EventTriggered Publisher->>+Subscriber: WS Deliver Subscriber->>+Controller: Dispatch Controller -->>- Controller: Handle ```