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


Java RemoteEndpoint类代码示例

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


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

示例1: send

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
@Override
public void send( final String message )
{
    final RemoteEndpoint endpoint = getRemote();
    if ( endpoint == null )
    {
        return;
    }

    try
    {
        endpoint.sendString( message );
    }
    catch ( final Exception e )
    {
        LOG.log( Level.SEVERE, "Failed to send web-socket message", e );
    }
}
 
开发者ID:purplejs,项目名称:purplejs,代码行数:19,代码来源:WebSocketSessionImpl.java

示例2: sendMessage

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
public boolean sendMessage(Message message) {
    try {
        RemoteEndpoint remote = session.getRemote();

        synchronized (remote) {
            try {
                remote.sendString(message.getBody());
                return true;
            } catch (Exception we) {
                System.out.println("[GameWebSocketHandler] Ошибка при отправке пакета (" + we.getMessage() + "). Дисконнектинг игрока.");
                return false;
            }
        }
    } catch (Exception e) {
        System.out.println("[GameWebSocketHandler] Ошибка при получении RemoteEndpoint (" + e.getMessage() + "). Дисконнектинг игрока.");
        return false;
    }
}
 
开发者ID:nbsp-team,项目名称:kurve-server,代码行数:19,代码来源:GameWebSocketHandler.java

