001/* 002 * GWTEventService 003 * Copyright (c) 2011 and beyond, strawbill UG (haftungsbeschr?nkt) 004 * 005 * This is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU Lesser General Public License as 007 * published by the Free Software Foundation; either version 3 of 008 * the License, or (at your option) any later version. 009 * Other licensing for GWTEventService may also be possible on request. 010 * Please view the license.txt of the project for more information. 011 * 012 * This software is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public 018 * License along with this software; if not, write to the Free 019 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 020 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 021 */ 022package de.novanic.eventservice.client.connection.strategy.connector.streaming.specific; 023 024import com.google.gwt.dom.client.Element; 025import com.google.gwt.user.client.ui.Frame; 026import com.google.gwt.user.client.ui.RootPanel; 027import de.novanic.eventservice.client.connection.strategy.connector.streaming.GWTStreamingClientConnector; 028 029/** 030 * The {@link de.novanic.eventservice.client.connection.strategy.connector.ConnectionStrategyClientConnector} listens for occurred events ({@link de.novanic.eventservice.client.event.Event}) 031 * of the server side and has the task to encode / process the transferred events at the client side. 032 * 033 * The {@link de.novanic.eventservice.client.connection.strategy.connector.streaming.specific.GWTStreamingClientConnectorGecko} is a 034 * Gecko / FF specific implementation of {@link de.novanic.eventservice.client.connection.strategy.connector.streaming.GWTStreamingClientConnector} which 035 * contains a special implementation to avoid loading messages / animations while streaming. 036 * 037 * @author sstrohschein 038 * <br>Date: 07.05.2010 039 * <br>Time: 23:29:33 040 */ 041public class GWTStreamingClientConnectorGecko extends GWTStreamingClientConnector 042{ 043 private static final Element DUMMY_FRAME_ELEMENT; 044 045 static { 046 DUMMY_FRAME_ELEMENT = createFrameElement(); 047 } 048 049 private static Element createFrameElement() { 050 Frame theDummyFrame = new Frame(); 051 theDummyFrame.setVisible(false); 052 final Element theDummyFrameElement = theDummyFrame.getElement(); 053 theDummyFrameElement.setId("gwteventservice_dummy_frame"); 054 return theDummyFrameElement; 055 } 056 057 /** 058 * That method can be used by a concrete implementation to sent received events. It de-serializes the event 059 * and notifies the callback and the {@link de.novanic.eventservice.client.event.listener.EventNotification} about the occurred 060 * event, itself. The callback is notified about events when the cycle ({@link de.novanic.eventservice.client.connection.strategy.connector.streaming.DefaultStreamingClientConnector#CYCLE_TAG}) 061 * is triggered. 062 * 063 * That implementation creates a dummy frame to avoid loading messages / animation while streaming. 064 * @param anEvent event or cycle tag ({@link de.novanic.eventservice.client.connection.strategy.connector.streaming.DefaultStreamingClientConnector#CYCLE_TAG}) 065 */ 066 public void receiveEvent(String anEvent) { 067 //Gecko / FF hack start (avoid loading messages) 068 RootPanel.getBodyElement().appendChild(DUMMY_FRAME_ELEMENT); 069 RootPanel.getBodyElement().removeChild(DUMMY_FRAME_ELEMENT); 070 //Gecko / FF hack end (avoid loading messages) 071 super.receiveEvent(anEvent); 072 } 073}