Hi,
I make a simply apps with gwt and on server-side I use Smack.
I want to create a button that when pressed is recorded in Openfire.
My problem is that not connect to Openfire
Client-side
SmackServiceAsync smackServiceAsync;
/**
* The entry point method, called automatically by loading a
module
* that declares an implementing class as an entry-point
*/
public void onModuleLoad() {
Button save = new Button("Click mei");
save.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
Window.alert("ho cliccato");
connect();
}
});
RootPanel.get().add(save);
}
public void connect(){
smackServiceAsync =(SmackServiceAsync) GWT.create
(SmackService.class);
ServiceDefTarget endpoint = (ServiceDefTarget)smackServiceAsync;
String serviceUrl = GWT.getModuleBaseURL() + "smackservice";
endpoint.setServiceEntryPoint(serviceUrl);
login("localhost", 5222, "smartsr.local", "smartsr",
"password");
}
private void login(String l, int port, String service, String
user, String password){
smackServiceAsync.connect(l, port, service, user,password, callback);
// create an async callback to handle the result.
AsyncCallback callback = new AsyncCallback(){
public void onSuccess(Object result){
}
public void onFailure(Throwable caught){
com.google.gwt.user.client.Window.alert("Failed to get
catalog");
}};
}
}
Service----
public interface SmackService extends RemoteService{
public void connect(String l ,int a, String service , String
user , String password);
}
ServiceAync----
-----------
Server Side-------
public class SmackServiceImpl extends RemoteServiceServlet implements
SmackService {
public void connect(String l, int port, String service, String
user, String pass) {
try {
ConnectionConfiguration config=new
ConnectionConfiguration(l, port, service);
XMPPConnection connection =new XMPPConnection(config);
connection.login( user, pass); // the error is
here...Not connected to server.
Presence presence = new Presence
(Presence.Type.available);
connection.sendPacket(presence);
}
catch(Exception e) {
System.out.println(e.getLocalizedMessage());
}
}
}
How do I do?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---