oddsockets-nodejs 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +448 -0
- package/dist/Channel.js +1 -0
- package/dist/EnhancedFeatures.js +1 -0
- package/dist/ManagerDiscovery.js +1 -0
- package/dist/MessageSizeValidator.js +1 -0
- package/dist/OddSockets.js +1 -0
- package/dist/PubNubCompat.js +1 -0
- package/dist/index.js +1 -0
- package/examples/basic-usage.js +140 -0
- package/examples/enhanced-features-usage.js +403 -0
- package/examples/index.html +729 -0
- package/package.json +61 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
const OddSockets = require('../src/index');
|
|
2
|
+
|
|
3
|
+
// Example: Basic OddSockets usage
|
|
4
|
+
async function basicExample() {
|
|
5
|
+
console.log('š OddSockets Node.js SDK - Basic Example');
|
|
6
|
+
|
|
7
|
+
// Initialize the client
|
|
8
|
+
const client = new OddSockets({
|
|
9
|
+
apiKey: 'your-api-key-here',
|
|
10
|
+
userId: 'user-123'
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// Listen for connection events
|
|
14
|
+
client.on('connected', () => {
|
|
15
|
+
console.log('ā
Connected to OddSockets');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
client.on('disconnected', () => {
|
|
19
|
+
console.log('ā Disconnected from OddSockets');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
client.on('error', (error) => {
|
|
23
|
+
console.error('š„ Error:', error.message);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Get a channel
|
|
27
|
+
const channel = client.channel('my-channel');
|
|
28
|
+
|
|
29
|
+
// Subscribe to messages
|
|
30
|
+
await channel.subscribe((message) => {
|
|
31
|
+
console.log('šØ Received message:', message);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Publish a message
|
|
35
|
+
try {
|
|
36
|
+
const result = await channel.publish({
|
|
37
|
+
text: 'Hello from Node.js!',
|
|
38
|
+
timestamp: new Date().toISOString()
|
|
39
|
+
});
|
|
40
|
+
console.log('š¤ Message published:', result);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error('ā Failed to publish:', error.message);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Publish multiple messages at once
|
|
46
|
+
try {
|
|
47
|
+
const results = await client.publishBulk([
|
|
48
|
+
{ channel: 'my-channel', message: 'Message 1' },
|
|
49
|
+
{ channel: 'my-channel', message: 'Message 2' },
|
|
50
|
+
{ channel: 'another-channel', message: 'Message 3' }
|
|
51
|
+
]);
|
|
52
|
+
console.log('š¤ Bulk publish results:', results);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error('ā Bulk publish failed:', error.message);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Get message history
|
|
58
|
+
try {
|
|
59
|
+
const history = await channel.getHistory({ count: 10 });
|
|
60
|
+
console.log('š Message history:', history);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error('ā Failed to get history:', error.message);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Clean up after 10 seconds
|
|
66
|
+
setTimeout(async () => {
|
|
67
|
+
await channel.unsubscribe();
|
|
68
|
+
client.disconnect();
|
|
69
|
+
console.log('š Example completed');
|
|
70
|
+
process.exit(0);
|
|
71
|
+
}, 10000);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Example: PubNub compatibility
|
|
75
|
+
async function pubNubCompatExample() {
|
|
76
|
+
console.log('š PubNub Compatibility Example');
|
|
77
|
+
|
|
78
|
+
const { PubNubCompat } = OddSockets;
|
|
79
|
+
|
|
80
|
+
// Initialize with PubNub-style configuration
|
|
81
|
+
const pubnub = new PubNubCompat({
|
|
82
|
+
publishKey: 'your-api-key-here',
|
|
83
|
+
subscribeKey: 'your-api-key-here',
|
|
84
|
+
userId: 'user-456'
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Add listener (PubNub style)
|
|
88
|
+
pubnub.addListener({
|
|
89
|
+
message: (messageEvent) => {
|
|
90
|
+
console.log('šØ PubNub-style message:', messageEvent);
|
|
91
|
+
},
|
|
92
|
+
presence: (presenceEvent) => {
|
|
93
|
+
console.log('š„ Presence event:', presenceEvent);
|
|
94
|
+
},
|
|
95
|
+
status: (statusEvent) => {
|
|
96
|
+
console.log('š Status:', statusEvent.category);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Subscribe to channels
|
|
101
|
+
pubnub.subscribe({
|
|
102
|
+
channels: ['channel-1', 'channel-2'],
|
|
103
|
+
withPresence: true
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Publish a message
|
|
107
|
+
pubnub.publish({
|
|
108
|
+
channel: 'channel-1',
|
|
109
|
+
message: 'Hello from PubNub compatibility layer!'
|
|
110
|
+
}, (response) => {
|
|
111
|
+
if (response.error) {
|
|
112
|
+
console.error('ā Publish error:', response.error);
|
|
113
|
+
} else {
|
|
114
|
+
console.log('š¤ Published with timetoken:', response.timetoken);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Clean up after 10 seconds
|
|
119
|
+
setTimeout(() => {
|
|
120
|
+
pubnub.disconnect();
|
|
121
|
+
console.log('š PubNub compatibility example completed');
|
|
122
|
+
process.exit(0);
|
|
123
|
+
}, 10000);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Run examples
|
|
127
|
+
if (require.main === module) {
|
|
128
|
+
const example = process.argv[2] || 'basic';
|
|
129
|
+
|
|
130
|
+
if (example === 'pubnub') {
|
|
131
|
+
pubNubCompatExample().catch(console.error);
|
|
132
|
+
} else {
|
|
133
|
+
basicExample().catch(console.error);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
module.exports = {
|
|
138
|
+
basicExample,
|
|
139
|
+
pubNubCompatExample
|
|
140
|
+
};
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OddSockets SDK - Enhanced Features Usage Example
|
|
3
|
+
* Demonstrates all 67 new Slack-like events
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const OddSockets = require('../src/index');
|
|
7
|
+
|
|
8
|
+
// Initialize client
|
|
9
|
+
const client = new OddSockets({
|
|
10
|
+
apiKey: 'your_api_key_here',
|
|
11
|
+
userId: 'user_123'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// Wait for connection
|
|
15
|
+
client.on('connected', async () => {
|
|
16
|
+
console.log('ā
Connected to OddSockets!');
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
// ==================== THREAD EVENTS ====================
|
|
20
|
+
console.log('\nš Thread Events:');
|
|
21
|
+
|
|
22
|
+
// Reply to a message in a thread
|
|
23
|
+
const threadReply = await client.enhanced.threadReply({
|
|
24
|
+
channel: 'general',
|
|
25
|
+
parentMessageId: 'msg_123',
|
|
26
|
+
message: 'This is a threaded reply!',
|
|
27
|
+
userId: 'user_123',
|
|
28
|
+
userName: 'John Doe'
|
|
29
|
+
});
|
|
30
|
+
console.log('Thread reply created:', threadReply);
|
|
31
|
+
|
|
32
|
+
// Get thread with all replies
|
|
33
|
+
const thread = await client.enhanced.getThread('thread_123');
|
|
34
|
+
console.log('Thread data:', thread);
|
|
35
|
+
|
|
36
|
+
// Subscribe to thread updates
|
|
37
|
+
await client.enhanced.subscribeThread('thread_123', 'user_123');
|
|
38
|
+
|
|
39
|
+
// Mark thread as read
|
|
40
|
+
client.enhanced.markThreadRead('thread_123', 'user_123');
|
|
41
|
+
|
|
42
|
+
// Follow/unfollow thread
|
|
43
|
+
client.enhanced.followThread('thread_123', 'user_123');
|
|
44
|
+
|
|
45
|
+
// ==================== REACTION EVENTS ====================
|
|
46
|
+
console.log('\nš Reaction Events:');
|
|
47
|
+
|
|
48
|
+
// Add reaction to message
|
|
49
|
+
client.enhanced.addReaction({
|
|
50
|
+
messageId: 'msg_123',
|
|
51
|
+
channel: 'general',
|
|
52
|
+
emoji: 'š',
|
|
53
|
+
userId: 'user_123',
|
|
54
|
+
userName: 'John Doe'
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Remove reaction
|
|
58
|
+
client.enhanced.removeReaction({
|
|
59
|
+
messageId: 'msg_123',
|
|
60
|
+
channel: 'general',
|
|
61
|
+
emoji: 'š',
|
|
62
|
+
userId: 'user_123'
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Get all reactions for a message
|
|
66
|
+
const reactions = await client.enhanced.getReactions('msg_123');
|
|
67
|
+
console.log('Message reactions:', reactions);
|
|
68
|
+
|
|
69
|
+
// ==================== READ RECEIPT EVENTS ====================
|
|
70
|
+
console.log('\nā Read Receipt Events:');
|
|
71
|
+
|
|
72
|
+
// Mark message as read
|
|
73
|
+
client.enhanced.markRead({
|
|
74
|
+
messageId: 'msg_123',
|
|
75
|
+
channel: 'general',
|
|
76
|
+
userId: 'user_123',
|
|
77
|
+
userName: 'John Doe'
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Get unread counts
|
|
81
|
+
const unreadCounts = await client.enhanced.getUnreadCounts('user_123', ['general', 'random']);
|
|
82
|
+
console.log('Unread counts:', unreadCounts);
|
|
83
|
+
|
|
84
|
+
// Mark all messages in channel as read
|
|
85
|
+
client.enhanced.markAllRead('general', 'user_123');
|
|
86
|
+
|
|
87
|
+
// ==================== CHANNEL EVENTS ====================
|
|
88
|
+
console.log('\nš¢ Channel Events:');
|
|
89
|
+
|
|
90
|
+
// Create a new channel
|
|
91
|
+
const newChannel = await client.enhanced.createChannel({
|
|
92
|
+
name: 'new-channel',
|
|
93
|
+
type: 'public',
|
|
94
|
+
description: 'A new channel for testing',
|
|
95
|
+
topic: 'Testing enhanced features',
|
|
96
|
+
createdBy: 'user_123',
|
|
97
|
+
createdByName: 'John Doe',
|
|
98
|
+
members: [
|
|
99
|
+
{ userId: 'user_456', userName: 'Jane Smith' }
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
console.log('Channel created:', newChannel);
|
|
103
|
+
|
|
104
|
+
// Update channel
|
|
105
|
+
client.enhanced.updateChannel({
|
|
106
|
+
channelId: 'channel_123',
|
|
107
|
+
updates: {
|
|
108
|
+
description: 'Updated description',
|
|
109
|
+
topic: 'New topic'
|
|
110
|
+
},
|
|
111
|
+
userId: 'user_123'
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Join a public channel
|
|
115
|
+
client.enhanced.joinChannel({
|
|
116
|
+
channelId: 'channel_123',
|
|
117
|
+
userId: 'user_123',
|
|
118
|
+
userName: 'John Doe'
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Get channel members
|
|
122
|
+
const members = await client.enhanced.getChannelMembers('channel_123');
|
|
123
|
+
console.log('Channel members:', members);
|
|
124
|
+
|
|
125
|
+
// Invite user to channel
|
|
126
|
+
client.enhanced.inviteToChannel({
|
|
127
|
+
channelId: 'channel_123',
|
|
128
|
+
invitedUserId: 'user_789',
|
|
129
|
+
invitedUserName: 'Bob Wilson',
|
|
130
|
+
invitedBy: 'user_123'
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// ==================== DIRECT MESSAGE EVENTS ====================
|
|
134
|
+
console.log('\nš¬ Direct Message Events:');
|
|
135
|
+
|
|
136
|
+
// Create DM conversation
|
|
137
|
+
const dmConversation = await client.enhanced.createDM({
|
|
138
|
+
userIds: ['user_123', 'user_456'],
|
|
139
|
+
type: '1-on-1'
|
|
140
|
+
});
|
|
141
|
+
console.log('DM conversation:', dmConversation);
|
|
142
|
+
|
|
143
|
+
// Send DM
|
|
144
|
+
client.enhanced.sendDM({
|
|
145
|
+
conversationId: dmConversation.conversationId,
|
|
146
|
+
message: 'Hello! This is a direct message.',
|
|
147
|
+
userId: 'user_123',
|
|
148
|
+
userName: 'John Doe'
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Get user's DM conversations
|
|
152
|
+
const conversations = await client.enhanced.getDMConversations('user_123');
|
|
153
|
+
console.log('DM conversations:', conversations);
|
|
154
|
+
|
|
155
|
+
// ==================== NOTIFICATION EVENTS ====================
|
|
156
|
+
console.log('\nš Notification Events:');
|
|
157
|
+
|
|
158
|
+
// Subscribe to notifications
|
|
159
|
+
client.enhanced.subscribeNotifications('user_123');
|
|
160
|
+
|
|
161
|
+
// Get notifications
|
|
162
|
+
const notifications = await client.enhanced.getNotifications({
|
|
163
|
+
userId: 'user_123',
|
|
164
|
+
limit: 50,
|
|
165
|
+
status: 'unread'
|
|
166
|
+
});
|
|
167
|
+
console.log('Notifications:', notifications);
|
|
168
|
+
|
|
169
|
+
// Mark notification as read
|
|
170
|
+
client.enhanced.markNotificationRead('notif_123', 'user_123');
|
|
171
|
+
|
|
172
|
+
// Mark all notifications as read
|
|
173
|
+
client.enhanced.markAllNotificationsRead('user_123');
|
|
174
|
+
|
|
175
|
+
// ==================== FILE UPLOAD EVENTS ====================
|
|
176
|
+
console.log('\nš File Upload Events:');
|
|
177
|
+
|
|
178
|
+
// Start file upload
|
|
179
|
+
const upload = await client.enhanced.startFileUpload({
|
|
180
|
+
fileName: 'document.pdf',
|
|
181
|
+
fileSize: 1024000,
|
|
182
|
+
mimeType: 'application/pdf',
|
|
183
|
+
channel: 'general',
|
|
184
|
+
userId: 'user_123',
|
|
185
|
+
userName: 'John Doe'
|
|
186
|
+
});
|
|
187
|
+
console.log('Upload started:', upload);
|
|
188
|
+
|
|
189
|
+
// Update progress
|
|
190
|
+
client.enhanced.uploadProgress({
|
|
191
|
+
uploadId: upload.uploadId,
|
|
192
|
+
bytesUploaded: 512000,
|
|
193
|
+
channel: 'general'
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Complete upload
|
|
197
|
+
client.enhanced.uploadComplete({
|
|
198
|
+
uploadId: upload.uploadId,
|
|
199
|
+
fileId: 'file_456',
|
|
200
|
+
storageInfo: {
|
|
201
|
+
url: 'https://cdn.example.com/file.pdf',
|
|
202
|
+
bucket: 'uploads',
|
|
203
|
+
key: 'files/file.pdf'
|
|
204
|
+
},
|
|
205
|
+
channel: 'general'
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// ==================== PRESENCE EVENTS ====================
|
|
209
|
+
console.log('\nš¤ Presence Events:');
|
|
210
|
+
|
|
211
|
+
// Set user status
|
|
212
|
+
client.enhanced.setStatus('user_123', 'online');
|
|
213
|
+
|
|
214
|
+
// Set custom status
|
|
215
|
+
client.enhanced.setCustomStatus({
|
|
216
|
+
userId: 'user_123',
|
|
217
|
+
emoji: 'šļø',
|
|
218
|
+
text: 'On vacation',
|
|
219
|
+
expiresAt: '2025-01-15T00:00:00Z'
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// Clear custom status
|
|
223
|
+
client.enhanced.clearCustomStatus('user_123');
|
|
224
|
+
|
|
225
|
+
// Enable Do Not Disturb
|
|
226
|
+
client.enhanced.setDND('user_123', '2025-01-10T18:00:00Z');
|
|
227
|
+
|
|
228
|
+
// Start typing indicator
|
|
229
|
+
client.enhanced.startTyping('user_123', 'general');
|
|
230
|
+
|
|
231
|
+
// Stop typing after 3 seconds
|
|
232
|
+
setTimeout(() => {
|
|
233
|
+
client.enhanced.stopTyping('user_123', 'general');
|
|
234
|
+
}, 3000);
|
|
235
|
+
|
|
236
|
+
// Get user presence
|
|
237
|
+
const presence = await client.enhanced.getUserPresence(['user_123', 'user_456']);
|
|
238
|
+
console.log('User presence:', presence);
|
|
239
|
+
|
|
240
|
+
// ==================== MESSAGE EDITING EVENTS ====================
|
|
241
|
+
console.log('\nāļø Message Editing Events:');
|
|
242
|
+
|
|
243
|
+
// Edit message
|
|
244
|
+
client.enhanced.editMessage({
|
|
245
|
+
messageId: 'msg_123',
|
|
246
|
+
channel: 'general',
|
|
247
|
+
newContent: 'Updated message content',
|
|
248
|
+
userId: 'user_123'
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// Delete message
|
|
252
|
+
client.enhanced.deleteMessage({
|
|
253
|
+
messageId: 'msg_456',
|
|
254
|
+
channel: 'general',
|
|
255
|
+
userId: 'user_123'
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// Pin message
|
|
259
|
+
client.enhanced.pinMessage({
|
|
260
|
+
messageId: 'msg_789',
|
|
261
|
+
channel: 'general',
|
|
262
|
+
userId: 'user_123'
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// Get pinned messages
|
|
266
|
+
const pinnedMessages = await client.enhanced.getPinnedMessages('general');
|
|
267
|
+
console.log('Pinned messages:', pinnedMessages);
|
|
268
|
+
|
|
269
|
+
// Unpin message
|
|
270
|
+
client.enhanced.unpinMessage({
|
|
271
|
+
messageId: 'msg_789',
|
|
272
|
+
channel: 'general',
|
|
273
|
+
userId: 'user_123'
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// ==================== SEARCH EVENTS ====================
|
|
277
|
+
console.log('\nš Search Events:');
|
|
278
|
+
|
|
279
|
+
// Search messages across all channels
|
|
280
|
+
const searchResults = await client.enhanced.searchMessages({
|
|
281
|
+
query: 'important',
|
|
282
|
+
limit: 50,
|
|
283
|
+
userId: 'user_123'
|
|
284
|
+
});
|
|
285
|
+
console.log('Search results:', searchResults);
|
|
286
|
+
|
|
287
|
+
// Filter messages by criteria
|
|
288
|
+
const filterResults = await client.enhanced.filterMessages({
|
|
289
|
+
channel: 'general',
|
|
290
|
+
userId: 'user_123',
|
|
291
|
+
startDate: '2025-01-01T00:00:00Z',
|
|
292
|
+
endDate: '2025-01-10T00:00:00Z',
|
|
293
|
+
hasAttachments: true,
|
|
294
|
+
limit: 50
|
|
295
|
+
});
|
|
296
|
+
console.log('Filter results:', filterResults);
|
|
297
|
+
|
|
298
|
+
// Search in specific channel
|
|
299
|
+
const channelSearch = await client.enhanced.searchInChannel({
|
|
300
|
+
channel: 'general',
|
|
301
|
+
query: 'meeting',
|
|
302
|
+
limit: 50
|
|
303
|
+
});
|
|
304
|
+
console.log('Channel search results:', channelSearch);
|
|
305
|
+
|
|
306
|
+
// Search by user
|
|
307
|
+
const userSearch = await client.enhanced.searchByUser({
|
|
308
|
+
userId: 'user_456',
|
|
309
|
+
query: 'project',
|
|
310
|
+
limit: 50
|
|
311
|
+
});
|
|
312
|
+
console.log('User search results:', userSearch);
|
|
313
|
+
|
|
314
|
+
console.log('\nā
All enhanced features demonstrated!');
|
|
315
|
+
|
|
316
|
+
} catch (error) {
|
|
317
|
+
console.error('Error:', error);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
// Listen for enhanced event broadcasts
|
|
322
|
+
client.on('connected', () => {
|
|
323
|
+
const socket = client._getSocket();
|
|
324
|
+
|
|
325
|
+
// Thread events
|
|
326
|
+
socket.on('new_thread_reply', (data) => {
|
|
327
|
+
console.log('New thread reply:', data);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
// Reaction events
|
|
331
|
+
socket.on('reaction_added', (data) => {
|
|
332
|
+
console.log('Reaction added:', data);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
socket.on('reaction_removed', (data) => {
|
|
336
|
+
console.log('Reaction removed:', data);
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
// Read receipt events
|
|
340
|
+
socket.on('message_read', (data) => {
|
|
341
|
+
console.log('Message read:', data);
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
// Channel events
|
|
345
|
+
socket.on('channel_created', (data) => {
|
|
346
|
+
console.log('Channel created:', data);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
socket.on('user_joined_channel', (data) => {
|
|
350
|
+
console.log('User joined channel:', data);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
// DM events
|
|
354
|
+
socket.on('dm_received', (data) => {
|
|
355
|
+
console.log('DM received:', data);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// Notification events
|
|
359
|
+
socket.on('notification', (data) => {
|
|
360
|
+
console.log('New notification:', data);
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
// File upload events
|
|
364
|
+
socket.on('file_upload_completed', (data) => {
|
|
365
|
+
console.log('File upload completed:', data);
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
// Presence events
|
|
369
|
+
socket.on('user_status_changed', (data) => {
|
|
370
|
+
console.log('User status changed:', data);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
socket.on('user_typing', (data) => {
|
|
374
|
+
console.log('User typing:', data);
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
socket.on('custom_status_updated', (data) => {
|
|
378
|
+
console.log('Custom status updated:', data);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
// Message editing events
|
|
382
|
+
socket.on('message_edited', (data) => {
|
|
383
|
+
console.log('Message edited:', data);
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
socket.on('message_deleted', (data) => {
|
|
387
|
+
console.log('Message deleted:', data);
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
socket.on('message_pinned', (data) => {
|
|
391
|
+
console.log('Message pinned:', data);
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
// Handle errors
|
|
396
|
+
client.on('error', (error) => {
|
|
397
|
+
console.error('OddSockets error:', error);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
// Handle disconnection
|
|
401
|
+
client.on('disconnected', (reason) => {
|
|
402
|
+
console.log('Disconnected:', reason);
|
|
403
|
+
});
|