示例3: newNodeVisible

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
@FiberOnly
private void newNodeVisible(NewNodeVisible nodeVisibilityMessage) {
  Availability availability = nodeVisibilityMessage.nodeInfo.availability;
  ByteArrayOutputStream jsonBytes = new ByteArrayOutputStream();
  try {
    JsonIOUtil.writeTo(jsonBytes, availability, availability, false);

    String jsonString = jsonBytes.toString();
    String finalString = "{\"type\":\"newNode\", \"data\": " + jsonString + "}";
    System.out.println(finalString);

    for (WebsocketClient client : websocketClients) {
      RemoteEndpoint wsRemote = client.getRemote();
      if (wsRemote != null) {
        client.getRemote().sendString(finalString);
      }
    }
  } catch (IOException e) {
    LOG.error("Processing new node visible message", e);
  }
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:22,代码来源:WebAdminService.java

示例4: setUp

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
@Before
public void setUp() {
    client = mock(GraqlClient.class);
    Session session = mock(Session.class);
    remote = mock(RemoteEndpoint.class);
    CompletableFuture<Session> future = new CompletableFuture<>();
    future.complete(session);

    when(client.connect(any(), any())).thenReturn(future);
    when(session.getRemote()).thenReturn(remote);
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:12,代码来源:JsonSessionTest.java

示例5: setUp

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	clientManager = new ClientManagerImpl(clientInformationHandler, singleDriverHandler);

	// mocking session
	session = mock(Session.class);
	remoteEndpoint = mock(RemoteEndpoint.class);
	when(session.getRemote()).thenReturn(remoteEndpoint);
	when(session.getRemoteAddress()).thenReturn(new InetSocketAddress(0));
	when(session.isOpen()).thenReturn(false);
}
 
开发者ID:weiss19ja,项目名称:amos-ss16-proj2,代码行数:12,代码来源:ClientManagerTest.java

示例6: send

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
public void send(WsContractDto contract) {
    if ((this.getSession() == null) || !this.getSession().isOpen()) {
        return;
    }

    RemoteEndpoint remoteEndpoint = this.getSession().getRemote();
    String jsonResult = this.jsonConverter.toJson(contract);
    remoteEndpoint.sendStringByFuture(jsonResult);
}
 
开发者ID:rndsolutions,项目名称:hawkcd,代码行数:10,代码来源:WSSocket.java

示例7: send

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
/**
 * Receives a WSSocket object and WsContractDto to write it to the stream
 *
 * @param session
 * @param contract
 */
public void send(WSSocket session, WsContractDto contract) {

    if (session != null && session.isConnected()) {
        RemoteEndpoint remoteEndpoint = session.getRemote();
        String jsonResult = this.jsonConverter.toJson(contract);

        remoteEndpoint.sendStringByFuture(jsonResult);
    }
}
 
开发者ID:rndsolutions,项目名称:hawkcd,代码行数:16,代码来源:SessionManager.java

示例8: getRemote

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
private RemoteEndpoint getRemote()
{
    try
    {
        return this.raw.getRemote();
    }
    catch ( final Exception e )
    {
        return null;
    }
}
 
开发者ID:purplejs,项目名称:purplejs,代码行数:12,代码来源:WebSocketSessionImpl.java

示例9: tabletStateChanges

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
@FiberOnly
private void tabletStateChanges(TabletStateChange tabletStateChange) {
  // TODO send to the websockets
  TabletStateNotification note = new TabletStateNotification(
      tabletStateChange.tablet.getRegionInfo().getEncodedName(),
      tabletStateChange.tablet.getRegionInfo().getRegionNameAsString(),
      tabletStateChange.state.toString(),
      tabletStateChange.tablet.getPeers(),
      0
  );
  ByteArrayOutputStream jsonBytes = new ByteArrayOutputStream();
  try {
    JsonIOUtil.writeTo(jsonBytes, note, note, false);

    String jsonString = jsonBytes.toString();
    String finalString = "{\"type\":\"tablet\", \"data\": " + jsonString + "}";
    System.out.println(finalString);

    for (WebsocketClient client : websocketClients) {
      RemoteEndpoint wsRemote = client.getRemote();
      if (wsRemote != null) {
        client.getRemote().sendString(finalString);
      }
    }
  } catch (IOException e) {
    LOG.error("Processing tablet message", e);
  }

}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:30,代码来源:WebAdminService.java

示例10: testProcess

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
@Test
public void testProcess() throws Exception {

	HttpRoutingContext routingContext = new HttpRoutingContext();
	HttpDmClient httpDmClient = new HttpDmClient( routingContext );

	// Not connected => no processing
	Message message = Mockito.mock( Message.class );
	Session session = Mockito.mock( Session.class );
	Mockito.when( session.isOpen()).thenReturn( false );

	httpDmClient.process( session, message );
	Mockito.verifyZeroInteractions( message );
	Mockito.verify( session, Mockito.only()).isOpen();

	// Connected => processing...
	Mockito.reset( session );
	Future<Void> future = Mockito.mock( Future.class );
	RemoteEndpoint remote = Mockito.mock( RemoteEndpoint.class );
	Mockito.when( remote.sendBytesByFuture( Mockito.any( ByteBuffer.class ) )).thenReturn( future );

	Mockito.when( session.getRemote()).thenReturn( remote );
	Mockito.when( session.isOpen()).thenReturn( true );

	httpDmClient.process( session, message );

	Mockito.verifyZeroInteractions( message );
	Mockito.verify( session, Mockito.times( 1 )).isOpen();
	Mockito.verify( session, Mockito.times( 1 )).getRemote();
	Mockito.verifyNoMoreInteractions( session );
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:32,代码来源:HttpDmClientTest.java

示例11: configuredHandler

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
private WebSocketHandler configuredHandler() {

		this.session = Mockito.mock( Session.class );
		this.remoteEndpoint = Mockito.mock( RemoteEndpoint.class );
		Mockito.when( this.session.getRemote()).thenReturn( this.remoteEndpoint );

		WebSocketHandler.addSession( this.session );
		WebSocketHandler handler = new WebSocketHandler();

		return handler;
	}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:12,代码来源:WebSocketHandlerTest.java

示例12: KafkaClient

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
public KafkaClient(String zooKeeper, String groupId, String topic, RemoteEndpoint remote) 
   {
       this.consumer = kafka.consumer.Consumer.createJavaConsumerConnector(
               createConsumerConfig(zooKeeper, groupId ));
       
       this.topic = topic;
       this.remote = remote;
}
 
开发者ID:OpenSOC,项目名称:opensoc-streaming,代码行数:9,代码来源:KafkaClient.java

示例13: send

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
/**
 * @param text
 *            the message to be sent
 * @throws IOException
 *             if unable to send the text message
 */
void send(String text) throws IOException {
	RemoteEndpoint remote = getRemote();
	if (remote != null) {
		// FIXME this log creates a recursion when using
		// the "log start -l debug" console command via WebSockets
		logger.debug("Sending: '{}' - Host: {}", text, hostname);
		remote.sendStringByFuture(text);
	}
}
 
开发者ID:sfera-labs,项目名称:sfera,代码行数:16,代码来源:ApiSocket.java

示例14: sendBytes

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
@Override
public void sendBytes(final ByteBuffer data, final SuccessCallback success,
    final OnError err) {
  requireNonNull(data, NO_DATA_TO_SEND);

  RemoteEndpoint remote = session.getRemote();
  remote.sendBytes(data, callback(log, success, err));
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:9,代码来源:JettyWebSocket.java

示例15: sendText

import org.eclipse.jetty.websocket.api.RemoteEndpoint; //导入依赖的package包/类
@Override
public void sendText(final String data, final SuccessCallback success, final OnError err) {
  requireNonNull(data, NO_DATA_TO_SEND);

  RemoteEndpoint remote = session.getRemote();
  remote.sendString(data, callback(log, success, err));
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:8,代码来源:JettyWebSocket.java


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