diff --git a/protocol/connections/engine.go b/protocol/connections/engine.go index 3eef1bc..3762e2b 100644 --- a/protocol/connections/engine.go +++ b/protocol/connections/engine.go @@ -561,11 +561,14 @@ func (e *engine) handlePeerMessage(hostname string, eventID string, context stri e.eventManager.Publish(event.NewEvent(event.ManifestReceived, map[event.Field]string{event.Handle: hostname, event.FileKey: fileKey, event.SerializedManifest: manifest})) } } else if context == event.ContextRequestFile { - for _, message := range e.filesharingSubSystem.ProcessChunkRequest(eventID, message) { - if err := e.sendPeerMessage(hostname, message); err != nil { - e.eventManager.Publish(event.NewEvent(event.SendMessageToPeerError, map[event.Field]string{event.RemotePeer: hostname, event.EventID: eventID, event.Error: err.Error()})) + chunks := e.filesharingSubSystem.ProcessChunkRequest(eventID, message) + go func() { + for _, message := range chunks { + if err := e.sendPeerMessage(hostname, message); err != nil { + e.eventManager.Publish(event.NewEvent(event.SendMessageToPeerError, map[event.Field]string{event.RemotePeer: hostname, event.EventID: eventID, event.Error: err.Error()})) + } } - } + }() } else if context == event.ContextSendFile { fileKey, progress, totalChunks, _, title := e.filesharingSubSystem.ProcessChunk(eventID, message) if len(fileKey) != 0 {