Skip to content

Commit

Permalink
Session populates data
Browse files Browse the repository at this point in the history
  • Loading branch information
stricklandrbls committed May 3, 2024
1 parent 3304ac3 commit d7a5703
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/dataEditor/dataEditorClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function activate(ctx: vscode.ExtensionContext): void {
await server.start()
/* Moving on w/ assumption that server is up and running */
const editor = new StandaloneEditor(ctx, configVars)
await editor.initialize(await server.getService())
await editor.initialize(server)
// await server.register(editor.heatbeat)
// return await createDataEditorWebviewPanel(ctx, configVars, fileToEdit)
}
Expand Down
21 changes: 3 additions & 18 deletions src/dataEditor/include/client/dataEditorClient.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
import { IHeartbeatReceiver } from '@omega-edit/client'
import {
HeartbeatInfo,
HeartbeatProcessor,
} from '../server/heartbeat/HeartBeatInfo'
import { ServiceHeartbeat } from '../server/Server'
import { IEditServiceProvider } from '../server/Server'
import { IEditService } from '../service/editorService'
class TestProcessor implements IHeartbeatReceiver {
constructor(
readonly id: string,
public process: (heartbeat: HeartbeatInfo) => void
) {}
}
export abstract class DataEditor {
protected abstract fileToEdit: string
protected editService: IEditService | undefined = undefined
constructor() {}
async initialize(service: IEditService) {
async initialize(provider: IEditServiceProvider) {
await this.getFile()
this.editService = service
service.setup(this.fileToEdit)
// await this.setupService()
this.editService = await provider.getService(this.fileToEdit)
}
protected abstract getFile(): Promise<void>
// protected abstract setupService(): Promise<void>
}
export interface DataEditorUI {
show(): Promise<void>
Expand Down
35 changes: 16 additions & 19 deletions src/dataEditor/include/server/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
// import net from 'net'
import * as fs from 'fs'
import {
IHeartbeatReceiver,
// IHeartbeatReceiver,
IServerHeartbeat,
IServerInfo,
getServerHeartbeat,
getServerHeartbeatFor,
getServerInfo,
pidIsRunning,
startServer,
Expand All @@ -25,8 +24,7 @@ import {
import path from 'path'
import { APP_DATA_PATH } from '../../config'
import assert from 'assert'
import { HeartbeatProcessor, IHeartbeatInfo } from './heartbeat/HeartBeatInfo'
import { OmegaEditService } from '../service/editorService'
import { IEditService, OmegaEditService } from '../service/editorService'

type ServerProcess = {
pidFile: string
Expand All @@ -45,13 +43,10 @@ export class ServiceHeartbeat {
}, this.interval)
}
}
export class ServiceClient {
constructor() {
// createSession()
// createViewport()
}
export interface IEditServiceProvider {
getService(targetFile: string): Promise<IEditService>
}
export class OmegaEditServer {
export class OmegaEditServer implements IEditServiceProvider {
readonly host: string
readonly port: number
private proc: ServerProcess = { pidFile: '', pid: -1 }
Expand Down Expand Up @@ -123,17 +118,19 @@ export class OmegaEditServer {
resolve(true)
})
}
async getService(): Promise<OmegaEditService> {
return new Promise((resolve, reject) => {
resolve(new OmegaEditService())
async getService(targetFile: string): Promise<OmegaEditService> {
return new Promise(async (resolve, reject) => {
let service = new OmegaEditService()
await service.set(targetFile)
resolve(service)
})
}
static createProcessor(
params: Required<IHeartbeatReceiver>
): IHeartbeatReceiver {
// Register Receiver w/ server registry
return params as IHeartbeatReceiver
}
// static createProcessor(
// params: Required<IHeartbeatReceiver>
// ): IHeartbeatReceiver {
// // Register Receiver w/ server registry
// return params as IHeartbeatReceiver
// }
private async verify(): Promise<void> {
return new Promise(async (resolve, reject) => {
for (let i = 1; i <= 10; ++i) {
Expand Down
6 changes: 3 additions & 3 deletions src/dataEditor/include/service/editorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {
getLanguage,

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: ubuntu-20.04, Node: 18, Java: 11)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: ubuntu-20.04, Node: 16, Java: 8)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: ubuntu-20.04, Node: 18, Java: 17)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: ubuntu-20.04, Node: 18, Java: 8)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: ubuntu-20.04, Node: 16, Java: 17)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: ubuntu-20.04, Node: 16, Java: 11)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: macos-12, Node: 18, Java: 11)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: macos-12, Node: 18, Java: 8)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: macos-12, Node: 18, Java: 17)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: macos-12, Node: 16, Java: 11)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: windows-2019, Node: 18, Java: 11)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: windows-2019, Node: 16, Java: 11)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: macos-12, Node: 16, Java: 8)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: windows-2019, Node: 18, Java: 8)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: windows-2019, Node: 18, Java: 17)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: windows-2019, Node: 16, Java: 17)

'getLanguage' is declared but its value is never read.

Check failure on line 5 in src/dataEditor/include/service/editorService.ts

View workflow job for this annotation

GitHub Actions / Build, Test, and Package (OS: macos-12, Node: 16, Java: 17)

'getLanguage' is declared but its value is never read.
CreateSessionResponse,
} from '@omega-edit/client'
import assert from 'assert'

export interface IEditService {
setup(editingFile: string): any
set(editingFile: string): any
}

/* OmegaEditService Implementation */
const SessionMetadata = {
byteOrderMark: '',
changeCount: 0,
Expand All @@ -35,7 +35,7 @@ export class Session {
export class OmegaEditService implements IEditService {
private session: Session | undefined = undefined
constructor() {}
async setup(editingFile: string) {
async set(editingFile: string) {
try {
this.session = new Session(await createSession(editingFile))
} catch {
Expand Down
3 changes: 0 additions & 3 deletions src/dataEditor/standalone/standaloneEditor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as vscode from 'vscode'
import * as editor_config from '../config'
import { DataEditor } from '../include/client/dataEditorClient'
import { IEditService } from '../include/service/editorService'

export class StandaloneEditor extends DataEditor {
protected fileToEdit: string = ''
Expand All @@ -21,6 +20,4 @@ export class StandaloneEditor extends DataEditor {
// await this.setupDataEditor()
}
}

async setupService(): Promise<void> {}
}

0 comments on commit d7a5703

Please sign in to comment.