Button b = new Button("Send hello to 127.0.0.1:100");
b.addClickListener(new ClickListener(){
public void onClick(Widget sender)
{
final Socket socketToApp1 = new Socket("127.0.0.1",100);
socketToApp1.setSocketCallback( new SocketCallback()
{
// data = "DOMLocation;proxy"
public void onDataReceived(String data)
{
Debug.log(1, "hey I received: " + data);
}
public void onConnected()
{
Debug.log(1, "Connected to 127.0.0.1:100!");
socketToApp1.send("Hello Mr. 127.0.0.1:100");
}
public void onDisconnected(String message)
{
Window.alert("Discunnected : "+ message );
}
});
}
});
RootPanel.get().add(b);
}
if(RootPanel.get("type-mashup-app1") != null )
{
Button b = new Button("Make me bigger!");
b.addClickListener(new ClickListener(){
public void onClick(Widget sender)
{
setSize("100%", "50%");
}
});
RootPanel.get().add(b);
ServerSocket ss = new ServerSocket(100);
ss.accept(new ServerSocketCallback()
{
public void onConnectionAccepted(final Socket s)
{
s.setSocketCallback(new SocketCallback()
{
public void onDisconnected(String msg)
{
}
// request: "domain name" response "DOMAddress;proxyURL"
public void onDataReceived(String data)
{
// for now, assume it is ProxyDNSEntry
//Window.alert("Mashup App1 received data :"+data);
Debug.log(1,"Received data ( "+data+")"+ " from " +s.getEndpointDomainName());
s.send("Echoing :"+ data);
}
// TODO does not get called for server side
public void onConnected()
{
}
}
);
}
public void onError(String s)
{
}
}
);
}
if(RootPanel.get("type-mashup-app2") != null )
{
Button b = new Button("Send hello to 127.0.0.1:100");
RootPanel.get().add(b);
b.addClickListener(new ClickListener(){
public void onClick(Widget sender)
{
final Socket socketToApp1 = new Socket("127.0.0.1",100);
socketToApp1.setSocketCallback( new SocketCallback()
{
// data = "DOMLocation;proxy"
public void onDataReceived(String data)
{
Debug.log(1, "Hey I received: " + data);
socketToApp1.close();
}
public void onConnected()
{
Debug.log(1, "Connected to 127.0.0.1:100!");
socketToApp1.send("Hello Mr. 127.0.0.1:100");
}
public void onDisconnected(String message)
{
Window.alert("Discunnected : "+ message );