From 7fe9b3ed4c4a6b2c3c5ae1fcc5ece20c610f1a48 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Thu, 17 Dec 2020 16:47:38 -0800 Subject: [PATCH] Clarified JoinServer opening n times This commit clarifies that JoinServer must only be opened by one container. In other words, before it is called again, the stop callback of the last call must be called beforehand. This applies per messenger. --- cchat.go | 7 +++++++ repository/gob/repository.gob | Bin 37352 -> 37351 bytes repository/main.go | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/cchat.go b/cchat.go index efc44ee..1b74fbf 100644 --- a/cchat.go +++ b/cchat.go @@ -577,6 +577,13 @@ type MessagesContainer interface { type Messenger interface { // JoinServer joins a server that's capable of receiving messages. The server // may not necessarily support sending messages. + // + // Frontends must never call JoinServer on the same server more than twice + // without calling the stop function first. This is the best of both worlds, as + // it greatly reduces complexity on both sides in most cases, therefore the + // backend can safely assume that there will only ever be one active JoinServer. + // If the frontend wishes to do this, it must keep its own shared message + // buffer. JoinServer(context.Context, MessagesContainer) (stop func(), err error) // Asserters. diff --git a/repository/gob/repository.gob b/repository/gob/repository.gob index b23a7516a5cef9eacbb32a573c94f038e5184a3b..5fe1e10f14a677c31c0e82d334a4b56c6608160a 100644 GIT binary patch delta 76 zcmV-S0JHz-qXOrn0R? i9+N>Y9h(qXOuo0nrli?E|v#12v29xazSF>>pxDcYP9bf