@diory/client-js 0.2.0-rc11 → 0.2.0-rc12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,7 @@ declare class DioryClient implements IDioryClient {
10
10
  diory?: IDiory;
11
11
  constructor(dataClients: IDataClient[]);
12
12
  initialise: (connections: IConnectionObject[]) => Promise<IDioryClient>;
13
+ selectRoom: (roomObject: IRoomObject) => IRoom;
13
14
  enterRoom: (roomObject: IRoomObject) => Promise<IRoom>;
14
15
  focusDiory: (dioryObject: IDioryObject) => IDiory;
15
16
  getDiosphereClients: (connections?: IConnectionObject[]) => import("../types").IConnectionClient[];
@@ -12,14 +12,17 @@ class DioryClient {
12
12
  console.info('initialise', connections);
13
13
  this.connections = connections;
14
14
  this.diosphere.resetRooms();
15
+ console.info(this.diosphere);
15
16
  return this;
16
17
  };
18
+ this.selectRoom = (roomObject) => {
19
+ return (this.room = this.diosphere.getRoom(roomObject));
20
+ };
17
21
  this.enterRoom = async (roomObject) => {
18
22
  console.info('enterRoom', roomObject);
19
- this.room = this.diosphere.getRoom(roomObject);
23
+ this.selectRoom(roomObject);
20
24
  this.diograph.resetDiograph();
21
25
  await this.getDiograph();
22
- this.focusDiory({ id: '/' });
23
26
  console.info(this.room);
24
27
  return this.room;
25
28
  };
@@ -36,9 +39,15 @@ class DioryClient {
36
39
  this.getDiosphere = async (connections) => {
37
40
  console.info('getDiosphere', connections);
38
41
  await Promise.all(this.getDiosphereClients(connections).map(async (connectionClient) => {
39
- const diosphereObject = await connectionClient.getDiosphere();
40
- this.diosphere.addDiosphere(diosphereObject);
41
- console.info(this.diosphere.toObject());
42
+ try {
43
+ const diosphereObject = await connectionClient.getDiosphere();
44
+ this.diosphere.addDiosphere(diosphereObject);
45
+ this.selectRoom({ id: '/' });
46
+ console.info(this.diosphere.toObject());
47
+ }
48
+ catch (error) {
49
+ console.error(error);
50
+ }
42
51
  return;
43
52
  }));
44
53
  return this.diosphere;
@@ -55,9 +64,15 @@ class DioryClient {
55
64
  this.getDiograph = async (connections) => {
56
65
  console.info('getDiograph', connections);
57
66
  await Promise.all(this.getDiographClients(connections).map(async (connectionClient) => {
58
- const diographObject = await connectionClient.getDiograph();
59
- this.diograph.addDiograph(diographObject);
60
- console.info(this.diograph.toObject());
67
+ try {
68
+ const diographObject = await connectionClient.getDiograph();
69
+ this.diograph.addDiograph(diographObject);
70
+ this.focusDiory({ id: '/' });
71
+ console.info(this.diograph.toObject());
72
+ }
73
+ catch (error) {
74
+ console.error(error);
75
+ }
61
76
  return;
62
77
  }));
63
78
  return this.diograph;
package/dist/types.d.ts CHANGED
@@ -49,6 +49,7 @@ export interface IDioryClient {
49
49
  diograph: IDiograph;
50
50
  diory?: IDiory;
51
51
  initialise: (connections: IConnectionObject[]) => Promise<IDioryClient>;
52
+ selectRoom: (roomObject: IRoomObject) => IRoom;
52
53
  enterRoom: (roomObject: IRoomObject) => Promise<IRoom>;
53
54
  focusDiory: (dioryObject: IDioryObject) => IDiory;
54
55
  getDiosphere: () => Promise<IDiosphere>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diory/client-js",
3
- "version": "0.2.0-rc11",
3
+ "version": "0.2.0-rc12",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "Olli-Pekka Pohjola <op@diory.me>, Jouni Alanen <jouni@diory.me>",
@@ -27,20 +27,24 @@ class DioryClient implements IDioryClient {
27
27
 
28
28
  this.connections = connections
29
29
  this.diosphere.resetRooms()
30
+ console.info(this.diosphere)
30
31
 
31
32
  return this
32
33
  }
33
34
 
35
+ selectRoom = (roomObject: IRoomObject): IRoom => {
36
+ return (this.room = this.diosphere.getRoom(roomObject))
37
+ }
38
+
34
39
  enterRoom = async (roomObject: IRoomObject): Promise<IRoom> => {
35
40
  console.info('enterRoom', roomObject)
36
41
 
37
- this.room = this.diosphere.getRoom(roomObject)
42
+ this.selectRoom(roomObject)
38
43
  this.diograph.resetDiograph()
39
44
  await this.getDiograph()
40
- this.focusDiory({ id: '/' })
41
45
  console.info(this.room)
42
46
 
43
- return this.room
47
+ return this.room as IRoom
44
48
  }
45
49
 
46
50
  focusDiory = (dioryObject: IDioryObject): IDiory => {
@@ -59,9 +63,14 @@ class DioryClient implements IDioryClient {
59
63
  console.info('getDiosphere', connections)
60
64
  await Promise.all(
61
65
  this.getDiosphereClients(connections).map(async (connectionClient) => {
62
- const diosphereObject = await connectionClient.getDiosphere()
63
- this.diosphere.addDiosphere(diosphereObject)
64
- console.info(this.diosphere.toObject())
66
+ try {
67
+ const diosphereObject = await connectionClient.getDiosphere()
68
+ this.diosphere.addDiosphere(diosphereObject)
69
+ this.selectRoom({ id: '/' })
70
+ console.info(this.diosphere.toObject())
71
+ } catch (error) {
72
+ console.error(error)
73
+ }
65
74
 
66
75
  return
67
76
  }),
@@ -90,9 +99,14 @@ class DioryClient implements IDioryClient {
90
99
 
91
100
  await Promise.all(
92
101
  this.getDiographClients(connections).map(async (connectionClient) => {
93
- const diographObject = await connectionClient.getDiograph()
94
- this.diograph.addDiograph(diographObject)
95
- console.info(this.diograph.toObject())
102
+ try {
103
+ const diographObject = await connectionClient.getDiograph()
104
+ this.diograph.addDiograph(diographObject)
105
+ this.focusDiory({ id: '/' })
106
+ console.info(this.diograph.toObject())
107
+ } catch (error) {
108
+ console.error(error)
109
+ }
96
110
 
97
111
  return
98
112
  }),
package/src/types.ts CHANGED
@@ -59,6 +59,7 @@ export interface IDioryClient {
59
59
  diograph: IDiograph
60
60
  diory?: IDiory
61
61
  initialise: (connections: IConnectionObject[]) => Promise<IDioryClient>
62
+ selectRoom: (roomObject: IRoomObject) => IRoom
62
63
  enterRoom: (roomObject: IRoomObject) => Promise<IRoom>
63
64
  focusDiory: (dioryObject: IDioryObject) => IDiory
64
65
  getDiosphere: () => Promise<IDiosphere>