from interface ChatProvider.ChatForwarder
483049
public void forwardBroadcast (Name from, byte levelOrMode, String bundle, String msg)
    {
        for (PeerNode peer : _peers.values()) {
            if (peer.nodeobj != null) {
                ((CrowdNodeObject)peer.nodeobj).crowdPeerService.deliverBroadcast(
                    from, levelOrMode, bundle, msg);
            }
        }
    }
1361202
public Observable<ComapiResult<List<Participant>>> getParticipants(@NonNull final String conversationId) {

        final String token = getToken();

        if (sessionController.isCreatingSession()) {
            return getTaskQueue().queueGetParticipants(conversationId);
        } else if (TextUtils.isEmpty(token)) {
            return Observable.error(getSessionStateErrorDescription());
        } else {
            return doGetParticipants(token, conversationId);
        }
    }
1293995
private void dispatchToConversationListenerMethod(WsByteBuffer data, ConversationImpl conversation)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "dispatchToConversationListenerMethod", new Object[]{data, conversation});
      boolean bailOut = false;

      if (conversation == null)
      {
         // Must be an attempt to start a new conversation.
         if (onClientSide)
         {
            // This is an error!
            bailOut = true;
         }
         else
         {
            // On the server side we assume any previously unseend
            // conversation id means that the client is stricking up a
            // conversation with us.
            conversation = new ConversationImpl((short)conversationHeaderFields.conversationId, false, connection, null);

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "accepting new conversation");

            ConversationReceiveListener rl = null;
            boolean badReceiveListener = false;
            try
            {
               rl = acceptListener.acceptConnection(conversation);
            }
            catch(Throwable t)
            {
               FFDCFilter.processException
                  (t, "com.ibm.ws.sib.jfapchannel.impl.ConnectionReadCompletedCallback", JFapChannelConstants.INBOUNDXMITPARSER_DISPCONVLST_01);
               if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "exception thrown from acceptConnection");
               if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) SibTr.event(this, tc, t.getMessage());

               // Oh dear, user managed to throw an exception in their callback.
               badReceiveListener = true;
               bailOut = true;
            }

            // If the user did not supply us with a receive listener (either through
            // incompetence or throwning an exception) make our own.  We need one before
            // we can finish establishing the conversation and the cleanest way to dump the
            // conversation is to finish establishing it then close it.
            if (rl == null)
            {
               if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "bad receive listener");
               badReceiveListener = true;
               bailOut = true;
               rl = new BadReceiveListener();
            }

            conversation.setDefaultReceiveListener(rl);
            try
            {
               conversation = connection.startNewConversation(conversation);

               if (badReceiveListener)
               {
                  try
                  {
                     conversation.close();
                  }
                  catch (SIResourceException e)
                  {
                     FFDCFilter.processException
                        (e, "com.ibm.ws.sib.jfapchannel.impl.ConnectionReadCompletedCallback", JFapChannelConstants.INBOUNDXMITPARSER_DISPCONVLST_02);
                     if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "exception thrown closing conversation");
                     if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) SibTr.exception(this, tc, e);

                     // Hmmn, something went wrong trying to close the logical conversation.
                     // Bring down the whole conneciton.
                     connection.invalidate(false, e, "SIResourceError when closing conversation - "+e.getMessage()); // D224570
                     bailOut = true;
                  }
               }
            }
            catch(SIResourceException e)
            {
               // No FFDC code needed
               // (FFDC taken at source of exception)
               try
               {
                  conversation.close();
               }
               catch(Exception e2)
               {
                  // No FFDC code needed
                  // (already broken)
               }

               connection.invalidate(true, e, "SIResourceError when creating conversation - "+e.getMessage());
            }
         }
      }

      if (!bailOut)
      {

         RequestIdTable reqIdTable = null;
         if (conversation != null)
            reqIdTable = conversation.getRequestIdTable();

         // Is this request something we were expecting a reply for?
         if ((reqIdTable != null) && reqIdTable.containsId(conversationHeaderFields.requestNumber))
         {
            ReceiveListener listener = reqIdTable.getListener(conversationHeaderFields.requestNumber);
            reqIdTable.remove(conversationHeaderFields.requestNumber);

            if (listener != null)
            {
               if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "listener: "+listener+" conversaion: "+conversation);

               ReceiveListenerDispatcher.getInstance(conversation.getConversationType(), conversation.isOnClientSide()).        // D242116
                queueDataReceivedInvocation
                  (connection, listener, data, primaryHeaderFields.segmentType,
                     conversationHeaderFields.requestNumber, primaryHeaderFields.priority, primaryHeaderFields.isPooled,
                     primaryHeaderFields.isExchange, conversation);
            }
            else
            {
               // It should be impossible to get to here and discover that
               // the associated entry in the request table has a null
               // receive listener...
               if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Entry "+conversationHeaderFields.requestNumber+" in request table has null listener");

               // Probably better stop talking to our peer - just to be on the safe side.
               connection.invalidate(true, null, "no receive listener for conversation "+conversationHeaderFields.requestNumber); // F176003, D224570
            }

         }
         else
         {
            // We weren't expecting this reply - notify the 'default' request
            // listener associated with this conversation...
            ConversationReceiveListener listener =                                 // F174776
               conversation.getDefaultReceiveListener();
            //if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "invokeCallback", "default receive listener: "+listener);
            if (listener == null)
            {
               // Earlier error checking should prevent us ever getting into
               // this condition.
               //if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "No default receive listener");

               // Since we can't really continue, probably best to stop talking
               // to our peer now.
               connection.invalidate(true, null, "no default receive listener");    // F176003, D224570
            }
            else
            {
               ReceiveListenerDispatcher.getInstance(conversation.getConversationType(), conversation.isOnClientSide()).        // D242116
                queueDataReceivedInvocation
                  (connection, listener, data, primaryHeaderFields.segmentType,
                  conversationHeaderFields.requestNumber, primaryHeaderFields.priority, primaryHeaderFields.isPooled,
                  primaryHeaderFields.isExchange, conversation);
            }
         }

      }//if(!bailOut)

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "dispatchToConversationListenerMethod");
   }
