//go:build !tinygo

package rpc

import (
	

	

	am 
	
)

// muxImpl holds the cmux state. It is replaced with an empty struct in TinyGo
// builds, where the mux is not supported.
type muxImpl struct {
	cmux cmux.CMux
}

func newMuxMachine(
	 context.Context,  *Mux,  *MuxOpts,
) (*am.Machine, error) {
	return am.NewCommon(, "rm-"+.Name, states.MuxSchema, ssM.Names(),
		, .Parent, &am.Opts{
			Tags: []string{states.TagRpcMux},
		})
}

func ( *Mux) ( context.Context,  *am.Event) {
	_ = 

	// Create a new cmux instance.
	.cmux = cmux.New(.Listener)

	// fork
	 := .cmux.Match(cmux.Any())
	go .accept(, )

	// start cmux
	if  := .cmux.Serve();  != nil {
		.Mach.AddErr(, nil)
		.Mach.EvRemove1(, ssM.Start, nil)
	}
}