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.
This commit is contained in:
diamondburned 2020-12-17 16:47:38 -08:00
parent fd8106eaf1
commit 7fe9b3ed4c
3 changed files with 16 additions and 0 deletions

View File

@ -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.

Binary file not shown.

View File

@ -1019,6 +1019,15 @@ var Main = Packages{
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.
`},
Name: "JoinServer",
},