package com.meancat.jabmud.component.xmpp;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.component.Component;
import org.xmpp.component.ComponentException;
import org.xmpp.component.ComponentManager;
import org.xmpp.packet.JID;
import org.xmpp.packet.Packet;

/**
 *
 */
public class MudComponent implements Component {
    private static final Logger logger = LoggerFactory.getLogger(MudComponent.class);

    @Override
    public String getName() {
        return "JabMud";
    }

    @Override
    public String getDescription() {
        return "Jabmud Component";
    }

    @Override
    public void processPacket(Packet packet) {
        logger.info("processPacket:\n{}", packet.toXML());
        // TODO!
    }

    @Override
    public void initialize(JID jid, ComponentManager componentManager) throws ComponentException {
        logger.info("Initialize: {}, {}", jid, componentManager);
    }

    @Override
    public void start() {
        logger.info("MudComponent Start!");
    }

    @Override
    public void shutdown() {
        logger.info("MudComponent shutdown!");
    }
}

@@ -124,91 +124,16 @@
 ent.
-Component;%0Aimport org.xmpp.component.ComponentException;%0Aimport org.xmpp.component.
+Abstract
 Comp
@@ -137,23 +137,16 @@
 omponent
-Manager
 ;%0Aimport
@@ -166,42 +166,15 @@
 ket.
-JID;%0Aimport org.xmpp.packet.Packet
+Message
 ;%0A%0A/
@@ -213,19 +213,24 @@
 ent 
-implement
+extend
 s 
+Abstract
 Comp
@@ -324,16 +324,17 @@
 lass);%0A%0A
+%0A
     @Ove
@@ -486,32 +486,33 @@
 ponent%22;%0A    %7D%0A%0A
+%0A
     @Override%0A  
@@ -529,493 +529,637 @@
 oid 
-processPacket(Packet packet) %7B%0A        logger.info(%22processPacket:%5Cn%7B%7D%22, packet.toXML());%0A        // TODO!%0A    %7D%0A%0A    @Override%0A    public void initialize(JID jid, ComponentManager componentManager) throws ComponentException %7B%0A        logger.info(%22Initialize: %7B%7D, %7B%7D%22, jid, componentManager
+start() %7B%0A        logger.info(%22MudComponent Start! My JID is %7B%7D and domain is %7B%7D%22, getJID(), getDomain());%0A    %7D%0A%0A    @Override%0A    protected void handleMessage(Message received) %7B%0A        logger.info(%22handleMessage:%5Cn%7B%7D%22, received.toXML());%0A        if (received.getType().equals(Message.Type.chat)) %7B%0A            Message response = new Message(
 );%0A    
-%7D%0A%0A
     
-@Override%0A    public void start() %7B%0A        logger.info(%22MudComponent Start!%22
+    response.setFrom(received.getTo());%0A            response.setTo(received.getFrom());%0A            response.setType(received.getType()
 );%0A    
-%7D%0A%0A
+    
     
-@Override%0A    public void shutdown() %7B%0A        logger.info(%22MudComponent shutdown!%22
+response.setThread(received.getThread());%0A%0A            response.setBody(%22Hi!%22);%0A            send(response
 );%0A    
-%7D
+    %7D%0A    %7D%0A
 %0A%7D%0A

use AbstractComponent instead