package com.yonge.netty.server.service;

import io.netty.channel.Channel;

import java.util.concurrent.ConcurrentHashMap;

import org.springframework.stereotype.Component;

import com.yonge.netty.dto.UserChannelContext;

@Component
public class UserChannelContextService {

	private ConcurrentHashMap<Channel, UserChannelContext> channelContextMap = new ConcurrentHashMap<Channel, UserChannelContext>();
	
	public boolean register(Channel channel,UserChannelContext userChannelContext){
		channelContextMap.put(channel, userChannelContext);
		return true;
	}
	
	public boolean remove(Channel channel){
		if(channel != null){
			channelContextMap.remove(channel);
		}
		return true;
	}
	
	public UserChannelContext getChannelContext(Channel channel){
		return channelContextMap.get(channel);
	}
	
}