1070302
public void deliverBroadcast (
        ClientObject caller, Name from, byte levelOrMode, String bundle, String msg)
    {
        // deliver the broadcast locally on this server
        _chatprov.broadcast(from, levelOrMode, bundle, msg, false);
    }
44935
private void dispatchToConversation(WsByteBuffer data)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "dispatchToConversation", data);
      ConversationImpl conversation =
         connection.getConversationById(conversationHeaderFields.conversationId);

      //@stoptracescan@
      if (TraceComponent.isAnyTracingEnabled()) JFapUtils.debugSummaryMessage(tc, connection, conversation, "received conversation data with segment "+Integer.toHexString(primaryHeaderFields.segmentType)+" ("+JFapChannelConstants.getSegmentName(primaryHeaderFields.segmentType)+")", conversationHeaderFields.requestNumber);
      //@starttracescan@
      if (conversation != null) conversation.logDataReceivedEvent(primaryHeaderFields.segmentType,
                                                                  conversationHeaderFields.requestNumber);

      switch(primaryHeaderFields.segmentType)
      {
         case(JFapChannelConstants.SEGMENT_LOGICAL_CLOSE):
            if (conversation == null)
            {
               state = STATE_ERROR;
               throwable = new SIConnectionLostException(nls.getFormattedMessage("TRANSPARSER_PROTOCOLERROR_SICJ0053", new Object[] {connection.remoteHostAddress, connection.chainName}, "TRANSPARSER_PROTOCOLERROR_SICJ0053"));   // D226223
               // This FFDC was generated because we could not locate a conversation corresponding
               // to the conversation ID supplied by our peer.
               FFDCFilter.processException(throwable, "com.ibm.ws.sib.jfapchannel.impl.InboundTransmissionParser", JFapChannelConstants.INBOUNDXMITPARSER_DISPCONV_01, getFormattedBytes(data));   // D267629
               if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Cannot locate conversation corresponding to conversation identifier in transmission ("+conversationHeaderFields.conversationId+")");
            }
            else
               conversation.processLogicalClose(data);
            break;
         case(JFapChannelConstants.SEGMENT_PING):
            if (conversation == null)
            {
               state = STATE_ERROR;
               throwable = new SIConnectionLostException(nls.getFormattedMessage("TRANSPARSER_PROTOCOLERROR_SICJ0053", new Object[] {connection.remoteHostAddress, connection.chainName}, "TRANSPARSER_PROTOCOLERROR_SICJ0053"));   // D226223
               // This FFDC was generated because we could not locate a conversation corresponding
               // to the conversation ID supplied by our peer.
               FFDCFilter.processException(throwable, "com.ibm.ws.sib.jfapchannel.impl.InboundTransmissionParser", JFapChannelConstants.INBOUNDXMITPARSER_DISPCONV_02, getFormattedBytes(data));   // D267629
               if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Cannot locate conversation corresponding to conversation identifier in transmission ("+conversationHeaderFields.conversationId+")");
            }
            else
               conversation.processPing(conversationHeaderFields.requestNumber, primaryHeaderFields.priority, data);
            break;
         case(JFapChannelConstants.SEGMENT_PING_RESPONSE):
            if (conversation == null)
            {
               state = STATE_ERROR;
               throwable = new SIConnectionLostException(nls.getFormattedMessage("TRANSPARSER_PROTOCOLERROR_SICJ0053", new Object[] {connection.remoteHostAddress, connection.chainName}, "TRANSPARSER_PROTOCOLERROR_SICJ0053"));   // D226223
               // This FFDC was generated because we could not locate a conversation corresponding
               // to the conversation ID supplied by our peer.
               FFDCFilter.processException(throwable, "com.ibm.ws.sib.jfapchannel.impl.InboundTransmissionParser", JFapChannelConstants.INBOUNDXMITPARSER_DISPCONV_03, getFormattedBytes(data));   // D267629
               if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Cannot locate conversation corresponding to conversation identifier in transmission ("+conversationHeaderFields.conversationId+")");
            }
            else
               conversation.processPingResponse(data);
            break;
         default:
            dispatchToConversationListenerMethod(data, conversation);
            break;
      }

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "dispatchToConversation");
   }
