@yorkie-js/sdk 0.6.35 → 0.6.37

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.
@@ -39,7 +39,7 @@
39
39
  rpcAddr: 'http://localhost:8080',
40
40
  });
41
41
 
42
- let presence = null;
42
+ let channel = null;
43
43
  const events = [];
44
44
 
45
45
  const elements = {
@@ -90,24 +90,24 @@
90
90
  try {
91
91
  elements.joinBtn.disabled = true;
92
92
 
93
- presence = new yorkie.Presence(roomId);
93
+ channel = new yorkie.Channel(roomId);
94
94
 
95
- presence.subscribe((event) => {
96
- console.log('Presence event:', event);
95
+ channel.subscribe((event) => {
96
+ console.log('Channel event:', event);
97
97
  updateCounter(event.count);
98
98
 
99
- if (event.type === yorkie.PresenceEventType.Initialized) {
99
+ if (event.type === yorkie.ChannelEventType.Initialized) {
100
100
  addEvent(`✅ Joined room - ${event.count} user(s) online`);
101
- } else if (event.type === yorkie.PresenceEventType.Changed) {
101
+ } else if (event.type === yorkie.ChannelEventType.Changed) {
102
102
  addEvent(`📊 Count updated - ${event.count} user(s) online`);
103
103
  }
104
104
  });
105
105
 
106
- await client.attach(presence);
106
+ await client.attach(channel);
107
107
  updateStatus(true);
108
108
  elements.leaveBtn.disabled = false;
109
109
 
110
- updateCounter(presence.getCount());
110
+ updateCounter(channel.getPresenceCount());
111
111
  } catch (error) {
112
112
  console.error('Failed to join room:', error);
113
113
  addEvent('❌ Failed to join room');
@@ -119,13 +119,15 @@
119
119
  try {
120
120
  elements.leaveBtn.disabled = true;
121
121
 
122
- await client.detach(presence);
122
+ await client.detach(channel);
123
123
  updateStatus(false);
124
124
  elements.joinBtn.disabled = false;
125
125
 
126
- addEvent(`👋 Left room - ${presence.getCount()} user(s) remaining`);
126
+ addEvent(
127
+ `👋 Left room - ${channel.getPresenceCount()} user(s) remaining`,
128
+ );
127
129
  updateCounter(0);
128
- presence = null;
130
+ channel = null;
129
131
  } catch (error) {
130
132
  console.error('Failed to leave room:', error);
131
133
  addEvent('❌ Failed to leave room');