Hi Yaroslav,
no worries, this is a good question. It depends a bit on what kind of logic
you want to trigger. If you just want to do something, you can use
`mapMaterializedValue` to do something with the `OutgoingConnection` object
before materialization is complete.
If you want to prepend some bytes to be output to the connection, you can
do it like this:
Flow[ByteString]
.prepend(Source.single(ByteString("hello connection"))) // or any other
source
.via(Tcp(system).outgoingConnection(???, ???))
More complex behavior can be built e.g. by wrapping the complete connection
flow with a custom GraphStage that would be able to receive all kinds of
signals.
HTH
Johannes
On Thursday, September 15, 2016 at 12:32:02 PM UTC+2, Yaroslav Klymko wrote:
>
> Either my question is silly or there is no easy answer.
>
> On Saturday, September 10, 2016 at 3:57:33 PM UTC+3, Yaroslav Klymko wrote:
>>
>> Hi guys,
>>
>> I'm trying to figure out on how to trigger some logic at the moment TCP
>> connection established, and preferably *before traffic goes*
>> Initial code looks like this:
>>
>>
>> Tcp(system).outgoingConnection(???, ???).join(flow).runWith(source, sink)
>>
>>
>>
>> As far as I can see I need to access Future[OutgoingConnection]
>>
>>
>> val outgoingConnection: Flow[ByteString, ByteString,
>> Future[OutgoingConnection]] = Tcp(system).outgoingConnection(???, ???)
>>
>>
>>
>> So far I came to:
>>
>>
>> val (_, connected: Future[Tcp.OutgoingConnection], _) =
>> Source.fromGraph(source).viaMat(connection)(Keep.both).toMat(sink)(Keep.both).run()
>>
>>
>>
>> Question 1: how to guarantee my code performed before first ByteString
>> came?
>> Question 2: is there better solution
>> Question 3: how to prepend connection as first event in the flow of
>> ByteStrings ?
>>
>>
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.