/**
 * Example usage of the JKMessageFactory in a React component
 * This demonstrates how to import and use the modern message factory
 */

import React, { useEffect } from 'react';
import { messageFactory, MessageType } from './MessageFactory';

// Example React component using the message factory
const MessageFactoryExample = () => {
  useEffect(() => {
    // Example: Create a heartbeat message
    const heartbeatMessage = messageFactory.heartbeat(123, '2023-01-01T00:00:00Z', true);
    console.log('Heartbeat message:', heartbeatMessage);

    // Example: Create a login message with token
    const loginMessage = messageFactory.loginWithToken('some-token', null, 'web');
    console.log('Login message:', loginMessage);

    // Example: Create a chat message
    const chatMessage = messageFactory.chatMessage('general', 'Hello world!');
    console.log('Chat message:', chatMessage);

    // Example: Subscribe to notifications
    const subscribeMessage = messageFactory.subscribe('session', 456);
    console.log('Subscribe message:', subscribeMessage);
  }, []);

  return (
    <div>
      <h3>JKMessageFactory Example</h3>
      <p>Check the console for example message outputs.</p>
      <p>The message factory is ready to be used in your React components for WebSocket communication.</p>
    </div>
  );
};

export default MessageFactoryExample;
