Author Topic: Chat Desktop - Help  (Read 4134 times)

Offline persmen

  • Newbie
  • *
  • Posts: 18
  • Karma: 2
  • Kemal KUCUKTASCI
Chat Desktop - Help
« on: August 20, 2010, 08:55:27 AM »
Hi;

    I'm using Platform SDK for development and im new for this SDK. I need some information about chat desktop development. I wrote some code, and test Connection, login, ready and invite. Everythings fine in ccpulse and log files. But desktop cannot take any event. EventAgentLogin or EventInvite. I think, i'm doing right thing explained in documents. But i dont understand what is problem.

    In application i'm craete a QueueMessageReceiver receiver;
                            create a BrokerServicefactory.CreateEventBrokerService(receiver);
                            create an InteractionServerProtocol(receiver)
                            craete a BasicChatProtocol(receiver)

    also i have some handler for event and request management. My BaseClass implements Subscriber<Message>
                          BaseClass include getFilter method

    All handler contains self success and failure filter.

    Can you help what i'm doing wrong. I'm wait the eventBroker must be invoke events like EventAgentLogin, EventAgentReady or EventInvite.

    Some small sample for my codes ;

Platform manager class
[tt]
        private QueueMessageReceiver receiver=new QueueMessageReceiver(1024, true);
        .........
        private void initializeChatServerProtocol(QueueMessageReceiver receiver) throws URISyntaxException{
                String userNick=getNickname();
                URI serveruri=new URI("tcp://"+mcrChatServer+":"+String.valueOf(mcrChatPort));
                chatProtocol=new BasicChatProtocol(new Endpoint(serveruri));
                chatProtocol.setUserNickname(userNick);
                chatProtocol.setReceiver(receiver);
                chatProtocol.setUserType(UserType.Agent);
                chatProtocol.setPersonId(getAgentId());
        }


        private void initializeInteractionServerProtocol(QueueMessageReceiver receiver) throws URISyntaxException{
                URI serveruri=new URI("tcp://"+mcrInteractionServer+":"+String.valueOf(mcrInteractionPort));
                isProtocol=new InteractionServerProtocol(new Endpoint(serveruri));
                isProtocol.setReceiver(receiver);
                isProtocol.setClientName("CCDesktop");
                isProtocol.setClientType(InteractionClient.AgentApplication);
        }

        private void initializeEventBrokerService(QueueMessageReceiver receiver){
                if (eventBroker==null){
                        eventBroker= BrokerServiceFactory.CreateEventBroker(receiver);
                }
        }

        private void initialize() throws URISyntaxException, ProtocolException, IllegalStateException, InterruptedException{
                initializeChatServerProtocol(receiver);
                initializeInteractionServerProtocol(receiver);
                initializeEventBrokerService(receiver);
                ......
                eventBroker.register(new RequestAgenrtLogin(protocol));
                eventBroker.register(new OpenMediaInviteAction(protocol));
                ......
        }
[/tt]

My base action class
[tt]
        public class BaseCTIAction implements Subscriber<Message> {
        ......
        public Predicate<Message> getFilter(){
                if ((successFilter!=null)&&(failureFilter!=null)){
                        return new OrPredicate(successFilter, failureFilter);
                }
                if (successFilter!=null){
                        return successFilter;
                }
                if (failureFilter!=null){
                        return failureFilter;
                }
                return null;
        }
        @Override
        public void handle(Message message) {
                if (successFilter==null || message==null)
                        return;
                event=message;
                if (successFilter.invoke(event)){
                        HandleSuccess(event);
                }
                else{
                        HandleFailure(event);
                }
        }
        public void Execute(){
                if(request==null){
                        throw new InvalidActivityException("Request must be set for this action.");
                }
                Message msg=protocol.request(request);
                handle(msg);
        }
        }
[/tt]

My sample Requestlogin action
[tt]
        public class OpenMediaLoginAction extends BaseCTIAction {

                RequestAgentLogin reqagentlogin;

                private Predicate<Message> getOpenMediaLoginFilter(){
                        return new OrPredicate<Message>(new MessageIdFilter(EventAck.ID), new MessageIdFilter(EventAgentLogin.ID));
                }

        public OpenMediaLoginAction(Protocol protocol, int tenantid, String placeid, String agentid) {
                super(protocol);
                super.setSuccessFilter(getOpenMediaLoginFilter());
                super.setFailureFilter(new MessageIdFilter(EventError.ID));

                reqagentlogin=RequestAgentLogin.create(tenantid, placeid, null);

                reqagentlogin.setAgentId(agentid);
                reqagentlogin.setMediaList(new KeyValueCollection());
                reqagentlogin.getMediaList().addInt("chat", 1);
               
                super.setRequest(reqagentlogin);
}
}
[/tt]

My sample Invite action class
[tt]
    public class OpenMediaInviteAction extends BaseCTIAction {

          public OpenMediaInviteAction(Protocol protocol) {
              super(protocol);
              super.setSuccessFilter(new MessageIdFilter(EventInvite.ID)); //127
              super.setFailureFilter(new MessageIdFilter(EventError.ID));
          }
    }
[/tt]