MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / Connect

Method Connect

pkg/waveapp/waveapp.go:161–193  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

159}
160
161func (client *Client) Connect() error {
162 jwtToken := os.Getenv(wshutil.WaveJwtTokenVarName)
163 if jwtToken == "" {
164 return fmt.Errorf("no %s env var set", wshutil.WaveJwtTokenVarName)
165 }
166 rpcCtx, err := wshutil.ExtractUnverifiedRpcContext(jwtToken)
167 if err != nil {
168 return fmt.Errorf("error extracting rpc context from %s: %v", wshutil.WaveJwtTokenVarName, err)
169 }
170 client.RpcContext = rpcCtx
171 if client.RpcContext == nil || client.RpcContext.BlockId == "" {
172 return fmt.Errorf("no block id in rpc context")
173 }
174 client.ServerImpl = &WaveAppServerImpl{BlockId: client.RpcContext.BlockId, Client: client}
175 sockName, err := wshutil.ExtractUnverifiedSocketName(jwtToken)
176 if err != nil {
177 return fmt.Errorf("error extracting socket name from %s: %v", wshutil.WaveJwtTokenVarName, err)
178 }
179 rpcClient, err := wshutil.SetupDomainSocketRpcClient(sockName, client.ServerImpl, "vdomclient")
180 if err != nil {
181 return fmt.Errorf("error setting up domain socket rpc client: %v", err)
182 }
183 client.RpcClient = rpcClient
184 authRtnData, err := wshclient.AuthenticateCommand(client.RpcClient, jwtToken, &wshrpc.RpcOpts{Route: wshutil.ControlRoute})
185 if err != nil {
186 return fmt.Errorf("error authenticating rpc connection: %v", err)
187 }
188 if authRtnData.RouteId == "" {
189 return fmt.Errorf("authentication returned empty routeid")
190 }
191 client.RouteId = authRtnData.RouteId
192 return nil
193}
194
195func (c *Client) SetRootElem(elem *vdom.VDomElem) {
196 c.RootElem = elem

Callers 5

runMainEMethod · 0.95
testBasicConnectFunction · 0.45
testShellWithCommandFunction · 0.45
testWshExecFunction · 0.45
testInteractiveShellFunction · 0.45

Implementers 1

WshRouterpkg/wshutil/wshrouter.go

Calls 4

AuthenticateCommandFunction · 0.92

Tested by

no test coverage detected