MCPcopy Index your code
hub / github.com/buildbot/buildbot / send

Method send

www/data-module/src/data/WebSocketClient.ts:61–87  ·  view source on GitHub ↗
(data: any)

Source from the content-addressed store, hash-verified

59 received has the same id
60 */
61 send(data: any) {
62 // add _id to each message
63 const id = this.generateId();
64 data._id = id;
65
66 const promiseData = {} as PromiseData<void>;
67 promiseData.promise = new Promise<void>((resolve, reject) => {
68 promiseData.resolve = resolve;
69 promiseData.reject = reject;
70 });
71 this.promises[id] = promiseData;
72
73 const jsonData = JSON.stringify(data);
74 if (this.socket.readyState === this.socket.OPEN) {
75 this.socket.send(jsonData);
76 } else {
77 // if the WebSocket is not open yet, add the data to the queue
78 this.queue.push(jsonData);
79 }
80 // socket is not watched by cypress, so we need to
81 // create a timeout while we are using the socket so that protractor waits for it
82 const to = setTimeout(() => {}, 20000);
83
84 return promiseData.promise.then(() => {
85 clearTimeout(to);
86 });
87 }
88
89 flush() {
90 // send all the data waiting in the queue

Callers 3

subscribeMethod · 0.95
unsubscribeMethod · 0.95
flushMethod · 0.45

Calls 2

generateIdMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected