-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Both message port and iframe approaches working
- Loading branch information
Showing
9 changed files
with
87 additions
and
68 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,21 +1,53 @@ | ||
import { FDC3_PORT_TRANSFER_RESPONSE_TYPE } from "fdc3-common"; | ||
import { io } from "socket.io-client" | ||
import { link } from "./util"; | ||
import { AppIdentifier } from "@finos/fdc3"; | ||
import { APP_HELLO } from "../../message-types"; | ||
|
||
const appWindow = window.parent; | ||
|
||
function getQueryVariable(variable: string): string { | ||
var query = window.location.search.substring(1); | ||
var vars = query.split("&"); | ||
for (var i = 0; i < vars.length; i++) { | ||
var pair = vars[i].split("="); | ||
if (pair[0] == variable) { | ||
return pair[1]; | ||
} | ||
} | ||
|
||
return "" | ||
} | ||
|
||
function getSource(): AppIdentifier { | ||
const source = getQueryVariable("source") | ||
const decoded = decodeURIComponent(source) | ||
const object: AppIdentifier = JSON.parse(decoded) | ||
return object | ||
} | ||
|
||
function getDeskopAgentId(): string { | ||
const id = getQueryVariable("desktopAgentId") | ||
return id | ||
} | ||
|
||
|
||
window.addEventListener("load", () => { | ||
|
||
const socket = io() | ||
const channel = new MessageChannel() | ||
const source = getSource() | ||
const desktopAgentUUID = getDeskopAgentId() | ||
|
||
socket.on("connect", () => { | ||
|
||
//link(socket, channel) | ||
link(socket, channel, source) | ||
|
||
// sned the other end of the channel to the app | ||
appWindow.postMessage({ | ||
type: FDC3_PORT_TRANSFER_RESPONSE_TYPE, | ||
}, "*", [channel.port1]) | ||
|
||
socket.emit(APP_HELLO, desktopAgentUUID, source) | ||
}) | ||
}) |
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