How to use the JoinRoom method

In wildfire there is a class called JoinRoom.

The sample code of deploying it is as below:

// Join an existing room or create a new one.

JoinRoom joinRoom = new JoinRoom("john@jabber.org/notebook", "room@conference.jabber.org/nick");

component.sendPacket(joinRoom);

I tried to use the code but was prompt error for “component” as it is not declared. Error is as below

ReplyBotPlugin.java:73: cannot find symbol

symbol : variable component

location: class com.wildfire.plugins.ReplyBotPlugin

component.sendPacket(joinRoom);

^

1 error

Can someone advise on how to declare the “component” so that i can make use of its method sendPacket(joinRoom) ???

Message was edited by: Geordie

anyone can help with this???

Hi,

is the code / plugin you are writing a component? Take a look at one of the plugins, they use code like

componentManager = ComponentManagerFactory.getComponentManager();

componentManager.addComponent(serviceName, this);

LG

Im currently trying to write a plugin. What it does is that when a person entered a certain keyword, i.e. “Help”, then another agent, (agent 2) from the same workgroup will automatically be invited into the chatroom.

Hence originally the chatroom has 1 customer and 1 agent(agent1). After inviting, the inviting, agent 2 will also be in the chatroom.

package com.wildfire.plugins;

import org.jivesoftware.wildfire.container.Plugin;

import org.jivesoftware.wildfire.container.PluginManager;

import org.xmpp.component.Component;

import org.xmpp.component.ComponentException;

import org.xmpp.component.ComponentManager;

import org.xmpp.component.ComponentManagerFactory;

import org.xmpp.packet.*;

import org.xmpp.muc.JoinRoom;

import org.jivesoftware.wildfire.muc.MUCRoom;

import org.jivesoftware.wildfire.muc.MUCRole;

import org.jivesoftware.wildfire.muc.MultiUserChatServer;

import java.io.File;

import java.util.List;

/**

  • A wildfire plugin to provide an bot which can respond to requests for weather data.

  • The weather data is gotten via a WeatherInfo component.

*/

public class ReplyBotPlugin implements Plugin, Component {

private static final String COMPONENT_NAME = “callcenter”;

public void initializePlugin(PluginManager manager, File pluginDirectory) {

ComponentManager componentManager = getComponentManager();

try {

componentManager.addComponent(COMPONENT_NAME, this);

}

catch (Exception e) {

componentManager.getLog().error(e);

}

}

public void destroyPlugin() {

ComponentManager componentManager = getComponentManager();

try {

componentManager.removeComponent(COMPONENT_NAME);

}

catch (Exception e) {

componentManager.getLog().error(e);

}

}

private ComponentManager getComponentManager() {

return ComponentManagerFactory.getComponentManager();

}

public String getName() {

return COMPONENT_NAME;

}

public String getDescription() {

return “AutoReply Bot”;

}

public void processPacket(Packet packet) {

if (packet instanceof Message) {

// Respond to incoming messages

Message message = (Message) packet;

processMessage(message);

//Component component = Component.initialize(packet.getTo(), getComponentManager()) ;

String conf = packet.getTo().toString();

{color:#ff0000}// Join an existing room or create a new one.

JoinRoom joinRoom = new JoinRoom(“helpdesk1@tzechyntan2004/Spark”, conf);

component.sendPacket(joinRoom);

} else if (packet instanceof Presence) {

// Respond to presence subscription request or presence probe

Presence presence = (Presence) packet;

processPresence(presence);

} else if (packet instanceof IQ) {

// Handle disco packets

IQ iq = (IQ) packet;

// Ignore IQs of type ERROR or RESULT

if (IQ.Type.error == iq.getType() || IQ.Type.result == iq.getType()) {

return;

}

processIQ(iq);

}

}

private void processIQ(IQ iq) {

//todo handle disco packets.

}

private void processPresence(Presence presence) {

try {

if (Presence.Type.subscribe == presence.getType()) {

// Accept all presence requests if user has permissions

// Reply that the subscription request was approved or rejected

Presence reply = new Presence();

reply.setTo(presence.getFrom());

reply.setFrom(presence.getTo());

reply.setType(Presence.Type.subscribed);

getComponentManager().sendPacket(this, reply);

} else if (Presence.Type.unsubscribe == presence.getType()) {

// Send confirmation of unsubscription

Presence reply = new Presence();

reply.setTo(presence.getFrom());

reply.setFrom(presence.getTo());

reply.setType(Presence.Type.unsubscribed);

getComponentManager().sendPacket(this, reply);

} else if (Presence.Type.probe == presence.getType()) {

// Send that the service is available

Presence reply = new Presence();

reply.setTo(presence.getFrom());

reply.setFrom(presence.getTo());

getComponentManager().sendPacket(this, reply);

}

}

catch (ComponentException e) {

getComponentManager().getLog().error(e);

}

}

private void processMessage(Message message) {

//ignore any non-body message. The bot doesn’'t need to know that someone might be typing.

if (message.getBody() != null && message.getBody().length() > 0) {

Message response = new Message();

response.setSubject(message.getSubject());

response.setThread(message.getThread());

response.setType(message.getType());

response.setTo(message.getFrom());

response.setFrom(message.getTo());

response.setBody(“This is a autogenerated reply”);

try {

getComponentManager().sendPacket(this, response);

} catch (ComponentException e) {

getComponentManager().getLog().error(“failed to respond to message.”, e);

}

}

}

public void initialize(JID jid, ComponentManager componentManager) throws ComponentException {

}

public void start() {

}

public void shutdown() {

}

}

Message was edited by: Geordie