@ -315,6 +315,10 @@ func (node *Node) send() {
break
break
}
}
if ! node . verboseOutput {
go node . printTransferInfo ( time . Second )
}
// receive incoming packets and decrypt them if necessary
// receive incoming packets and decrypt them if necessary
incomingPacket , ok := <- node . packetPipe
incomingPacket , ok := <- node . packetPipe
if ! ok {
if ! ok {
@ -395,12 +399,13 @@ func (node *Node) send() {
node . transferInfo . Sending . SentBytes += fileToSend . Size
node . transferInfo . Sending . SentBytes += fileToSend . Size
node . transferInfo . Sending . InTransfer = false
if node . verboseOutput {
if node . verboseOutput {
fmt . Printf ( "\n[File] receiver already has \"%s\"" , fileToSend . Name )
fmt . Printf ( "\n[File] receiver already has \"%s\"" , fileToSend . Name )
}
}
}
}
}
}
}
}
// Transfer section
// Transfer section
@ -411,7 +416,6 @@ func (node *Node) send() {
Header : protocol . HeaderDone ,
Header : protocol . HeaderDone ,
} )
} )
fmt . Printf ( "\nTransfer ended successfully" )
node . stopped = true
node . stopped = true
continue
continue
@ -451,10 +455,6 @@ func (node *Node) send() {
continue
continue
}
}
if ! node . verboseOutput {
go node . printTransferInfo ( time . Second )
}
// if allowed to transfer and the other node is ready to receive packets - send one piece
// if allowed to transfer and the other node is ready to receive packets - send one piece
// and wait for it to be ready again
// and wait for it to be ready again
if node . transferInfo . Sending . AllowedToTransfer && node . transferInfo . Sending . CanSendBytes && node . transferInfo . Sending . InTransfer {
if node . transferInfo . Sending . AllowedToTransfer && node . transferInfo . Sending . CanSendBytes && node . transferInfo . Sending . InTransfer {
@ -544,6 +544,10 @@ func (node *Node) receive() {
break
break
}
}
if ! node . verboseOutput && node . transferInfo . Receiving . ReceivedBytes != 0 {
go node . printTransferInfo ( time . Second )
}
// receive incoming packets and decrypt them if necessary
// receive incoming packets and decrypt them if necessary
incomingPacket , ok := <- node . packetPipe
incomingPacket , ok := <- node . packetPipe
if ! ok {
if ! ok {
@ -718,6 +722,13 @@ func (node *Node) receive() {
node . mutex . Lock ( )
node . mutex . Lock ( )
node . transferInfo . Receiving . AcceptedFiles = append ( node . transferInfo . Receiving . AcceptedFiles , file )
node . transferInfo . Receiving . AcceptedFiles = append ( node . transferInfo . Receiving . AcceptedFiles , file )
node . mutex . Unlock ( )
node . mutex . Unlock ( )
err = protocol . SendPacket ( node . netInfo . Conn , protocol . Packet {
Header : protocol . HeaderReady ,
} )
if err != nil {
panic ( err )
}
}
}
existingFileHandler . Close ( )
existingFileHandler . Close ( )
@ -727,13 +738,13 @@ func (node *Node) receive() {
node . mutex . Lock ( )
node . mutex . Lock ( )
node . transferInfo . Receiving . AcceptedFiles = append ( node . transferInfo . Receiving . AcceptedFiles , file )
node . transferInfo . Receiving . AcceptedFiles = append ( node . transferInfo . Receiving . AcceptedFiles , file )
node . mutex . Unlock ( )
node . mutex . Unlock ( )
}
err = protocol . SendPacket ( node . netInfo . Conn , protocol . Packet {
err = protocol . SendPacket ( node . netInfo . Conn , protocol . Packet {
Header : protocol . HeaderReady ,
Header : protocol . HeaderReady ,
} )
} )
if err != nil {
if err != nil {
panic ( err )
panic ( err )
}
}
}
case protocol . HeaderFileBytes :
case protocol . HeaderFileBytes :
@ -855,10 +866,6 @@ func (node *Node) receive() {
fmt . Printf ( "\n%s disconnected" , node . netInfo . Conn . RemoteAddr ( ) )
fmt . Printf ( "\n%s disconnected" , node . netInfo . Conn . RemoteAddr ( ) )
}
}
if ! node . verboseOutput && node . transferInfo . Receiving . ReceivedBytes != 0 {
go node . printTransferInfo ( time . Second )
}
}
}
}
}