当前位置: 首页>>代码示例>>Java>>正文


Java WebPoller类代码示例

本文整理汇总了Java中org.realityforge.gwt.webpoller.client.WebPoller的典型用法代码示例。如果您正苦于以下问题:Java WebPoller类的具体用法?Java WebPoller怎么用?Java WebPoller使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WebPoller类属于org.realityforge.gwt.webpoller.client包,在下文中一共展示了WebPoller类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MessageEvent

import org.realityforge.gwt.webpoller.client.WebPoller; //导入依赖的package包/类
public MessageEvent( @Nonnull final WebPoller webPoller,
                     @Nonnull final Map<String,String> context,
                     @Nonnull final String data )
{
  super( webPoller );
  _context = Collections.unmodifiableMap( context );
  _data = data;
}
 
开发者ID:realityforge,项目名称:gwt-webpoller,代码行数:9,代码来源:MessageEvent.java

示例2: onMessage

import org.realityforge.gwt.webpoller.client.WebPoller; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public final void onMessage( @Nonnull final WebPoller webPoller,
                             @Nonnull final Map<String, String> context,
                             @Nonnull final String data )
{
  _eventBus.fireEventFromSource( new MessageEvent( webPoller, context, data ), webPoller );
}
 
开发者ID:realityforge,项目名称:gwt-webpoller,代码行数:11,代码来源:EventBasedWebPollerListener.java

示例3: onModuleLoad

import org.realityforge.gwt.webpoller.client.WebPoller; //导入依赖的package包/类
public void onModuleLoad()
{
  final WebPoller webPoller = WebPoller.newWebPoller();
  webPoller.setRequestFactory( this );
  registerListeners( webPoller );

  _start = new Button( "Start", new ClickHandler()
  {
    @Override
    public void onClick( final ClickEvent event )
    {
      _start.setEnabled( false );
      _longPoll.setEnabled( false );
      _longErrorBackOff.setEnabled( false );
      webPoller.setLogLevel( Level.INFO );
      webPoller.setInterRequestDuration( _longPoll.getValue() == Boolean.TRUE ? 0 : 2000 );
      webPoller.setInterErrorDuration( _longErrorBackOff.getValue() == Boolean.TRUE ? 5000 : 0 );
      webPoller.start();
    }
  } );
  _stop = new Button( "Stop", new ClickHandler()
  {
    @Override
    public void onClick( ClickEvent event )
    {
      webPoller.stop();
      _stop.setEnabled( false );
    }
  } );
  _stop.setEnabled( false );

  _longPoll = new CheckBox( "Long Poll" );
  _longErrorBackOff = new CheckBox( "Error Backoff" );

  _messages = new HTML();
  _scrollPanel = new ScrollPanel();
  _scrollPanel.setHeight( "250px" );
  _scrollPanel.add( _messages );
  RootPanel.get().add( _scrollPanel );

  {
    final FlowPanel controls = new FlowPanel();
    controls.add( _longPoll );
    controls.add( _longErrorBackOff );
    controls.add( _start );
    controls.add( _stop );
    RootPanel.get().add( controls );
  }
}
 
开发者ID:realityforge,项目名称:gwt-webpoller-example,代码行数:50,代码来源:Example.java

示例4: WebPollerEvent

import org.realityforge.gwt.webpoller.client.WebPoller; //导入依赖的package包/类
protected WebPollerEvent( @Nonnull final WebPoller webPoller )
{
  _webPoller = webPoller;
}
 
开发者ID:realityforge,项目名称:gwt-webpoller,代码行数:5,代码来源:WebPollerEvent.java

示例5: getWebPoller

import org.realityforge.gwt.webpoller.client.WebPoller; //导入依赖的package包/类
@Nonnull
public final WebPoller getWebPoller()
{
  return _webPoller;
}
 
开发者ID:realityforge,项目名称:gwt-webpoller,代码行数:6,代码来源:WebPollerEvent.java

示例6: onStart

import org.realityforge.gwt.webpoller.client.WebPoller; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public final void onStart( @Nonnull final WebPoller webPoller )
{
  _eventBus.fireEventFromSource( new StartEvent( webPoller ), webPoller );
}
 
