mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-23 12:52:24 +02:00
+1








98652c6476
* Add bump-changes * Add utility tests * Add utility tests * Bump to new version of esbuild and typescript * v0.7.3 * use platform rig 0.7.10 * upgrade: memory engine optimized; change name to (was recommended by Copilot and Onnikov, TODO: CHANGE CLIENT TOO!!!) Signed-off-by: Leonid Kaganov <lleo@lleo.me> * Fix rate limits bug * Bump versions * Fix lock file * Fix bug in queue cleanup * Add more tests for queue * Add api-test tests * Initial commit * Improve hierarchy + tests Add tests for hierarchy and few performance/memory optimizations. * Add more hierarchy tests * Move from Huly platform repository * Add docker tests setup * Fix test to be executed only once * Add connection tests * Fix package include source files * More tests * Create README.md * Fix pnpm lock * Fix packages publish * Remove broken tests * feat: adjust hulylake client for storage adapter Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Fix export * Fix publish * Fix message update (#114) Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com> * Bump version Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com> * Bump versions Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Fix lang store (#115) Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com> * update hulylake client Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Bump version Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Add hulylake storage adapter Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Bump version Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * fix validation issues Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * fix: do not fail on deseralization error and add logs Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * bump version -> 0.1.14 Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * fix collaboration test Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Update prettier and new update-deps script Prettier + svelte support * fix unstable ydoc tests Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Add tx ordering middleware * Fix ordering tests * Fix Kafka close of admin * Add tests for measurement and understand overhead * Fix not updated lock file * Fix update-deps * Fix update-deps * Use latest platform-rig * Fix deps * Add rush check to CI * Use latest versions * Bump versions * Fix lock file * validate json patch Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * bump version -> 0.1.15 Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * fix merge unit tests Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Script to sync eslint deps * Fix deps * Fix tests * Fix platform-rig detection * Update to latest platform-rig * Update to latest platform rig and core * Bump typescript * Bump typescript * Rollback eslint plugins * Fix lock file * Bump platform-rig * Update to latest platform-rig * update to latest platform-rig * Allow to compile svelte files * Add ui-test component for checking compile * Fix log levels rename compile ui -> compile ui-esbuild * Fix build * Bump esbuild svelte version * Chore: use fixed versions in update-deps Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com> * Chore: commit changes Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com> * Update deps * Add tests for session manager * Fix txOrdering implementation * Bump ordering * Prevent metrics zero values in measure + Fix format svelte files * Revert update-deps script logic * v0.7.19 * update to latest platform-rig * Update deps * Fix pnpm * Session counters * Fix pnpm lock * Add storage client Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Bump versions Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * fix versions Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Bump core * Fix pnpm * Get rid of communication dependency * Add copilot memory file * Use proper name for instructions file * Fix instructions * Use domain instead of test name in gauges * Update instructions file * fix front service upload Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * remove incorrect test Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Move packages to huly.core * Move packages to core, since they are not utils * Add global user profile Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com> * Fix lock file Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com> * Add support for memory limit check * Bump version * Fix pnpm * report more accurate upload progress Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * fic validation issues Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Fix deps Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com> * Move LowLevelStorage to server * Fix linting * Revert "Fix linting" This reverts commit54631d353e. * Revert "Move LowLevelStorage to server" This reverts commitaafb8f6f12. * feature: add regorus engine with permit file Signed-off-by: Leonid Kaganov <lleo@lleo.me> * Fix one second counters for memory usage * Fix kafka test * use fresh core * Version bump * fix: key parameter added Signed-off-by: Leonid Kaganov <lleo@lleo.me> * Fix readme and few author mistakes * Export domain schemas * Bump version * Tests (#117) Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com> * Bump version Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com> * feat: compact compact worker (#4) Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * bump version -> 0.1.16 Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Add TypeIdentifier Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Add change logs Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * rename send -> try_send Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Bump Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Fix pnpm lock Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Add identifier middleware, bump core Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Add subsciption methods to account client Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com> * Fix lock file Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com> * Fix reaction notification (#118) Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com> * Bump version Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com> * Improve find methods schemas to convert to valid types Signed-off-by: Nikolay Marchuk <nikolay.marchuk@hardcoreeng.com> * Add change description Signed-off-by: Nikolay Marchuk <nikolay.marchuk@hardcoreeng.com> * Do not transcode while recording Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Open telemetry support Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * use proper content type in multipart upload Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Bump versions Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * fix build (#26) Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Fix peers (#120) Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com> * Bump version Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com> * Add ActivityCollaborativeChange Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Update pnpm Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Allow to suspend errors on with * Fix pnpm cache * update versions * v0.7.17 for all * v0.7.11 * v0.7.14 * remove arc from worker Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * bump version -> 0.1.17 Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Rank for attributes Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Update pnpm Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Fix one second counters * Fix withContext and allow pass options * Fix formatting * Use updated deps * Bump versions * Update deps * Update deps to platform.core * add support for textColor mark Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * add support for textStyle mark Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Bump versions Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Bump versions again Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Fix Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Rework on second timers * fix merge of large blobs feched from s3 Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * bump version -> 0.1.18 Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * New subscription methods in account-client * Update lock file Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com> * Send error on find for wrong domain * Suspend connect custom errors events in traces * Bump client * Bump core * update deps * Fix lock file * Sorting for TypeIdentifier Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Bump version Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * add workspace usage info Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Bump versions Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * Improve pg security perfomance Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Fix identifier middleware Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Update TxAccessLevel interface Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com> * Allow guest to update its identities Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com> * Add password login locked platform status Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com> * Fix Uptrace normalizeMarkdown errors Signed-off-by: Artem Savchenko <armisav@gmail.com> * Add change log Signed-off-by: Artem Savchenko <armisav@gmail.com> * Add txMatch to permission Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * update pnpm lock Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Bump Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Fix permission middleware Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Fix enum sorting Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Enable formatting check Signed-off-by: Andrey Sobolev <haiodo@gmail.com> * Enable formatting check * Add change Signed-off-by: Andrey Sobolev <haiodo@gmail.com> * Fix Uptrace NaN error Signed-off-by: Artem Savchenko <armisav@gmail.com> * feature: removed actors, improved performance Signed-off-by: Leonid Kaganov <lleo@lleo.me> * feature: ping from server to clients added Signed-off-by: Leonid Kaganov <lleo@lleo.me> * feature: ping from server to clients added Signed-off-by: Leonid Kaganov <lleo@lleo.me> * Compress kafka messages and fix exception in findAll Signed-off-by: Artem Savchenko <armisav@gmail.com> * Bump versions Signed-off-by: Artem Savchenko <armisav@gmail.com> * Bump versions Signed-off-by: Artem Savchenko <armisav@gmail.com> * Rush change Signed-off-by: Artem Savchenko <armisav@gmail.com> * Fix compression param Signed-off-by: Artem Savchenko <armisav@gmail.com> * Trigger change Signed-off-by: Artem Savchenko <armisav@gmail.com> * Clean up Signed-off-by: Artem Savchenko <armisav@gmail.com> * Trigger change Signed-off-by: Artem Savchenko <armisav@gmail.com> * Bump markdown version Signed-off-by: Artem Savchenko <armisav@gmail.com> * Enable sub projects * Fix wrong double symbol scripts * Include foundation packages * Add support for custom exclude filters Add support for custom exclude filters - by Andrey Sobolev - haiodo@gmail.com Signed-off-by: Andrey Sobolev <haiodo@gmail.com> * Bump Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Fix Uptrace filter is not a function error Signed-off-by: Artem Savchenko <armisav@gmail.com> * Sync versions Signed-off-by: Andrey Sobolev <haiodo@gmail.com> --------- Signed-off-by: Leonid Kaganov <lleo@lleo.me> Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com> Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com> Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> Signed-off-by: Nikolay Marchuk <nikolay.marchuk@hardcoreeng.com> Signed-off-by: Artem Savchenko <armisav@gmail.com> Signed-off-by: Andrey Sobolev <haiodo@gmail.com> Co-authored-by: Leonid Kaganov <lleo@lleo.me> Co-authored-by: Alexander Onnikov <Alexander.Onnikov@xored.com> Co-authored-by: Alexander Onnikov <Alexander.Onnikov@gmail.com> Co-authored-by: Kristina <kristin.fefelova@gmail.com> Co-authored-by: Alexey Zinoviev <alexey.zinoviev@xored.com> Co-authored-by: Denis Bykhov <bykhov.denis@gmail.com> Co-authored-by: Nikolay Marchuk <nikolay.marchuk@hardcoreeng.com> Co-authored-by: Alexander Onnikov <aonnikov@hardcoreeng.com> Co-authored-by: Artem Savchenko <armisav@gmail.com>
288 lines
8.3 KiB
TypeScript
288 lines
8.3 KiB
TypeScript
/**
|
|
* Example 2: Event Broadcasting Container
|
|
*
|
|
* This example demonstrates real-time event broadcasting to multiple connected clients.
|
|
* Shows how to implement a chat room where messages are broadcast to all participants.
|
|
*
|
|
* @example
|
|
* // Start the network server first:
|
|
* // cd pods/network-pod && rushx dev
|
|
*
|
|
* // Then run this example:
|
|
* // cd examples && rushx run:events
|
|
*/
|
|
|
|
import { AgentImpl, TickManagerImpl, NetworkImpl, createProxyHandler } from '@hcengineering/network-core'
|
|
import { NetworkServer } from '@hcengineering/network-server'
|
|
import { createNetworkClient, NetworkAgentServer } from '@hcengineering/network-client'
|
|
import type {
|
|
Container,
|
|
ContainerUuid,
|
|
ClientUuid,
|
|
ContainerKind,
|
|
GetOptions
|
|
} from '@hcengineering/network-core'
|
|
|
|
interface ChatMessage {
|
|
username: string
|
|
text: string
|
|
timestamp: number
|
|
}
|
|
|
|
// Define the service interface for type-safe proxy usage
|
|
interface ChatRoomService {
|
|
sendMessage: (username: string, text: string) => Promise<{
|
|
success: boolean;
|
|
messageId: number;
|
|
timestamp: number
|
|
}>
|
|
getHistory: () => Promise<{
|
|
success: boolean;
|
|
messages: ChatMessage[];
|
|
totalMessages: number
|
|
}>
|
|
getUserCount: () => Promise<{
|
|
success: boolean;
|
|
count: number;
|
|
connectedClients: ClientUuid[]
|
|
}>
|
|
getRoomInfo: () => Promise<{
|
|
success: boolean;
|
|
roomName: string;
|
|
uuid: ContainerUuid;
|
|
messageCount: number;
|
|
clientCount: number;
|
|
}>
|
|
}
|
|
|
|
class ChatRoomContainer implements Container {
|
|
private clients = new Map<ClientUuid, (data: any) => Promise<void>>()
|
|
private messages: ChatMessage[] = []
|
|
|
|
constructor(
|
|
readonly uuid: ContainerUuid,
|
|
readonly roomName: string
|
|
) {
|
|
console.log(`[ChatRoom] Room '${roomName}' created (${uuid})`)
|
|
}
|
|
|
|
// Implement the service interface
|
|
private serviceImpl: ChatRoomService = {
|
|
sendMessage: async (username: string, text: string) => {
|
|
const message: ChatMessage = {
|
|
username,
|
|
text,
|
|
timestamp: Date.now()
|
|
}
|
|
this.messages.push(message)
|
|
|
|
console.log(`[ChatRoom] ${message.username}: ${message.text}`)
|
|
|
|
// Broadcast to all connected clients
|
|
await this.broadcastToAll({
|
|
type: 'newMessage',
|
|
message,
|
|
messageCount: this.messages.length
|
|
})
|
|
|
|
return {
|
|
success: true,
|
|
messageId: this.messages.length - 1,
|
|
timestamp: message.timestamp
|
|
}
|
|
},
|
|
|
|
getHistory: async () => {
|
|
return {
|
|
success: true,
|
|
messages: this.messages,
|
|
totalMessages: this.messages.length
|
|
}
|
|
},
|
|
|
|
getUserCount: async () => {
|
|
return {
|
|
success: true,
|
|
count: this.clients.size,
|
|
connectedClients: Array.from(this.clients.keys())
|
|
}
|
|
},
|
|
|
|
getRoomInfo: async () => {
|
|
return {
|
|
success: true,
|
|
roomName: this.roomName,
|
|
uuid: this.uuid,
|
|
messageCount: this.messages.length,
|
|
clientCount: this.clients.size
|
|
}
|
|
}
|
|
}
|
|
|
|
// Use proxy handler to route requests to service implementation
|
|
request = createProxyHandler(this.serviceImpl as any, 'ChatRoomService')
|
|
|
|
async ping(): Promise<void> {}
|
|
|
|
async terminate(): Promise<void> {
|
|
console.log(`[ChatRoom] Room '${this.roomName}' closing...`)
|
|
|
|
// Notify all clients about room closure
|
|
await this.broadcastToAll({
|
|
type: 'roomClosed',
|
|
roomName: this.roomName,
|
|
message: 'This room has been closed'
|
|
})
|
|
|
|
this.clients.clear()
|
|
this.messages = []
|
|
}
|
|
|
|
connect(clientId: ClientUuid, broadcast: (data: any) => Promise<void>): void {
|
|
console.log(`[ChatRoom] Client ${clientId} joined '${this.roomName}'`)
|
|
this.clients.set(clientId, broadcast)
|
|
|
|
// Send welcome message to the new client
|
|
broadcast({
|
|
type: 'welcome',
|
|
message: `Welcome to ${this.roomName}!`,
|
|
currentUsers: this.clients.size,
|
|
messageHistory: this.messages.length
|
|
}).catch(err => console.error('[ChatRoom] Failed to send welcome:', err))
|
|
}
|
|
|
|
disconnect(clientId: ClientUuid): void {
|
|
console.log(`[ChatRoom] Client ${clientId} left '${this.roomName}'`)
|
|
this.clients.delete(clientId)
|
|
|
|
// Notify remaining clients
|
|
this.broadcastToAll({
|
|
type: 'userLeft',
|
|
clientId,
|
|
remainingUsers: this.clients.size
|
|
}).catch(err => console.error('[ChatRoom] Failed to broadcast user left:', err))
|
|
}
|
|
|
|
private async broadcastToAll(event: any): Promise<void> {
|
|
const promises = Array.from(this.clients.values()).map(handler =>
|
|
handler(event).catch(err =>
|
|
console.error('[ChatRoom] Failed to broadcast to client:', err)
|
|
)
|
|
)
|
|
await Promise.all(promises)
|
|
}
|
|
}
|
|
|
|
async function main(): Promise<void> {
|
|
console.log('=== Event Broadcasting Container Example ===\n')
|
|
|
|
// 1. Setup infrastructure
|
|
const tickManager = new TickManagerImpl(1)
|
|
tickManager.start()
|
|
const network = new NetworkImpl(tickManager)
|
|
const server = new NetworkServer(network, tickManager, '*', 3737)
|
|
console.log('✓ Network server started\n')
|
|
|
|
// 2. Create agent
|
|
const agent = new AgentImpl('chat-agent' as any, {
|
|
['chat-room' as ContainerKind]: async (options: GetOptions) => {
|
|
const roomName = options.labels?.[0] || 'general'
|
|
const uuid = options.uuid ?? `room-${roomName}-${Date.now()}` as ContainerUuid
|
|
const container = new ChatRoomContainer(uuid, roomName)
|
|
return {
|
|
uuid,
|
|
container,
|
|
endpoint: `chat://${roomName}/${uuid}` as any
|
|
}
|
|
}
|
|
})
|
|
|
|
const agentServer = new NetworkAgentServer(tickManager, 'localhost', '*', 3738)
|
|
await agentServer.start(agent)
|
|
console.log('✓ Agent server started\n')
|
|
|
|
// 3. Create multiple clients
|
|
const client1 = createNetworkClient('localhost:3737')
|
|
await client1.waitConnection(5000)
|
|
const client2 = createNetworkClient('localhost:3737')
|
|
await client2.waitConnection(5000)
|
|
const client3 = createNetworkClient('localhost:3737')
|
|
await client3.waitConnection(5000)
|
|
console.log('✓ Three clients connected\n')
|
|
|
|
// 4. Register agent
|
|
await client1.register(agent)
|
|
console.log('✓ Agent registered\n')
|
|
|
|
// 5. All clients join the same chat room
|
|
console.log('--- Clients joining chat room ---')
|
|
const chatRef1 = await client1.get('chat-room' as ContainerKind, {
|
|
uuid: 'room-general' as ContainerUuid,
|
|
labels: ['general']
|
|
})
|
|
|
|
const chatRef2 = await client2.get('chat-room' as ContainerKind, {
|
|
uuid: 'room-general' as ContainerUuid,
|
|
labels: ['general']
|
|
})
|
|
|
|
const chatRef3 = await client3.get('chat-room' as ContainerKind, {
|
|
uuid: 'room-general' as ContainerUuid,
|
|
labels: ['general']
|
|
})
|
|
console.log('✓ All clients have chat room references\n')
|
|
|
|
// 6. Create typed proxies for RPC calls (no need for explicit connect)
|
|
console.log('--- Creating typed proxies ---')
|
|
const chat1 = chatRef1.cast<ChatRoomService>()
|
|
const chat2 = chatRef2.cast<ChatRoomService>()
|
|
const chat3 = chatRef3.cast<ChatRoomService>()
|
|
console.log('✓ Created typed proxies\n')
|
|
|
|
// 7. Get room info
|
|
console.log('--- Room Information ---')
|
|
const info = await chat1.getRoomInfo()
|
|
console.log('Room:', info)
|
|
|
|
// 8. Send messages (these will be broadcast to all clients)
|
|
console.log('\n--- Sending messages ---')
|
|
const msg1 = await chat1.sendMessage('Alice', 'Hello everyone!')
|
|
console.log('Message 1:', msg1)
|
|
|
|
await new Promise(resolve => setTimeout(resolve, 100))
|
|
|
|
const msg2 = await chat2.sendMessage('Bob', 'Hi Alice!')
|
|
console.log('Message 2:', msg2)
|
|
|
|
await new Promise(resolve => setTimeout(resolve, 100))
|
|
|
|
const msg3 = await chat3.sendMessage('Charlie', 'Hey folks!')
|
|
console.log('Message 3:', msg3)
|
|
|
|
// 9. Get user count
|
|
console.log('\n--- User Count ---')
|
|
const userCount = await chat1.getUserCount()
|
|
console.log('Users in room:', userCount)
|
|
|
|
// 10. Get message history
|
|
console.log('\n--- Message History ---')
|
|
const history = await chat2.getHistory()
|
|
console.log('Total messages:', history.totalMessages)
|
|
history.messages.forEach((msg, idx) => {
|
|
console.log(` ${idx + 1}. [${new Date(msg.timestamp).toISOString()}] ${msg.username}: ${msg.text}`)
|
|
})
|
|
|
|
// 11. Cleanup
|
|
console.log('\n--- Cleanup ---')
|
|
await chatRef1.close()
|
|
await chatRef2.close()
|
|
await chatRef3.close()
|
|
await agentServer.close()
|
|
await server.close()
|
|
tickManager.stop()
|
|
|
|
console.log('✓ Example completed successfully!\n')
|
|
}
|
|
|
|
main().catch(console.error)
|