dojox/xmpp/ChatService.js

  • Provides:

    • dojox.xmpp.ChatService
  • dojox.xmpp.ChatService

    • type
      Function
    • source: [view]
        this.state="";
        this.chatid = Math.round(Math.random() * 1000000000000000);
    • summary
  • dojox.xmpp.ChatService.state

    • summary
  • dojox.xmpp.ChatService.recieveMessage

    • type
      Function
    • parameters:
      • msg: (typeof )
      • initial: (typeof )
    • source: [view]
        if (msg&&!initial){
         this.onNewMessage(msg);
        }
    • summary
  • dojox.xmpp.ChatService.setSession

    • type
      Function
    • parameters:
      • session: (typeof )
    • source: [view]
        this.session = session;
    • summary
  • dojox.xmpp.ChatService.setState

    • type
      Function
    • parameters:
      • state: (typeof )
    • source: [view]
        if (this.state != state){
         this.state = state;
        }
    • summary
  • dojox.xmpp.ChatService.invite

    • type
      Function
    • parameters:
      • contact: (typeof )
    • source: [view]
        if (this.uid){return;}




        if(!contact || contact==''){
         throw new Error("ChatService::invite() contact is NULL");
        }


        this.uid = contact;


        var req = {
         xmlns: "jabber:client",
         to: this.uid,
         from: this.session.jid + "/" + this.session.resource,
         type: "chat"
        }
        var request = new dojox.string.Builder(dojox.xmpp.util.createElement("message", req, false));
        request.append(dojox.xmpp.util.createElement("thread",{},false));
        request.append(this.chatid);
        request.append("");
        request.append(dojox.xmpp.util.createElement("active",{xmlns: dojox.xmpp.chat.CHAT_STATE_NS},true));
        request.append("");
        this.session.dispatchPacket(request.toString());


        this.onInvite(contact);
        this.setState(dojox.xmpp.chat.CHAT_STATE_NS);
    • summary
  • dojox.xmpp.ChatService.sendMessage

    • type
      Function
    • parameters:
      • msg: (typeof )
    • source: [view]
        if (!this.uid){
         //console.log("ChatService::sendMessage() - Contact Id is null, need to invite to chat");
         return;
        }


        if ((!msg.body || msg.body=="") && !msg.xhtml){return;}


        var req = {
         xmlns: "jabber:client",
         to: this.uid,
         from: this.session.jid + "/" + this.session.resource,
         type: "chat"
        }


        var message = new dojox.string.Builder(dojox.xmpp.util.createElement("message",req,false));
        var html = dojox.xmpp.util.createElement("html", { "xmlns":dojox.xmpp.xmpp.XHTML_IM_NS},false)


        var bodyTag = dojox.xmpp.util.createElement("body", {"xml:lang":this.session.lang, "xmlns":dojox.xmpp.xmpp.XHTML_BODY_NS}, false) + msg.body + "";
        var bodyPlainTag = dojox.xmpp.util.createElement("body", {}, false) + dojox.xmpp.util.stripHtml(msg.body) + "";
      /*
        if (msg.xhtml){
         if (msg.xhtml.getAttribute('xmlns') != dojox.xmpp.xmpp.XHTML_IM_NS){
          //console.log("ChatService::sendMessage() - Cannot use this xhtml without the propper xmlns");
         }else{
          //FIXME do this in some portable way
          //console.log("ChatService::sendMessage() - FIXME Serialize XHTML to string: ", msg.xhtml.toString());
         }
        }
      */
        if (message.subject && message.subject != ""){
         message.append(dojox.xmpp.util.createElement("subject",{},false));
         message.append(message.subject);
         message.append("");
        }
        message.append(bodyPlainTag);
        message.append(html);
        message.append(bodyTag);
        message.append("");
        message.append(dojox.xmpp.util.createElement("thread", {}, false));
        message.append(this.chatid);
        message.append("");


        if (this.useChatStates){
         message.append(dojox.xmpp.util.createElement("active",{xmlns: dojox.xmpp.chat.CHAT_STATE_NS},true));
        }
        message.append("");

       
        this.session.dispatchPacket(message.toString());
    • summary
  • dojox.xmpp.ChatService.sendChatState

    • type
      Function
    • parameters:
      • state: (typeof )
    • source: [view]
        if (!this.useChatState || this.firstMessage){return;}
        if (state==this._currentState){return;}

        
        var req={
         xmlns: "jabber:client",
         to: this.uid,
         from: this.session.jid + "/" + this.session.resource,
         type: "chat"
        }


        var request = new dojox.string.Builder(dojox.xmpp.util.createElement("message",req,false));
        request.append(dojox.xmpp.util.createElement(state, {xmlns: dojox.xmpp.chat.CHAT_STATE_NS},true));
        this._currentState = state;
        request.append("");
        request.append(this.chatid);
        request.append("
      ");

        
        this.session.dispatchPacket(request.toString());
    • summary
  • dojox.xmpp.ChatService.onNewMessage

    • type
      Function
    • parameters:
      • msg: (typeof )
    • source: [view]
      }
    • summary
  • dojox.xmpp.ChatService.onInvite

    • type
      Function
    • parameters:
      • contact: (typeof )
    • source: [view]
      }
    • summary
  • dojox.xmpp.ChatService.session

    • summary
  • dojox.xmpp.ChatService.uid

    • summary
  • dojox.xmpp.ChatService._currentState

    • summary
  • dojox.xmpp.ChatService.chatid

    • summary
  • dojox.xmpp.chat

    • type
      Object
    • summary
  • dojox.xmpp.chat.CHAT_STATE_NS

    • summary
  • dojox.xmpp.chat.ACTIVE_STATE

    • summary
  • dojox.xmpp.chat.COMPOSING_STATE

    • summary
  • dojox.xmpp.chat.INACTIVE_STATE

    • summary
  • dojox.xmpp.chat.PAUSED_STATE

    • summary
  • dojox.xmpp.chat.GONE_STATE

    • summary
  • dojox.xmpp

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary