mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-19 15:44:28 +01:00
fixed bug in golang channel handling (json-rpc mode)
* golang channels are meant to be 1:1 channels, so if multiple goroutines listen on the same channel for messages, only one will receive the message and the others are not, which lead to lost messages. In order to fix that, we create a dedicated golang channel for every websocket connection. see #451
This commit is contained in:
@@ -390,7 +390,7 @@ func (a *Api) SendV2(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (a *Api) handleSignalReceive(ws *websocket.Conn, number string, stop chan struct{}) {
|
||||
receiveChannel, err := a.signalClient.GetReceiveChannel()
|
||||
receiveChannel, channelUuid, err := a.signalClient.GetReceiveChannel()
|
||||
if err != nil {
|
||||
log.Error("Couldn't get receive channel: ", err.Error())
|
||||
return
|
||||
@@ -399,6 +399,7 @@ func (a *Api) handleSignalReceive(ws *websocket.Conn, number string, stop chan s
|
||||
for {
|
||||
select {
|
||||
case <-stop:
|
||||
a.signalClient.RemoveReceiveChannel(channelUuid)
|
||||
ws.Close()
|
||||
return
|
||||
case msg := <-receiveChannel:
|
||||
|
||||
Reference in New Issue
Block a user