Skip to content

MassageΒ #35915

@Ghaliashiru

Description

@Ghaliashiru

Description

<title>SpaChat - Wellness Messaging</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; }
    body {
        font-family: 'Arial', sans-serif;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .chat-container {
        width: 400px;
        height: 600px;
        background: rgba(255, 255, 255, 0.95);
        border-radius: 20px;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .chat-header {
        background: linear-gradient(45deg, #ff6b6b, #ffa502);
        color: white;
        padding: 20px;
        text-align: center;
        font-size: 1.5em;
        font-weight: bold;
    }
    
    .chat-messages {
        flex: 1;
        padding: 20px;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    .message {
        max-width: 70%;
        padding: 12px 16px;
        border-radius: 20px;
        animation: fadeIn 0.3s ease;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(10px); }
        to { opacity: 1; transform: translateY(0); }
    }
    
    .received {
        background: #e3f2fd;
        align-self: flex-start;
        border-bottom-left-radius: 5px;
    }
    
    .sent {
        background: #4caf50;
        color: white;
        align-self: flex-end;
        border-bottom-right-radius: 5px;
    }
    
    .chat-input {
        display: flex;
        padding: 20px;
        background: white;
        border-top: 1px solid #eee;
    }
    
    .chat-input input {
        flex: 1;
        padding: 12px 16px;
        border: 2px solid #e0e0e0;
        border-radius: 25px;
        outline: none;
        font-size: 16px;
    }
    
    .chat-input input:focus {
        border-color: #4caf50;
    }
    
    .chat-input button {
        margin-left: 10px;
        padding: 12px 20px;
        background: #4caf50;
        color: white;
        border: none;
        border-radius: 25px;
        cursor: pointer;
        font-weight: bold;
        transition: background 0.3s;
    }
    
    .chat-input button:hover {
        background: #45a049;
    }
    
    .timestamp {
        font-size: 0.7em;
        opacity: 0.7;
        margin-top: 5px;
        text-align: right;
    }
    
    .typing-indicator {
        display: none;
        padding: 10px;
        color: #666;
        font-style: italic;
    }
</style>
🌿 SpaChat Wellness
    <div class="chat-messages" id="chatMessages">
        <div class="message received">
            Welcome to SpaChat! 🌸<br>
            How can I help you today?<br>
            <span class="timestamp">Just now</span>
        </div>
    </div>
    
    <div class="typing-indicator" id="typingIndicator">πŸ’¬ Assistant is typing...</div>
    
    <div class="chat-input">
        <input type="text" id="messageInput" placeholder="Type your wellness message..." maxlength="200">
        <button onclick="sendMessage()">Send</button>
    </div>
</div>

<script>
    const chatMessages = document.getElementById('chatMessages');
    const messageInput = document.getElementById('messageInput');
    const typingIndicator = document.getElementById('typingIndicator');
    
    // Wellness responses database
    const wellnessResponses = [
        "That sounds wonderful! 🌟 Take a deep breath and relax.",
        "Your wellness journey is important! πŸ’š",
        "I'm here to support your self-care routine. 🌸",
        "Remember to hydrate and take breaks! πŸ’§",
        "You deserve all the peace and tranquility. πŸ•ŠοΈ",
        "Mindfulness is a beautiful practice. ✨",
        "Your mental health matters deeply. πŸ’™",
        "Let's create a calm space together. 🌿",
        "Every small step toward wellness counts! 🌱",
        "You're doing great on your journey! 🎯"
    ];
    
    const spaServices = [
        "πŸ’†β€β™€οΈ Massage Therapy",
        "🌸 Aromatherapy",
        "πŸ•―οΈ Candlelight Meditation",
        "πŸ§˜β€β™€οΈ Yoga Sessions",
        "🍡 Herbal Tea Consultation",
        "πŸŒ™ Sleep Wellness Program"
    ];
    
    function getCurrentTime() {
        return new Date().toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
    }
    
    function addMessage(text, isSent = false) {
        const messageDiv = document.createElement('div');
        messageDiv.className = `message ${isSent ? 'sent' : 'received'}`;
        messageDiv.innerHTML = `${text}<br><span class="timestamp">${getCurrentTime()}</span>`;
        chatMessages.appendChild(messageDiv);
        chatMessages.scrollTop = chatMessages.scrollHeight;
    }
    
    function showTyping() {
        typingIndicator.style.display = 'block';
        chatMessages.scrollTop = chatMessages.scrollHeight;
    }
    
    function hideTyping() {
        typingIndicator.style.display = 'none';
    }
    
    function getWellnessResponse(userMessage) {
        const lowerMessage = userMessage.toLowerCase();
        
        if (lowerMessage.includes('hello') || lowerMessage.includes('hi') || lowerMessage.includes('hey')) {
            return "Hello there! 🌺 Welcome to our wellness space. How are you feeling today?";
        }
        
        if (lowerMessage.includes('stress') || lowerMessage.includes('tired') || lowerMessage.includes('exhausted')) {
            return "I understand. Let's take a moment for yourself. 🌼 Would you like to hear about our relaxation services?";
        }
        
        if (lowerMessage.includes('massage') || lowerMessage.includes('spa') || lowerMessage.includes('relax')) {
            const service = spaServices[Math.floor(Math.random() * spaServices.length)];
            return `We offer ${service}! Our therapists are here to help you unwind. πŸ§˜β€β™€οΈ`;
        }
        
        if (lowerMessage.includes('thank')) {
            return "You're very welcome! πŸ™ Remember, taking care of yourself is not selfishβ€”it's essential. πŸ’š";
        }
        
        if (lowerMessage.includes('bye') || lowerMessage.includes('goodbye')) {
            return "Sending you peaceful vibes! πŸŒ™ Take care and come back whenever you need wellness support. 🌸";
        }
        
        // Random wellness response
        return wellnessResponses[Math.floor(Math.random() * wellnessResponses.length)];
    }
    
    async function sendMessage() {
        const message = messageInput.value.trim();
        if (!message) return;
        
        // Add user message
        addMessage(message, true);
        messageInput.value = '';
        
        // Show typing indicator
        showTyping();
        
        // Simulate thinking time
        await new Promise(resolve => setTimeout(resolve, 1000 + Math.random() * 2000));
        
        // Get and add response
        hideTyping();
        const response = getWellnessResponse(message);
        addMessage(response);
    }
    
    // Allow Enter key to send
    messageInput.addEventListener('keypress', function(e) {
        if (e.key === 'Enter') {
            sendMessage();
        }
    });
    
    // Add some ambient messages to make it feel alive
    setTimeout(() => {
        addMessage("🌱 Just a gentle reminder: Your wellness journey is unique and beautiful. Take it one breath at a time.");
    }, 3000);
    
    setTimeout(() => {
        addMessage("πŸ•―οΈ Creating calm spaces for your mind and soul. How can we support your peace today?");
    }, 8000);
</script>

[Enter feedback here]

Page URL

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/websockets?view=aspnetcore-9.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/websockets.md

Document ID

762efeed-010e-f422-03d0-22d6681b2851

Platform Id

3e06aef0-84df-6106-fb9c-2d43e7e95d19

Article author

@wadepickett

Metadata

  • ID: a3b0cac1-adc7-434c-d867-6e28e39bdae7
  • PlatformId: 3e06aef0-84df-6106-fb9c-2d43e7e95d19
  • Service: aspnet-core
  • Sub-service: fundamentals

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions