github.com/whoyao/protocol@v0.0.0-20230519045905-2d8ace718ca5/rpc/egress_client.go (about)

     1  package rpc
     2  
     3  import (
     4  	"github.com/livekit/psrpc"
     5  	"github.com/whoyao/protocol/livekit"
     6  )
     7  
     8  type EgressClient interface {
     9  	EgressInternalClient
    10  	EgressHandlerClient
    11  }
    12  
    13  type egressClient struct {
    14  	EgressInternalClient
    15  	EgressHandlerClient
    16  }
    17  
    18  func NewEgressClient(nodeID livekit.NodeID, bus psrpc.MessageBus) (EgressClient, error) {
    19  	if bus == nil {
    20  		return nil, nil
    21  	}
    22  
    23  	clientID := string(nodeID)
    24  	internalClient, err := NewEgressInternalClient(clientID, bus)
    25  	if err != nil {
    26  		return nil, err
    27  	}
    28  	handlerClient, err := NewEgressHandlerClient(clientID, bus)
    29  	if err != nil {
    30  		return nil, err
    31  	}
    32  	return &egressClient{
    33  		EgressInternalClient: internalClient,
    34  		EgressHandlerClient:  handlerClient,
    35  	}, nil
    36  }