@@ -25,6 +25,7 @@ import userAgentParser from "ua-parser-js";
25
25
import { delay } from "../utils/delay" ;
26
26
import * as TypesGen from "./typesGenerated" ;
27
27
import type { PostWorkspaceUsageRequest } from "./typesGenerated" ;
28
+ import { OneWayWebSocket } from "utils/OneWayWebSocket" ;
28
29
29
30
const getMissingParameters = (
30
31
oldBuildParameters : TypesGen . WorkspaceBuildParameter [ ] ,
@@ -101,26 +102,22 @@ const getMissingParameters = (
101
102
} ;
102
103
103
104
/**
104
- *
105
105
* @param agentId
106
- * @returns An EventSource that emits agent metadata event objects
107
- * (ServerSentEvent)
106
+ * @returns A one-way WebSocket that receives agent metadata events
108
107
*/
109
- export const watchAgentMetadata = ( agentId : string ) : EventSource => {
110
- return new EventSource (
108
+ export const watchAgentMetadata = ( agentId : string ) : OneWayWebSocket => {
109
+ return new OneWayWebSocket (
111
110
`${ location . protocol } //${ location . host } /api/v2/workspaceagents/${ agentId } /watch-metadata` ,
112
- { withCredentials : true } ,
113
111
) ;
114
112
} ;
115
113
116
114
/**
117
- * @returns { EventSource } An EventSource that emits workspace event objects
118
- * (ServerSentEvent)
115
+ * @param workspaceId
116
+ * @returns A one-way WebSocket that receives workspace events
119
117
*/
120
- export const watchWorkspace = ( workspaceId : string ) : EventSource => {
121
- return new EventSource (
118
+ export const watchWorkspace = ( workspaceId : string ) : OneWayWebSocket => {
119
+ return new OneWayWebSocket (
122
120
`${ location . protocol } //${ location . host } /api/v2/workspaces/${ workspaceId } /watch` ,
123
- { withCredentials : true } ,
124
121
) ;
125
122
} ;
126
123
0 commit comments