Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Improvments and changed message, that will be returned.
  • Loading branch information
arne-fuchs authored Sep 13, 2021
1 parent 27c9234 commit 3c3d578
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func run(_ *node.Plugin) {
notifyNewMsg := events.NewClosure(func(messageID tangle.MessageID) {
messagelayer.Tangle().Storage.Message(messageID).Consume(func(message *tangle.Message) {
go func() {
server.Broadcast(message.Bytes())
server.Broadcast([]byte(message.String()))
}()
})
})
Expand Down
11 changes: 6 additions & 5 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ func Broadcast(data []byte) {

idx := int(index.Load())
for i := 0; i < idx; i++ {
if connectionList[i].active {
if _, err := connectionList[i].bufferedConn.Write(data); err != nil {
connectionList[i].log.LogInfof("Error writing on connection: %s", err)
connectionList[i].active = false
}
if !connectionList[i].active {
continue
}
if _, err := connectionList[i].bufferedConn.Write(data); err != nil {
connectionList[i].log.LogInfof("Error writing on connection: %s", err)
connectionList[i].active = false
}
}
//Tidy up array of unused connections
Expand Down

0 comments on commit 3c3d578

Please sign in to comment.