Thanks for the hint Yann!

I think I'm starting to get an idea of how to solve this. 

On Saturday, April 25, 2015 at 10:15:41 AM UTC+2, Yann Simon wrote:
>
> Disclaimer: I'm a newbie in akka-stream myself.
> I'd try to integrate an akka actor in the flow: 
> http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-RC1/scala/stream-integrations.html
>
> The logic to answer or not to a message would be inside the actor.
>
> Le ven. 24 avr. 2015 à 11:38, Jonas Adler <[email protected] <javascript:>> 
> a écrit :
>
>> Hi,
>>
>> we're evaluating akka-stream for the usage in a future project of ours. 
>> The IRC client spec (https://tools.ietf.org/html/rfc2812) is somewhat 
>> comparable to what we will need to be able to do in our real project. I'm 
>> struggling with the design of a graph in which the source has to emit 
>> outbound messages on certain inbound messages from the sink. 
>>
>> The goal is to provide an API that look something like this:
>>
>> def join(network: String, port: Int, channels: Seq[String]): Source[
>> ChannelMessage, ...]
>>
>> where the ChannelMessages that this source emits are messages sent in the 
>> specified channels.
>>
>> This is my very simple implementation, but it's enough to send and 
>> receive messages to an IRC network:
>>
>> import java.net.InetSocketAddress
>> import akka.actor.ActorSystem
>> import akka.stream.ActorFlowMaterializer
>> import akka.stream.scaladsl.{BidiFlow, Source, StreamTcp}
>> import akka.util.ByteString
>>
>> object ReactiveIRC extends App {
>>
>>   implicit val system = ActorSystem("reactive-irc")
>>   implicit val materializer = ActorFlowMaterializer()
>>
>>   val connection = StreamTcp().outgoingConnection(new InetSocketAddress("
>> irc.freenode.net", 6666))
>>
>>   val convertToByteString = (s: String) => ByteString(s)
>>   val convertToString = (b: ByteString) => b.utf8String
>>
>>   val codec = BidiFlow(convertToByteString, 
>> convertToString).join(connection)
>>
>>   Source(() => scala.io.Source.stdin.getLines()).map(_ + 
>> "\r\n").via(codec).runForeach { s =>
>>     println(s"response: $s")
>>   }
>>
>> }
>>
>> The messages needed to join the #akka channel on freenode are:
>>
>> PASS foobar
>> NICK reactive-tester
>> USER guest 0 * :Reactive Tester
>> JOIN #akka
>>
>> Now on to my problem:
>>
>> I need to handle the messages from the IRC network in the following way: 
>>
>> * There are messages the Source needs to answer to (e.g. the responses to 
>> the message above and PING messages)
>> * There are the messages that I want to sent to the user of the API (user 
>> messages in a Channel: something like Source[ChannelMessage,...])
>>
>> So what I am looking for is a cyclic graph with the ability to 'pipe' 
>> certain messages in to another Source.
>>
>> I thought I could use an ActorPublisher as a Source that would initiate 
>> the connection by sending the commands above on start, but I have no Idea 
>> how to reference it on the inbound side of the flow in order to pass the 
>> responses and PING messages to it.
>>
>> Could anyone give me a hint on how to solve problems like this?
>>
>> Thanks in advance!
>>
>> Jonas 
>>
>>  -- 
>> >>>>>>>>>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
>>>>>>>>>>      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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to