Skip to content

Commit

Permalink
Create an AmqpSocketStream with a #flush implementation consistent fo…
Browse files Browse the repository at this point in the history
…r every pharo version
  • Loading branch information
jvanecek committed Aug 10, 2024
1 parent 62b8c7d commit 5601329
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/Ansible-Protocol-Core/AmqpConnection.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ AmqpConnection >> nextFrame [
{ #category : 'opening' }
AmqpConnection >> open [

codec := AmqpCodec on: ( ( ZdcSocketStream on: socket )
codec := AmqpCodec on: ( ( AmqpSocketStream on: socket )
noTimeout;
binary;
yourself ).

Expand Down
22 changes: 22 additions & 0 deletions source/Ansible-Protocol-Core/AmqpSocketStream.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Class {
#name : 'AmqpSocketStream',
#superclass : 'SocketStream',
#category : 'Ansible-Protocol-Core',
#package : 'Ansible-Protocol-Core'
}

{ #category : 'control' }
AmqpSocketStream >> flush [
"If the other end is connected and we have something
to send, then we send it and reset the outBuffer.
If the other end is closed and we are signaling errors, do so."

(outNextToWrite > 1 and: [ socket isOtherEndClosed not ]) ifTrue: [
[ socket sendData: outBuffer count: outNextToWrite - 1 ]
on: NetworkError
do: [ :ex |
shouldSignal
ifTrue: [ ex pass ]
ifFalse: [ "swallow" ] ].
outNextToWrite := 1 ]
]

0 comments on commit 5601329

Please sign in to comment.