-
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
288 additions
and
179 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2024 TypeFox and others. | ||
* Licensed under the MIT License. See LICENSE in the package root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
|
||
export * from './definitions.js'; | ||
export * from './endpoints/defaultEndpoint.js'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
packages/examples/src/clangd/client/mainRemoteMessageChannelFs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2024 TypeFox and others. | ||
* Licensed under the MIT License. See LICENSE in the package root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
|
||
import { ComChannelEndpoint, RawPayload, WorkerMessage, ComRouter } from 'wtd-core'; | ||
|
||
/** | ||
* Answer the file create request | ||
*/ | ||
export class FileHandlerMain implements ComRouter { | ||
|
||
private endpointFs?: ComChannelEndpoint; | ||
|
||
setComChannelEndpoint(comChannelEndpoint: ComChannelEndpoint): void { | ||
this.endpointFs = comChannelEndpoint; | ||
} | ||
|
||
async fs_driver_init(message: WorkerMessage) { | ||
await this.endpointFs?.sentAnswer({ | ||
message: WorkerMessage.createFromExisting(message, { | ||
overrideCmd: 'fs_driver_init_confirm', | ||
}), | ||
awaitAnswer: false | ||
}); | ||
|
||
// send double confirmation | ||
await this.endpointFs?.sentMessage({ | ||
message: WorkerMessage.fromPayload(new RawPayload({ | ||
hello: 'worker', | ||
}), 'fs_follower_init'), | ||
awaitAnswer: true, | ||
expectedAnswer: 'fs_follower_init_confirm' | ||
}); | ||
} | ||
|
||
async syncFile(message: WorkerMessage) { | ||
const rawPayload = message.payloads[0] as RawPayload; | ||
console.log(rawPayload.message.raw.resourceUri); | ||
|
||
await this.endpointFs?.sentAnswer({ | ||
message: WorkerMessage.createFromExisting(message, { | ||
overrideCmd: 'syncFile_confirm', | ||
overridePayloads: new RawPayload({ | ||
status: 'created', | ||
message: `Created: ${rawPayload.message.raw.resourceUri}` | ||
}) | ||
}) | ||
}); | ||
} | ||
} | ||
|
||
export class MainRemoteMessageChannelFs { | ||
|
||
constructor(port: MessagePort) { | ||
|
||
const fileHandlerMain = new FileHandlerMain(); | ||
const endpointFs = new ComChannelEndpoint({ | ||
endpointId: 21, | ||
endpointName: 'port_main_fs', | ||
endpointConfig: { | ||
$type: 'DirectImplConfig', | ||
impl: port | ||
}, | ||
verbose: true | ||
}); | ||
endpointFs.connect(fileHandlerMain); | ||
} | ||
} |
Oops, something went wrong.