Java Code Examples for io.netty.channel.Channel#id()

The following examples show how to use io.netty.channel.Channel#id() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SubscriptionManager.java    From esjc with MIT License 6 votes vote down vote up
public void startSubscription(SubscriptionItem item, Channel connection) {
    checkNotNull(connection, "connection is null");

    if (item.isSubscribed) {
        logger.debug("StartSubscription REMOVING due to already subscribed {}.", item);
        removeSubscription(item);
        return;
    }

    item.correlationId = UUID.randomUUID();
    item.connectionId = connection.id();
    item.lastUpdated.update();

    activeSubscriptions.put(item.correlationId, item);

    if (!item.operation.subscribe(item.correlationId, connection)) {
        logger.debug("StartSubscription REMOVING AS COULD NOT SUBSCRIBE {}.", item);
        removeSubscription(item);
    } else {
        logger.debug("StartSubscription SUBSCRIBING {}.", item);
    }
}
 
Example 2
Source File: ChannelUtils.java    From zuul with Apache License 2.0 6 votes vote down vote up
public static String channelInfoForLogging(Channel ch)
{
    if (ch == null) {
        return "null";
    }
    
    String channelInfo = ch.toString() 
            + ", active=" + ch.isActive()
            + ", open=" + ch.isOpen()
            + ", registered=" + ch.isRegistered()
            + ", writable=" + ch.isWritable()
            + ", id=" + ch.id();
    
    CurrentPassport passport = CurrentPassport.fromChannel(ch);
    return "Channel: " + channelInfo + ", Passport: " + String.valueOf(passport);
}
 
Example 3
Source File: DefaultChannelListener.java    From bitchat with Apache License 2.0 5 votes vote down vote up
@Override
public void channelInactive(Channel channel) {
    ChannelId channelId = channel.id();
    channelManager.removeChannel(channelId);
    sessionManager.removeSession(channelId);
    SessionHelper.markOffline(channel);
    log.info("Remove an inactive Channel={}", channel);
}
 
Example 4
Source File: OperationManager.java    From esjc with MIT License 5 votes vote down vote up
private void send(OperationItem item, Channel connection) {
    item.connectionId = connection.id();
    item.lastUpdated.update();
    activeOperations.put(item.correlationId, item);

    TcpPackage tcpPackage = item.operation.create(item.correlationId);

    logger.debug("send package {}, {}, {}.", tcpPackage.command, tcpPackage.correlationId, item);

    connection.writeAndFlush(tcpPackage);
}
 
Example 5
Source File: AbstractNettyService.java    From sailfish-core with Apache License 2.0 4 votes vote down vote up
public void onExceptionCaught(Channel channel, Throwable cause) {
    String message = "Exception caught in netty's pipeline in channel " + channel.id();
    changeStatus(ServiceStatus.ERROR, message, cause);
    stop(message, cause);
}
 
Example 6
Source File: ActiveMQChannelHandler.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
protected static Object channelId(Channel channel) {
   return channel.id();
}
 
Example 7
Source File: LoginService.java    From ChatServer with Artistic License 2.0 3 votes vote down vote up
/**
 * 접속 사용자 정보 제거
 *
 * @param channel Netty 채널
 */
public void removeUser(Channel channel) {

	ChannelId channelId = channel.id();
	Map<ChannelId, String> channelIdUserIdMap = channelIdUserIdRepository.getChannelIdUserIdMap();
	String userId = channelIdUserIdMap.get(channelId);

	// 사용자 정보 제거
	if (!StringUtils.isEmpty(userId)) {

		userIdChannelRepository.getUserIdChannelMap().remove(userId);

		String roomId = userIdRoomIdRepository.getUserIdRoomIdMap().get(userId);

		// 룸 정보 제거
		if (!StringUtils.isEmpty(roomId)) {

			roomIdUserIdRepository.getRoomIdUserIdMap().remove(roomId, userId);
			userIdRoomIdRepository.getUserIdRoomIdMap().remove(userId);

		}

		channelIdUserIdMap.remove(channelId);

	}

}