package kr.co.i4way.webocket.controller;

import java.util.Collection;
import java.util.Map;

import org.springframework.boot.autoconfigure.security.SecurityProperties.User;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
import org.springframework.messaging.simp.annotation.SendToUser;
import org.springframework.stereotype.Controller;
import org.springframework.web.util.HtmlUtils;

import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentGroup;

import kr.co.i4way.genesys.config.ConfigModule;
import kr.co.i4way.webocket.domain.Chat;
import kr.co.i4way.webocket.domain.Greeting;
import kr.co.i4way.webocket.domain.HelloMessage;

@Controller
public class GreetingController {
	ConfigModule cfg = new ConfigModule("172.168.30.2", "172.168.30.2", 2020, 2020, "default", "password", "cfg123", "MS949");
	  
	@MessageMapping("/hello")
	@SendToUser(value="/topic/greetings", broadcast=false)
	public Greeting greeting(HelloMessage message) throws Exception {
		return new Greeting("Hello, " + HtmlUtils.htmlEscape(message.getName()));
	}
	
//	@MessageMapping("/hello")
//	@SendToUser("/queue/greetings")
//	public Greeting info(HelloMessage message, SimpMessageHeaderAccessor messageHeaderAccessor) {
//		User talker = (User) messageHeaderAccessor.getSessionAttributes().get("currsession");
//		CfgAgentGroup ag = cfg.selectAgentGroups(Integer.parseInt(message.getName()), 101);
//		System.out.println(ag.toString());
//		return new Greeting("Hello, " + HtmlUtils.htmlEscape(ag.toString()));
//	}
}