1012550
public void deliverTell (UserMessage message, Name target, TellListener listener)
        throws InvocationException
    {
        // make sure the target user is online
        BodyObject tobj = _locator.lookupBody(target);
        if (tobj == null) {
            // if we have a forwarder configured, try forwarding the tell
            if (_chatForwarder != null && _chatForwarder.forwardTell(message, target, listener)) {
                return;
            }
            throw new InvocationException(ChatCodes.USER_NOT_ONLINE);
        }

        if (tobj.status == OccupantInfo.DISCONNECTED) {
            String errmsg = MessageBundle.compose(
                ChatCodes.USER_DISCONNECTED, TimeUtil.getTimeOrderString(
                    System.currentTimeMillis() - tobj.getLocal(BodyLocal.class).statusTime,
                    TimeUtil.SECOND));
            throw new InvocationException(errmsg);
        }

        // deliver a tell notification to the target player
        deliverTell(tobj, message);

        // let the teller know it went ok
        long idle = 0L;
        if (tobj.status == OccupantInfo.IDLE) {
            idle = System.currentTimeMillis() - tobj.getLocal(BodyLocal.class).statusTime;
        }
        String awayMessage = null;
        if (!StringUtil.isBlank(tobj.awayMessage)) {
            awayMessage = tobj.awayMessage;
        }
        listener.tellSucceeded(idle, awayMessage);
    }
