Skip to content

Commit

Permalink
Messages passing via socket from app to da
Browse files Browse the repository at this point in the history
  • Loading branch information
robmoffat committed Mar 16, 2024
1 parent a572bbf commit beb6406
Show file tree
Hide file tree
Showing 100 changed files with 15,325 additions and 515 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ The project is divided into several different yarn workspaces:
- `common` : Common APIs and functionality used by both `client` and `server`
- `demo` : A bare-bones desktop agent implementation with a few apps that use WebFDC3
- `fdc3-web-demo` : A bare-bones desktop agent implementation with a few apps that use WebFDC3. See: https://static.swimlanes.io/6bb69f2c9acdc0656f5f3b098d40518e.png for how this works. Basically, the implementation here is that it uses iframes approach and a server-side websocket to relay messages.
- `fdc3-workbench`: The FDC3 Workbench app from https://github.com/FDC3/toolbox/workbench, ported to use WebFDC3.
## Configuring the client
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/messaging/message-port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export async function messagePortInit(mp: MessagePort, data: APIResponseMessage)
const is = new DefaultIntentSupport(messaging, new DesktopAgentIntentResolver(messaging))
const as = new DefaultAppSupport(messaging, data.appIdentifier, "WebFDC3")
const da = new BasicDesktopAgent(hs, cs, is, as, version)
await da.connect()
return da
}

Expand Down
22 changes: 11 additions & 11 deletions packages/da-server/src/supply/post-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import { APIResponseMessage, AppChecker, DesktopAgentDetailResolver, Supplier, F
* Called by the server-side desktop agent.
*/
export const supply: Supplier = (
checker: AppChecker,
detailsResolver: DesktopAgentDetailResolver,
checker: AppChecker,
detailsResolver: DesktopAgentDetailResolver,
portResolver: DesktopAgentPortResolver = () => null) => {

function createResponseMessage(source: Window, appId: AppIdentifier): APIResponseMessage {
return {
provider: "string",
authRequired: true,
authToken: "secret",
desktopAgentBridgeVersion: "demo",
supportedFDC3Versions: [ '2.0'],
fdc3Version: "2.0",
//provider: "string",
//authRequired: true,
//authToken: "secret",
//desktopAgentBridgeVersion: "demo",
//supportedFDC3Versions: [ '2.0'],
//fdc3Version: "2.0",
type: FDC3_API_RESPONSE_MESSAGE_TYPE,
...detailsResolver(source, appId),

Expand All @@ -34,7 +34,7 @@ export const supply: Supplier = (
function createTransferrableArray(source: Window, appId: AppIdentifier): Transferable[] {
const port = portResolver(source, appId);
if (port) {
return [ port ]
return [port]
} else {
return []
}
Expand All @@ -51,7 +51,7 @@ export const supply: Supplier = (
const appDetails = checker(source)
if (appDetails) {
console.log(`API Request Origin: ${origin}`);
const message = createResponseMessage(source,appDetails)
const message = createResponseMessage(source, appDetails)
const transferrables = createTransferrableArray(source, appDetails)
source.postMessage(message, {
targetOrigin: origin,
Expand Down
1 change: 0 additions & 1 deletion packages/demo/.env

This file was deleted.

4 changes: 0 additions & 4 deletions packages/demo/broken/constants.ts

This file was deleted.

21 changes: 0 additions & 21 deletions packages/demo/broken/embed.ts

This file was deleted.

94 changes: 0 additions & 94 deletions packages/demo/broken/server/SimpleServer.ts.leg

This file was deleted.

21 changes: 0 additions & 21 deletions packages/demo/broken/server/index copy.ts

This file was deleted.

21 changes: 0 additions & 21 deletions packages/demo/broken/server/index.ts

This file was deleted.

36 changes: 0 additions & 36 deletions packages/demo/package.json

This file was deleted.

12 changes: 0 additions & 12 deletions packages/demo/src/index.ts

This file was deleted.

27 changes: 0 additions & 27 deletions packages/demo/tsconfig.json

This file was deleted.

22 changes: 11 additions & 11 deletions packages/fdc3-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ export { exchange, exchangePostMessage, exchangeForMessagePort }
export type AppChecker = (o: Window) => AppIdentifier | undefined;

export type Supplier = (
checker: AppChecker,
detailsResolver: DesktopAgentDetailResolver,
checker: AppChecker,
detailsResolver: DesktopAgentDetailResolver,
portResolver?: DesktopAgentPortResolver) => void;

export type Loader = (options: Options) => Promise<DesktopAgent>
export type Loader = (options: Options) => Promise<DesktopAgent>

/**
* These are details such as login information sent from the desktop back to the
* app in order to initialise the api.
*/
export type DesktopAgentDetails = { [key: string] : string | number | boolean }
export type DesktopAgentDetails = { [key: string]: string | number | boolean }

/**
* Use these to return details specific to the window/app needing a connection
Expand All @@ -49,16 +49,16 @@ export type APIResponseMessage = {
method: "message-port",
uri?: string, /* Supplied when an embedded iframe should be loaded */
appIdentifier: AppIdentifier,
fdc3Version: string,
supportedFDC3Versions: string[],
desktopAgentBridgeVersion: string,
authRequired: boolean,
provider: string,
authToken?: string,
// fdc3Version: string,
// supportedFDC3Versions: string[],
// desktopAgentBridgeVersion: string,
// authRequired: boolean,
// provider: string,
// authToken?: string,
}

export type APIRequestMessage = {
type: string,
type: string,
methods: string[]
}

Expand Down
13 changes: 0 additions & 13 deletions packages/fdc3-web-demo/index.html

This file was deleted.

10 changes: 10 additions & 0 deletions packages/fdc3-web-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@
"vite": "^5.0.2"
},
"dependencies": {
"@finos/fdc3": "^2.1.0-beta.4",
"@types/uuid": "^9.0.8",
"@types/ws": "^8.5.10",
"client": "workspace:*",
"da-proxy": "workspace:*",
"da-server": "workspace:*",
"express": "^4.18.3",
"fdc3-common": "workspace:*",
"socket.io": "^4.7.5",
"socket.io-client": "^4.7.5",
"tsx": "^4.5.0",
"typescript": "^5.3.2",
"uuid": "^9.0.1",
"vite-express": "^0.15.0"
}
}
1 change: 0 additions & 1 deletion packages/fdc3-web-demo/public/vite.svg

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit beb6406

Please sign in to comment.