MCPcopy
hub / github.com/livekit/livekit / newAgentClient

Function newAgentClient

test/agent.go:47–67  ·  view source on GitHub ↗
(token string, port uint32)

Source from the content-addressed store, hash-verified

45}
46
47func newAgentClient(token string, port uint32) (*agentClient, error) {
48 host := fmt.Sprintf("ws://localhost:%d", port)
49 u, err := url.Parse(host + "/agent")
50 if err != nil {
51 return nil, err
52 }
53 requestHeader := make(http.Header)
54 requestHeader.Set("Authorization", "Bearer "+token)
55
56 connectUrl := u.String()
57 conn, _, err := websocket.DefaultDialer.Dial(connectUrl, requestHeader)
58 if err != nil {
59 return nil, err
60 }
61
62 return &agentClient{
63 conn: conn,
64 requestedJobs: make(chan *livekit.Job, 100),
65 done: make(chan struct{}),
66 }, nil
67}
68
69func (c *agentClient) Run(jobType livekit.JobType, namespace string) (err error) {
70 go c.read()

Callers 3

TestAgentsFunction · 0.85
TestAgentNamespacesFunction · 0.85
TestAgentMultiNodeFunction · 0.85

Calls 2

ParseMethod · 0.45
StringMethod · 0.45

Tested by 3

TestAgentsFunction · 0.68
TestAgentNamespacesFunction · 0.68
TestAgentMultiNodeFunction · 0.68