Ziya/electron/handlers/redis-handlers.ts
rizary 67fb3a203e
feat: implement CEX analysis cards and real-time token monitoring
- Add TokenCard and CexAnalysisCard components for displaying token data
- Implement real-time Redis event streaming for token updates
- Add environment-based configuration system for dev/prod Redis servers
- Create comprehensive hunting ground dashboard with card management
- Add individual and bulk card removal functionality
- Implement browser integration for token details viewing
- Add timestamp utilities and proper type handling for Redis events
- Create production-ready configuration with 154.38.185.112 Redis server
- Add comprehensive documentation in README.md and CONTRIBUTORS.md
- Restructure project architecture with proper Electron-Vue integration

BREAKING CHANGE: Redis configuration now uses environment-based settings
2025-06-23 09:03:39 +07:00

66 lines
1.7 KiB
TypeScript

import type { BrowserWindow } from 'electron';
interface RedisMessageData {
channel: string;
data: unknown;
timestamp: number;
}
/**
* Handle new token created events
*/
export function handleNewTokenCreated(mainWindow: BrowserWindow, data: unknown): void {
const messageData: RedisMessageData = {
channel: 'new_token_created',
data,
timestamp: Date.now(),
};
mainWindow.webContents.send('redis-data', messageData);
// console.info('Handled new token created:', data);
}
/**
* Handle token CEX updated events
*/
export function handleTokenCexUpdated(mainWindow: BrowserWindow, data: unknown): void {
const messageData: RedisMessageData = {
channel: 'token_cex_updated',
data,
timestamp: Date.now(),
};
mainWindow.webContents.send('redis-data', messageData);
// console.info('Handled token CEX updated:', data);
}
/**
* Handle max depth reached events
*/
export function handleMaxDepthReached(mainWindow: BrowserWindow, data: unknown): void {
const messageData: RedisMessageData = {
channel: 'max_depth_reached',
data,
timestamp: Date.now(),
};
mainWindow.webContents.send('redis-data', messageData);
// console.info('Handled max depth reached:', data);
}
/**
* Get the appropriate handler for a Redis channel
*/
export function getRedisChannelHandler(channel: string): ((mainWindow: BrowserWindow, data: unknown) => void) | null {
switch (channel) {
case 'new_token_created':
return handleNewTokenCreated;
case 'token_cex_updated':
return handleTokenCexUpdated;
case 'max_depth_reached':
return handleMaxDepthReached;
default:
console.warn(`No handler found for Redis channel: ${channel}`);
return null;
}
}