开发者ID:realityforge,项目名称:gwt-webpoller,代码行数:9,代码来源:EventBasedWebPollerListener.java

示例7: onStop

import org.realityforge.gwt.webpoller.client.WebPoller; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public final void onStop( @Nonnull final WebPoller webPoller )
{
  _eventBus.fireEventFromSource( new StopEvent( webPoller ), webPoller );
}
 
开发者ID:realityforge,项目名称:gwt-webpoller,代码行数:9,代码来源:EventBasedWebPollerListener.java

示例8: onError

import org.realityforge.gwt.webpoller.client.WebPoller; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public final void onError( @Nonnull final WebPoller webPoller, @Nonnull final Throwable exception )
{
  _eventBus.fireEventFromSource( new ErrorEvent( webPoller, exception ), webPoller );
}
 
开发者ID:realityforge,项目名称:gwt-webpoller,代码行数:9,代码来源:EventBasedWebPollerListener.java

示例9: ErrorEvent

import org.realityforge.gwt.webpoller.client.WebPoller; //导入依赖的package包/类
public ErrorEvent( @Nonnull final WebPoller webPoller, @Nonnull final Throwable exception )
{
  super( webPoller );
  _exception = exception;
}
 
开发者ID:realityforge,项目名称:gwt-webpoller,代码行数:6,代码来源:ErrorEvent.java

示例10: StartEvent

import org.realityforge.gwt.webpoller.client.WebPoller; //导入依赖的package包/类
public StartEvent( @Nonnull final WebPoller webPoller )
{
  super( webPoller );
}
 
开发者ID:realityforge,项目名称:gwt-webpoller,代码行数:5,代码来源:StartEvent.java

示例11: StopEvent

import org.realityforge.gwt.webpoller.client.WebPoller; //导入依赖的package包/类
public StopEvent( @Nonnull final WebPoller webPoller )
{
  super( webPoller );
}
 
开发者ID:realityforge,项目名称:gwt-webpoller,代码行数:5,代码来源:StopEvent.java

示例12: newWebPoller

import org.realityforge.gwt.webpoller.client.WebPoller; //导入依赖的package包/类
@Nonnull
@Override
public WebPoller newWebPoller()
{
  return new TimerBasedWebPoller( _service );
}
 
开发者ID:realityforge,项目名称:gwt-webpoller,代码行数:7,代码来源:TimerBasedWebPoller.java

示例13: doStart

import org.realityforge.gwt.webpoller.client.WebPoller; //导入依赖的package包/类
protected void doStart()
{
  final String baseURL = getBaseURL();

  switch ( getStrategy() )
  {
    case EVENTSOURCE:
      if ( EventSource.isSupported() )
      {
        _eventSource = EventSource.newEventSourceIfSupported();
        _eventSource.open( baseURL + "api/time" );
        registerListeners( _eventSource );
      }
      else
      {
        throw new IllegalStateException( getStrategy() + " strategy not supported" );
      }
      break;
    case WEBSOCKET:
      if ( WebSocket.isSupported() )
      {
        _webSocket = WebSocket.newWebSocketIfSupported();
        _webSocket.connect( baseURL.replaceFirst( "^http\\:", "ws:" ) + "api/wstime" );
        registerListeners( _webSocket );
      }
      else
      {
        throw new IllegalStateException( getStrategy() + " strategy not supported" );
      }
      break;
    case POLL:
    {
      final RequestBuilder requestBuilder = new RequestBuilder( RequestBuilder.GET, baseURL + "api/time/poll" );
      _webPoller = WebPoller.newWebPoller();
      _webPoller.setRequestFactory( new HttpRequestFactory( requestBuilder ) );
      registerListeners( _webPoller );
      _webPoller.setInterRequestDuration( 0 );
      _webPoller.start();
    }
    break;

    default:
    {
      throw new IllegalStateException( getStrategy() + " strategy not supported" );
    }
  }
  if ( !isActive() )
  {
    throw new IllegalStateException( "Unable to initiate connection" );
  }
}
 
开发者ID:realityforge,项目名称:gwt-packetio-example,代码行数:52,代码来源:PacketIO.java


注:本文中的org.realityforge.gwt.webpoller.client.WebPoller类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。