dialogBox = new DialogBox();
label = new Label();
dialogBox.add(label);
//TODO take the URL from user, as a parameter... if not provided, use the expression below as default
final String url = "ws://" + Window.Location.getHostName() + ":" + DEFAULT_COMPILER_NOTIFIER_PORT;
final WebSocket socket = WebSocket.createIfSupported(url);
if(socket == null)
{
logger.info("Browser do not support Websocket.");
return;
}
socket.addCloseHandler(new SocketCloseHandler()
{
@Override
public void onClose(SocketCloseEvent event)
{
logger.info("Compilation Notifier Socket was closed. Trying to reconnect...");
socket.reconnect();
}
});
socket.addOpenHandler(new SocketOpenHandler()
{
@Override
public void onOpen(SocketOpenEvent event)
{
if (LogConfiguration.loggingIsEnabled())
{
logger.log(Level.INFO, "Connected to Compilation Notifier service.");
}
}
});
socket.addErrorHandler(new SocketErrorHandler()
{
@Override
public void onError(SocketErrorEvent event)
{
if (LogConfiguration.loggingIsEnabled())
{
logger.log(Level.INFO, "Unexpected error on Compilation Notifier service socket.");
}
}
});
socket.addMessageHandler(new SocketMessageHandler()
{
@Override
public void onMessage(SocketMessageEvent event)
{
try