Skip to content

Parent <-> child communication design. #1024

@slimshader

Description

@slimshader

Hi,

My case: launcher application that is able to spawn 2 child apps. I want my launcher and child apps be able to talk to each other via json rpc, meaning sending multiple messages back and forth when needed. Based on od cond sampes I implemented it this way:

  1. Launcher creates a server based on InOut NamedPipeServerStream with name "Parent"
  2. Launcher starts child app
  3. child app creates InOut server with generated name
  4. child creates NamedPipeClientStream to "Parent"
  5. child calls remote procedure on parent "ChildReady" with generated name as paramter
  6. Parent creates NPCS with child's name
  7. parent and child send messages to each other via respecitve Client streams
  8. server streams get recreated after each precessed message (via while (true) loops)
            while (true)
            {
                var stream = new NamedPipeServerStream("StreamJsonRpcSamplePipe", PipeDirection.InOut, NamedPipeServerStream.MaxAllowedServerInstances, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);

                await stream.WaitForConnectionAsync();

                var jsonRpc = JsonRpc.Attach(stream, this);

                await jsonRpc.Completion;
            }

is that the way to go for this case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions