Skip to content

Commit

Permalink
added disconnect logic
Browse files Browse the repository at this point in the history
  • Loading branch information
robmoffat committed Apr 17, 2024
1 parent 90f7738 commit 434b4f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ The project is divided into several different yarn workspaces:
- `common` : Common APIs and functionality used by both `client` and `server`
- `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.
- `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.
- `fdc3-workbench`: The FDC3 Workbench app from https://github.com/FDC3/toolbox/workbench, ported to use WebFDC3. Start with `yarn dev` and invoke from `demo`
## Configuring the client
Expand Down Expand Up @@ -81,19 +81,14 @@ The project is divided into several different yarn workspaces:
- Handing of fdc3Ready
- Handling on intents, open, finishing test cases for `da` / `testing`
## More Messages
Desktop Agent Briding needs extending with the following types:
## Troubleshooting
- Try removing tsconfig.tsbuildinfo files if you are having trouble building
## Issues To Resolve
- Desktop Agent Briding needs extending with types from `fdc3-common/index.ts`
- Move exchange into client, instead of common.
- How does the da-server tell the da-proxy about the channel metadata? We need a message to get the list of user channels from the server.
- How does the da-server decide on a desktop agent name (maybe it just has one?)
- AppChecker / AppDetailsResolver / AppPortResolver - this is all too complex.
Expand All @@ -102,6 +97,8 @@ Desktop Agent Briding needs extending with the following types:
- use cookie for the da id.
- add server tests for intent resolution choice
- handle disconnections from the server / update running apps
- test intent resolvers on different domains
- we shoulnd't be using meta for routing - check this.
## Idea
Expand Down
14 changes: 12 additions & 2 deletions packages/demo/src/server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ const instances: Map<string, ConnectedWorld> = new Map()
io.on('connection', (socket: Socket) => {

var myInstance: ConnectedWorld | undefined
var myId: string | undefined

socket.on(DA_HELLO, function (id) {
myId = id
const instance = instances.get(id) ?? {
server: socket,
apps: new Map()
Expand All @@ -42,11 +44,12 @@ io.on('connection', (socket: Socket) => {
})

socket.on(APP_HELLO, function (id: string, appID: AppIdentifier) {
myId = appID.instanceId!!
const instance = instances.get(id)

if (instance != undefined) {
console.log("An app connected: " + id)
instance.apps.set(appID.instanceId!!, socket)
instance.apps.set(myId, socket)
myInstance = instance
} else {
console.log("App Tried Connecting to non-existent DA Instance " + id + " " + appID.appId + " " + appID.instanceId)
Expand Down Expand Up @@ -78,6 +81,13 @@ io.on('connection', (socket: Socket) => {
})

socket.on("disconnect", function (): void {
console.log("Apparent disconnect")
if (myInstance) {
if (myInstance.server.id == socket.id) {
instances.delete(myId!!)
} else {
myInstance.apps.delete(myId!!)
console.log(`Apparent disconnect: ${myInstance.apps.size} remaining`)
}
}
})
})

0 comments on commit 434b4f2

Please sign in to comment.