分析 crisp-client 的 client 过程

2023-08-02

脚本: https://client.crisp.chat/static/javascripts/client.js?7734d14

i18n 的处理

https://client.crisp.chat/static/javascripts/locales/zh.js?7734d14

过程

  • 定义 jade 有如下方法
    • ['merge', 'joinClasses', 'cls', 'style', 'attr', 'attrs', 'escape', 'rethrow']
  • 载入 petite-vue
    • 数据监听
    • 模板编译
  • Smileys 的处理; 即普通字符转表情的一套规则

browsing 监听

this.parent.socket.on("browsing:request:initiate", this.Zn.Bt(this)),
this.parent.stream.on("client:browsing:request:initiated", this.ue.Bt(this)),
this.parent.stream.on("client:browsing:action:start", this.fe.Bt(this)),
this.parent.stream.on("client:browsing:action:stop", this.de.Bt(this)),
this.parent.stream.on("client:browsing:action:heartbeat", this.ve.Bt(this)),
this.parent.stream.on("client:browsing:assist:start", this.pe.Bt(this)),
this.parent.stream.on("client:browsing:assist:stop", this.ye.Bt(this)),
this.parent.stream.on("client:browsing:assist:heartbeat", this.me.Bt(this)),
this.parent.stream.on("client:browsing:assist:mouse", this.ge.Bt(this)),
this.parent.stream.on("client:browsing:assist:scroll", this.we.Bt(this)),
this.parent.stream.on("client:browsing:assist:click", this.be.Bt(this))
["browsing:action:start", "browsing:action:stop", "browsing:action:heartbeat", "browsing:assist:start", "browsing:assist:stop", "browsing:assist:heartbeat", "browsing:assist:mouse", "browsing:assist:scroll", "browsing:assist:click"]

session 会话层


var t = this;
this.parent.socket.on("session:created", this.un.Bt(this)),
this.parent.socket.on("session:joined", this.dn.Bt(this)),
this.parent.socket.on("session:state", this.vn.Bt(this)),
this.parent.socket.on("session:error", this.pn.Bt(this)),
this.parent.socket.on("session:request:initiate", this.Pi.Bt(this)),
this.parent.socket.on("session:request:purge", this.yn.Bt(this)),
this.parent.socket.on("session:request:feedback", this.mn.Bt(this)),
this.parent.socket.on("session:feedback:rated", this.gn.Bt(this)),
this.parent.socket.on("connect", function() {
    t.in ? t.join(!0) : t.restore()
})

整理大量当前用户会话信息,比如 page_title/page_url/referrer

w.prototype.Ti

恢复会话聊天记录,并把聊天记录排序且展示

storage_session_retrieve

使用 socket io 进行通信 https://socket.io

屏幕分享

toggle_screensharing

copyright ©2019-2024 shenzhen
粤ICP备20041170号-1