AnsweredAssumed Answered

Call with Openfire server (with Asterisk-im)

Question asked by mimmojabber on Sep 9, 2007
Latest reply on Sep 10, 2007 by mimmojabber

Hi all, help me!

 

On my LAN I have 192.168.0.4 with Asterisk server and 192.168.0.2 with Openfire Server.

 

Below it's the Asterisk-im page on console Openfire server:

screen1

 

 

My Phone Mappings is

screen2

 

I config manually the users (200 and 201). Is it right?

I create same users (200 and 201) in "User Summary" page on Openfire server.

 

Now, when I run the follow java code, it run correctly and "Connect" to Openfire (server: 192.168.0.2; username: 200; password: ***; Input: //empty ).

It's OK.

 

/**

 

  • $RCSfile: PhoneClientDebugger.java,v $

 

  • $Revision: 1.5 $

 

  • $Date: 2005/07/05 18:41:09 $

*

 

  • Copyright (C) 1999-2004 Jive Software. All rights reserved.

*

 

  • This software is the proprietary information of Jive Software. Use is subject to license terms.

*/

 

import org.jivesoftware.phone.client.Call;

import org.jivesoftware.phone.client.PhoneActionException;

import org.jivesoftware.phone.client.PhoneClient;

import org.jivesoftware.phone.client.PhoneEvent;

import org.jivesoftware.phone.client.PhoneEventListener;

import org.jivesoftware.phone.client.RingEvent;

import org.jivesoftware.phone.client.action.PhoneActionIQProvider;

import org.jivesoftware.phone.client.action.PhoneActionPacket;

import org.jivesoftware.phone.client.event.PhoneEventPacketExtension;

import org.jivesoftware.phone.client.event.PhoneEventPacketExtensionProvider;

import org.jivesoftware.smack.XMPPConnection;

import org.jivesoftware.smack.XMPPException;

import org.jivesoftware.smack.provider.ProviderManager;

 

import javax.swing.*;

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.util.logging.Level;

import java.util.logging.Logger;

 

/**

 

  • Useful for testing the client api, however the user interface is currenlty horrible. I want to fix this one day.

*

 

  • @author Andrew Wright

*/

public class PhoneClientDebugger extends JFrame implements ActionListener, PhoneEventListener {

 

    private static final Logger log = Logger.getLogger(PhoneClientDebugger.class.getName());

 

    static {

        //XMPPConnection.DEBUG_ENABLED = true;

 

        try {

 

            ProviderManager.getInstance().addExtensionProvider("phone-event",

                    PhoneEventPacketExtension.NAMESPACE,

                    new PhoneEventPacketExtensionProvider());

 

 

            ProviderManager.getInstance().addIQProvider("phone-action",

                    PhoneActionPacket.NAMESPACE,

                    new PhoneActionIQProvider());

        }

        catch (Exception e) {

            log.log(Level.SEVERE, e.getMessage(), e);

            throw new ExceptionInInitializerError(e);

        }

    }

 

    private PhoneClient client;

    private XMPPConnection conn;

 

    private JTextField input;

    private JTextField username;

    private JTextField password;

    private JTextField server;

    private Call call;

 

    public PhoneClientDebugger() throws Exception {

        super("Phone Client Debugger");

        getContentPane().setLayout(new BorderLayout());

        setSize(200, 150);

 

        getContentPane().add(buildForm());

        pack();

 

        setVisible(true);

    }

 

    private JComponent buildForm() {

 

        JPanel panel = new JPanel();

 

        panel.setLayout(new GridLayout(5, 2));

 

        JLabel label = new JLabel("Server");

        label.setHorizontalAlignment(JLabel.RIGHT);

        panel.add(label);

        server = new JTextField(20);

        panel.add(server);

 

        label = new JLabel("Username");

        label.setHorizontalAlignment(JLabel.RIGHT);

        panel.add(label);

        username = new JTextField(20);

        panel.add(username);

 

        label = new JLabel("Password");

        label.setHorizontalAlignment(JLabel.RIGHT);

        panel.add(label);

        password = new JTextField(20);

        panel.add(password);

 

        label = new JLabel("Input");

        label.setHorizontalAlignment(JLabel.RIGHT);

        panel.add(label);

        input = new JTextField(20);

        panel.add(input);

 

        Box buttonPanel = new Box(BoxLayout.X_AXIS);

        panel.add(buttonPanel);

 

        JButton button = new JButton("Connect");

        button.setActionCommand("connect");

        button.addActionListener(this);

        buttonPanel.add(button);

 

        button = new JButton("Disconnect");

        button.setActionCommand("disconnect");

        button.addActionListener(this);

        buttonPanel.add(button);

 

        button = new JButton("Exit");

        button.setActionCommand("exit");

        button.addActionListener(this);

        buttonPanel.add(button);

 

        buttonPanel = new Box(BoxLayout.X_AXIS);

        panel.add(buttonPanel);

 

        button = new JButton("Call");

        button.setActionCommand("call");

        button.addActionListener(this);

        buttonPanel.add(button);

 

        button = new JButton("Forward");

        button.setActionCommand("forward");

        button.addActionListener(this);

        buttonPanel.add(button);

 

        return panel;

    }

 

    public void handle(PhoneEvent event) {

 

        if(event instanceof  RingEvent ) {

 

            call = ((RingEvent) event).getCall();

 

        }

 

 

    }

 

 

    public void actionPerformed(ActionEvent e) {

 

        String command = e.getActionCommand();

 

        if ("call".equals(command)) {

 

            String extensionText = input.getText();

 

            if (extensionText != null && !"".equals(extensionText)) {

                try {

 

                    if(extensionText.indexOf("@") > -1) {

                        client.dialByJID(extensionText);

                    }

                    else {

                        client.dialByExtension(extensionText);

                    }

                }

                catch (PhoneActionException ex) {

                    log.log(Level.SEVERE, ex.getMessage(), ex);

                }

            }

 

 

        }

        else if ("connect".equals(command)) {

 

            try {

                conn = new XMPPConnection(server.getText());

                conn.connect();

                conn.login(username.getText(), password.getText());

                client = new PhoneClient(conn);

                client.addEventListener(this);

            }

            catch (XMPPException e1) {

                log.log(Level.SEVERE, e1.getMessage(), e1);

                throw new RuntimeException(e1);

            }

 

        }

        else if ("disconnect".equals(command)) {

 

            conn.disconnect();

 

        }

        else if ("exit".equals(command)) {

            try {

                conn.disconnect();

            }

            finally {

                System.exit(0);

            }

        }

        else if ("forward".equals(command)) {

 

            String extensionText = input.getText();

 

            if(call != null && extensionText != null && !"".equals(extensionText)) {

                try {

                    if(extensionText.indexOf("@") > -1) {

                        client.forwardByJID(call, extensionText);

                    }

                    else {

                        client.forward(call, extensionText);

                    }

                }

                catch (PhoneActionException e1) {

                    log.log(Level.SEVERE, e1.getMessage(), e1);

                }

            }

 

        }

 

    }

 

 

    public static void main(String[] args) {

        try {

            SwingUtilities.invokeAndWait(new Runnable() {

 

                public void run() {

                    try {

                        new PhoneClientDebugger();

                    }

                    catch (Exception e) {

                        log.log(Level.SEVERE, e.getMessage(), e);

                        System.exit(1);

                    }

                }

 

            });

        }

        catch (Exception e) {

            log.log(Level.SEVERE, e.getMessage(), e);

            System.exit(1);

        }

 

    }

 

}

 

But if I try "Call" by the same code, i have an error (in Eclipse IDE); it says:

 

9-set-2007 17.39.44 PhoneClientDebugger actionPerformed

GRAVE: No response received from the server

No response received from the server:

     at org.jivesoftware.phone.client.PhoneClient.dialByExtension(PhoneClient.java:117)

     at PhoneClientDebugger.actionPerformed(PhoneClientDebugger.java:172)

     at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)

     at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)

     at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

     at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)

     at java.awt.Component.processMouseEvent(Unknown Source)

     at javax.swing.JComponent.processMouseEvent(Unknown Source)

     at java.awt.Component.processEvent(Unknown Source)

     at java.awt.Container.processEvent(Unknown Source)

     at java.awt.Component.dispatchEventImpl(Unknown Source)

     at java.awt.Container.dispatchEventImpl(Unknown Source)

     at java.awt.Component.dispatchEvent(Unknown Source)

     at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

     at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

     at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

     at java.awt.Container.dispatchEventImpl(Unknown Source)

     at java.awt.Window.dispatchEventImpl(Unknown Source)

     at java.awt.Component.dispatchEvent(Unknown Source)

     at java.awt.EventQueue.dispatchEvent(Unknown Source)

     at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

     at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

     at java.awt.EventDispatchThread.run(Unknown Source)

 

Obviously, the call doesn't run (Input: 201@192.168.0.2 /or/ Input: 201).

 

Why? What's wrong? I believe the problem is in configuration or integration server Openfire/Asterisk. But where?

Help me, please.

Outcomes