673984
function() {
                chatSendQueueHandlerTimeout && clearTimeout(chatSendQueueHandlerTimeout);
                if (chatSendQueue.length) {
                    var messageToBeSend = chatSendQueue[0];

                    /**
                     * Getting chatSendQueue from either cache or
                     * memory and scrolling through the send queue
                     * to send all the messages which are waiting
                     * for chatState to become TRUE
                     *
                     * There is a small possibility that a Message
                     * wouldn't make it through network, so it Will
                     * not reach chat server. To avoid losing those
                     * messages, we put a clone of every message
                     * in waitQ, and when ack of the message comes,
                     * we delete that message from waitQ. otherwise
                     * we assume that these messages have been failed to
                     * send and keep them to be either canceled or resent
                     * by user later. When user calls getHistory(), they
                     * will have failed messages alongside with typical
                     * messages history.
                     */
                    if (chatState) {
                        getChatSendQueue(0, function(chatSendQueue) {
                            deleteFromChatSentQueue(messageToBeSend,
                                function() {
                                    sendMessage(messageToBeSend.message, messageToBeSend.callbacks, function() {
                                        if (chatSendQueue.length) {
                                            chatSendQueueHandler();
                                        }
                                    });
                                });
                        });
                    }
                }
            }
1183033
@Override
    public void afterInitialized(BaseComponent comp) {
        super.afterInitialized(comp);
        window = (Window) comp;
        sessionId = (String) comp.getAttribute("id");
        lstParticipants.setRenderer(new ParticipantRenderer(chatService.getSelf(), null));
        model.add(chatService.getSelf());
        lstParticipants.setModel(model);
        clearMessage();
        
        if (comp.getAttribute("originator") != null) {
            invite((result) -> {
                if (!result) {
                    close();
                } else {
                    initSession();
                }
            });
        }
130933
Observable<ChatResult> handleConversationCreated(ComapiResult<ConversationDetails> result) {
        if (result.isSuccessful()) {
            return persistenceController.upsertConversation(ChatConversation.builder().populate(result.getResult(), result.getETag()).build()).map(success -> adapter.adaptResult(result, success));
        } else {
            return Observable.fromCallable(() -> adapter.adaptResult(result));
        }
    }
327345
public void speak (ClientObject caller, final ChatChannel channel, String message, byte mode)
    {
        BodyObject body = _locator.forClient(caller);
        final UserMessage umsg = new UserMessage(body.getVisibleName(), null, message, mode);

        // if we're hosting this channel, dispatch it directly
        if (_channels.containsKey(channel)) {
            dispatchSpeak(channel, umsg);
            return;
        }

        // if we're resolving this channel, queue up our message for momentary deliver
        List<UserMessage> msgs = _resolving.get(channel);
        if (msgs != null) {
            msgs.add(umsg);
            return;
        }

        // forward the speak request to the server that hosts the channel in question
        _peerMan.invokeNodeAction(new ChannelAction(channel) {
            @Override protected void execute () {
                _channelMan.dispatchSpeak(_channel, umsg);
            }
        }, new Runnable() {
            public void run () {
                _resolving.put(channel, Lists.newArrayList(umsg));
                resolveAndDispatch(channel);
            }
        });
    }
243903
private IChannelConsumer getClientChannelFor(
            String functionalityName,
            IAsyncMessageClient client,
            String conversationID) throws ServiceGroundingException
    {
        IChannelConsumer channel = this.channelConsumersHelper.getChannel(functionalityName, client.getName(), conversationID);
        if (null != channel)
        {
            return channel;
        }

        IChannelConsumer newChannel = createClientChannelFor(functionalityName, client.getName(), conversationID);
        newChannel.addClientCallback(client);
        this.channelConsumersHelper.addChannel(newChannel, functionalityName, client.getName(), conversationID);
        return newChannel;
    }
435935
public void requestBroadcast (String message)
    {
        message = filter(message, null, true);
        if (message == null) {
            displayFeedback(_bundle, MessageBundle.compose("m.broadcast_failed", "m.filtered"));
            return;
        }
        _cservice.broadcast(message, new ChatService.InvocationListener() {
            public void requestFailed (String reason) {
                reason = MessageBundle.compose("m.broadcast_failed", reason);
                displayFeedback(_bundle, reason);
            }
        });
    }
807273
Observable<ChatConversationBase> getConversation(@NonNull String conversationId) {

        return Observable.create(emitter -> storeFactory.execute(new StoreTransaction<ChatStore>() {
            @Override
            protected void execute(ChatStore store) {
                store.open();
                ChatConversationBase c = store.getConversation(conversationId);
                store.close();
                emitter.onNext(c);
                emitter.onCompleted();
            }
        }), Emitter.BackpressureMode.BUFFER);
    }
1189234
@Message(encoders = {JacksonEncoder.class}, decoders = {ProtocolDecoder.class})
    public ChatProtocol onMessage(ChatProtocol message) throws IOException {

        if (!users.containsKey(message.getAuthor())) {
            users.put(message.getAuthor(), message.getUuid());
            return new ChatProtocol(message.getAuthor(), " entered room " + chatroomName, users.keySet(), getRooms(factory.lookupAll()));
        }

        if (message.getMessage().contains("disconnecting")) {
            users.remove(message.getAuthor());
            return new ChatProtocol(message.getAuthor(), " disconnected from room " + chatroomName, users.keySet(), getRooms(factory.lookupAll()));
        }

        message.setUsers(users.keySet());
        logger.info("{} just send {}", message.getAuthor(), message.getMessage());
        return new ChatProtocol(message.getAuthor(), message.getMessage(), users.keySet(), getRooms(factory.lookupAll()));
    }
905017
protected Observable<RxComapiClient> getClientInstance(@NonNull Application app, @NonNull final ChatConfig chatConfig) {
        return RxComapi.initialise(app, chatConfig.buildComapiConfig());
    }
193956
private void processDestinationListenerCallback (CommsByteBuffer buffer, Conversation conversation) {
     if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "processDestinationListenerCallback", new Object[]{buffer, conversation});

     final ClientConversationState convState = (ClientConversationState) conversation.getAttachment();
     final SICoreConnection connection = convState.getSICoreConnection();

     final short connectionObjectId                = buffer.getShort();
     final short destinationListenerId             = buffer.getShort();
     final SIDestinationAddress destinationAddress = buffer.getSIDestinationAddress(conversation.getHandshakeProperties().getFapLevel());
     final short destinationAvailabilityShort      = buffer.getShort();

     if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "connectionObjectId="+connectionObjectId);
     if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "destinationListenerId="+destinationListenerId);
     if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "destinationAddress="+destinationAddress);

     DestinationAvailability destinationAvailability = null;
     if (destinationAvailabilityShort != CommsConstants.NO_DEST_AVAIL) {
       destinationAvailability = DestinationAvailability.getDestinationAvailability(destinationAvailabilityShort);
     }
     if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "destinationAvailability="+destinationAvailability);

     // Look up the real DestinationListener in the local DestinationListenerCache

     final DestinationListenerCache destinationListenerCache = convState.getDestinationListenerCache();
     final DestinationListener destinationListener = destinationListenerCache.get(destinationListenerId);

     if (destinationListener != null) {
        //Call the listener on a seperate thread.
        ClientAsynchEventThreadPool.getInstance().dispatchDestinationListenerEvent(connection, destinationAddress, destinationAvailability, destinationListener);
     } else {
       if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "DestinationListener id="+destinationListenerId+" not found in DestinationListenerCache");
       if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, destinationListenerCache.toString());

       SIErrorException e = new SIErrorException(nls.getFormattedMessage("UNABLE_TO_FIND_DESTINATION_LISTENER_SICO8019", new Object[] {Short.valueOf(destinationListenerId)}, null));
       FFDCFilter.processException(e, CLASS_NAME + ".processDestinationListenerCallback", CommsConstants.PROXYRECEIVELISTENER_DESTLIST_CALLBACK_02, this);

       SibTr.error(tc, "UNABLE_TO_FIND_DESTINATION_LISTENER_SICO8019", e);
       throw e;
     }

     if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "processDestinationListenerCallback");
   }
526304
public AVIMConversation getConversation(String conversationId, int convType) {
    AVIMConversation result = null;
    switch (convType) {
      case Conversation.CONV_TYPE_SYSTEM:
        result = getServiceConversation(conversationId);
        break;
      case Conversation.CONV_TYPE_TEMPORARY:
        result = getTemporaryConversation(conversationId);
        break;
      case Conversation.CONV_TYPE_TRANSIENT:
        result = getChatRoom(conversationId);
        break;
      default:
        result = getConversation(conversationId);
        break;
    }
    return result;
  }