Skip to content
Repos

DevPlaceApp

C++ 880 B26 lines Opens in site

Directory Raw Download

#pragma once
// Spec: shell.md "Sockets" (MessagesSocket protocol). Swift AsyncStream<ChatSocketEvent> becomes an event handler
// invoked on the UI thread. connect/disconnect are idempotent; send* are fire and forget (dropped when not open).
#include <functional>
#include <string>
#include <vector>

#include "model/ChatSocketEvent.hpp"

namespace dp {

class MessagesSocket {
 public:
  using EventHandler = std::function<void(const ChatSocketEvent&)>;

  virtual ~MessagesSocket() = default;
  virtual void setEventHandler(EventHandler handler) = 0;
  virtual void connect() = 0;
  virtual void disconnect() = 0;
  virtual void send(const std::string& content, const std::vector<std::string>& attachmentUids,
                    const std::string& clientId) = 0;
  virtual void sendTyping() = 0;
  virtual void sendRead(const std::string& withUid) = 0;
};

}  // namespace dp
41.9ms