-
Notifications
You must be signed in to change notification settings - Fork 4
/
example.js
41 lines (34 loc) · 1.21 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const {
ActivityColorManager,
MxGraphAdapter,
PointerManager,
SelectionManager,
Deserializer
} = ConvergenceMxGraphAdapter;
async function run() {
const domain = await Convergence.connectAnonymously(CONVERGENCE_URL, "test user");
const model = await domain
.models()
.openAutoCreate({
id: "mxgrph-example",
collection: "mxgraph",
ephemeral: true,
data: () => {
return DEFAULT_GRAPH;
}
});
const options = {autoCreate: {ephemeral: true, worldPermissions: ["join", "view_state", "set_state"]}};
const activity = await domain
.activities()
.join("mxgraph-example", "example", options);
const container = document.getElementById("mxgraph");
const graphModel = Deserializer.deserializeMxGraphModel(model.root().value());
const graph = new mxGraph(container, graphModel);
setTimeout(() => {
const colorManger = new ActivityColorManager(activity);
const graphAdapter = new MxGraphAdapter(graph, model.root());
const pointerManager = new PointerManager(graph, activity, colorManger);
const selectionManager = new SelectionManager(graph, activity, colorManger, graphAdapter);
}, 0);
}
run().catch(e => console.log(e));