0

In Akka.Net can we derive TcpStream actor from Tcp actor ?

I created a Tcp actor using

Context.System.Tcp().Tell(new IoTcp.Connect(endPoint));

Then I register my self as the handler

Sender.Tell(new IoTcp.Register(Self, true, true));

The endpoint represent a plain remote Tcp socket and not a Tcp Stream actor.

Then I subscribe to Received message

private void OnReceived(IoTcp.Received message)
{
    // pass message.Data to a flow to materialize
}

How can consume the Received message as a stream via a Flow that will define a custom framing logic ?

Can I create the connection using

var connection = Context.System.TcpStream().OutgoingConnection("",0);
Alex David
  • 585
  • 1
  • 11
  • 32
  • I might be missing something, but your case seems to exactly match one described in the docs: https://getakka.net/articles/streams/workingwithstreamingio.html – Bartosz Sypytkowski Apr 07 '21 at 06:45
  • @BartoszSypytkowski I did go through that link earlier. But when I create a TcpStream, I'm not able to receive Tcp.Connected message. – Alex David Apr 07 '21 at 12:21
  • When you're creating a `System.TcpStream().Bind("127.0.0.1", 8888)`, every emitted event is a newly accepted connection (equivalent of `Connected` message), which you can handle however you like. On client side if you're using streams, you can use `OutgoingConnection` together with [Source.Queue](https://getakka.net/api/Akka.Streams.Dsl.Source.html#Akka_Streams_Dsl_Source_Queue__1_System_Int32_Akka_Streams_OverflowStrategy_) which can be watched for completion and internal failures. – Bartosz Sypytkowski Apr 08 '21 at 10:51
  • @BartoszSypytkowski Started a duscussion at https://github.com/akkadotnet/akka.net/discussions/4932 – Alex David Apr 11 '21 at 06:43

0 Answers0