Comparing version 2.4.7 to 2.4.8
{ | ||
"name": "sendbird", | ||
"version": "2.4.7", | ||
"version": "2.4.8", | ||
"authors": [ | ||
@@ -5,0 +5,0 @@ "SendBird <support@sendbird.com>" |
Changelog | ||
========= | ||
## v2.4.8 | ||
### update | ||
* bugfix for react native | ||
## v2.4.7 | ||
@@ -5,0 +12,0 @@ |
{ | ||
"name": "sendbird", | ||
"version": "2.4.7", | ||
"version": "2.4.8", | ||
"description": "SendBird JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "main": "SendBird.min.js", |
@@ -30,6 +30,6 @@ SendBird-SDK-JavaScript | ||
## Upgrading to v2.4.7 | ||
## Upgrading to v2.4.8 | ||
If you want to check the record of other version, go to [Change Log](https://github.com/smilefam/SendBird-SDK-JavaScript/blob/master/CHANGELOG.md). | ||
* update: disconnect bug fix | ||
* bugfix: for react-native | ||
@@ -36,0 +36,0 @@ |
/** | ||
* SendBird JavaScript SDK v2.4.7 | ||
* SendBird JavaScript SDK v2.4.8 | ||
*/ | ||
var _isLeavingPage=!1;"object"==typeof window&&(window.onbeforeunload=function(){_isLeavingPage=!0}),function(e,n){"function"==typeof define&&define.amd?define([],n()):"object"==typeof exports?module.exports=n():(e.SB=n(),e.sendbird=e.SB.getInstance())}(this,function(){function e(e,n,s,t,i,r){var c=new XMLHttpRequest;if("withCredentials"in c){try{switch(c=new XMLHttpRequest,s.toLowerCase()){case"get":c.open("GET",e);break;default:c.open("POST",e)}c.onload=function(){if(c.status>=a&&c.status<o){var e=c.responseText;i(JSON.parse(e))}else r(c.status,c.statusText)},c.onerror=function(){r(404,"There was a connection error")}}catch(u){c=new ActiveXObject("Microsoft.XMLHTTP");try{switch(s.toLowerCase()){case"get":c.open("GET",e);break;default:c.open("POST",e)}}catch(g){c.open("POST",e)}c.onreadystatechange=function(){if(4==c.readyState)if(c.status>=a&&c.status<o){var e=c.responseText;i(JSON.parse(e))}else r(c.status,c.statusText)}}c.setRequestHeader("Content-Type","text/plain; charset=UTF-8");for(var d in t)c.setRequestHeader(d,t[d])}else{c=new XDomainRequest,c.withCredentials=!0;try{switch(s.toLowerCase()){case"get":c.open("GET",e);break;default:c.open("POST",e)}}catch(g){c.open("POST",e)}for(var d in t)n[d]=t[d];c.onload=function(){var e=JSON.parse(c.responseText);e.error?r(c.status,c.statusText):i(e)},c.onerror=function(){r(404,"There was a connection error")}}c.send(JSON.stringify(n))}var n=!1,s=!1,t=window.console||{log:function(){}},i=function(e){n&&t.log(e)},r=function(e){e=e||{};for(var n=arguments.length,s=1;n>s;s++)if(arguments[s])for(var t in arguments[s])arguments[s].hasOwnProperty(t)&&(e[t]=arguments[s][t]);return e};"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});var a=200,o=400,c=function(){function e(){var e=new u;return e}var n,s=function(s){var t=r({},{newInstance:!1},s);return t.newInstance?e():(n||(n=e()),n)};return{getInstance:s}}(),u=function(){function t(e){return u(_+k.app_id),d+"v"+f.replace(/[^(0-9)]/gi,"")+"/"+e}function c(e){return u(_+k.app_id),d+"v3/"+e}function u(n,s,t){if(l)p="ws://localtest.me:9000",d="http://api.localtest.me:8000/","function"==typeof s&&s();else{var r=(new Date).getTime()/1e3;0==C||C-r>3?e(n,{},"GET",{SendBird:S+k.app_id},function(e){p=e.ws_server,d=e.api_server+"/",i("Routing Info Update: "+p+", "+d),C=r,"function"==typeof s&&s()},function(e,n){"function"==typeof t&&t(e,n)}):"function"==typeof s&&s()}}function g(e){k.app_id=e.app_id,k.guest_id=e.guest_id,k.user_name=e.user_name,k.image_url=void 0==e.image_url||null==e.image_url?"":e.image_url,k.access_token=void 0==e.access_token||null==e.access_token?"":e.access_token,G({successFunc:function(n){e.successFunc(n)},errorFunc:function(n,s){e.errorFunc(n,s)},async:e.async})}var d,p,l=!1,f="1",_="https://sbrouting.sendbird.com/app/",m="2.4.7",v="/?p=JS&pv="+encodeURI(navigator.userAgent)+"&sv="+m+"&ai=",S="JS,"+encodeURI(navigator.userAgent)+","+m+",",y=null,h={MESG:"MESG",FILE:"FILE",LOGI:"LOGI",JOIN:"JOIN",SYSM:"SYSM",BRDM:"BRDM",MCUP:"MCUP",READ:"READ",TPST:"TPST",TPEN:"TPEN",BAAN:"BAAN",FREZ:"FREZ",PING:"PING",PONG:"PONG"},k={},F={},T=0,M=0,O=null,P=null,R=null,N=0,w=!1,b=0,I=1e4,C=0,E=function(e,n){switch(e){case h.MESG:B.onMessageReceived(JSON.parse(n));break;case h.SYSM:B.onSystemMessageReceived(JSON.parse(n));break;case h.FILE:B.onFileMessageReceived(JSON.parse(n));break;case h.BRDM:B.onBroadcastMessageReceived(JSON.parse(n));break;case h.TPST:B.onTypeStartReceived(JSON.parse(n));break;case h.TPEN:B.onTypeEndReceived(JSON.parse(n));break;case h.PONG:i(h.PONG);break;case h.READ:B.onReadReceived(JSON.parse(n));break;case h.BAAN:B.onBanReceived(JSON.parse(n));break;case h.FREZ:var s=JSON.parse(n),t=!1;try{t=s.freeze}catch(r){t=!1}F.data=JSON.stringify({freeze:t}),B.onChannelFreezeReceived(s);break;default:B.onUndefinedMessageReceived(e,JSON.parse(n))}return JSON.parse(n)},L={successFunc:function(e){},errorFunc:function(e,n){i(e),i(n)}},B={onMessageReceived:function(e){i(e)},onSystemMessageReceived:function(e){i(e)},onFileMessageReceived:function(e){i(e)},onBroadcastMessageReceived:function(e){i(e)},onReadReceived:function(e){i(e)},onMessagingChannelUpdateReceived:function(e){i(e)},onTypeStartReceived:function(e){i(e)},onTypeEndReceived:function(e){i(e)},onMessageDelivery:function(e){i(e)},onBanReceived:function(e){i(e)},onChannelFreezeReceived:function(e){i(e)},onUndefinedMessageReceived:function(e,n){i(e),i(n)}},J=6,D=5,G=function(n){i("=== Start SendBird SDK ===");var s=r({},L,n),o="guest_login/",c={guest_id:k.guest_id,app_id:k.app_id,nickname:k.user_name,image_url:k.image_url,access_token:k.access_token};void 0!=k.gcm_reg_token&&""!=k.gcm_reg_token&&(c.gcm_reg_token=k.gcm_reg_token),void 0!=k.apns_device_token&&""!=k.apns_device_token&&(c.apns_device_token=k.apns_device_token),u(_+k.app_id,function(){e(t(o),c,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(a,e.message):(k.guest_key=e.key,s.successFunc({}))},function(e,n){s.errorFunc(e,n)})},function(e,n){s.errorFunc(e,n)})},A=function(n,s){i("=== Join Channel ===");var o=r({},L,s),c="channel_join/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:n},g={};e(t(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?o.errorFunc(a,e.message):(e.isMessaging=!1,r(F,e),g=F,o.successFunc(g))},function(e,n){o.errorFunc(e,n)})},U=function(n,s){i("=== Leave Channel ===");var o=r({},L,s),c="channel_leave",u={app_id:k.app_id,session_key:k.guest_key,channel_url:n},g={};e(t(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?o.errorFunc(a,e.message):(g=e,o.successFunc(g))},function(e,n){o.errorFunc(e,n)})},x=function(n,s){i("=== Member List ===");var o=r({},L,s),c="member_list/",u={app_id:k.app_id,channel_url:n},g={};e(t(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?o.errorFunc(a,e.message):(g=e,o.successFunc(g))},function(e,n){o.errorFunc(e,n)})},W=function(n){i("=== Channel List ==="),n=r({},{limit:20,page:1,query:""},n);var s=r({},L,n),o="channel_list/",c={app_id:k.app_id,page:s.page,limit:s.limit,query:s.query},u={};e(t(o),c,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(a,e.message):(u=e,s.successFunc(u))},function(e,n){s.errorFunc(e,n)})},z=function(e){W(e)},j=function(e){return void 0!=e.last_message&&""!=e.last_message&&(e.last_message=JSON.parse(e.last_message.substring(4))),e},q=function(n,s){i("=== Join Messaging Channel ===");var o=r({},L,s),c="messaging_join/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:n},g={};e(t(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?o.errorFunc(a,e.message):(e.channel.isMessaging=!0,r(F,e.channel),g=e,o.successFunc(j(g)))},function(e,n){o.errorFunc(e,n)})},H=function(n,s){i("=== Start Messaging ==="),n=n instanceof Array?n:new Array(n);var o=r({},L,s),c="messaging_start/",u={app_id:k.app_id,session_key:k.guest_key,guest_ids:n},g={};e(t(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?o.errorFunc(a,e.message):(r(F,e.channel),g=e,o.successFunc(j(g)))},function(e,n){o.errorFunc(e,n)})},X=function(e,n,s){if(2==arguments.length){var t=arguments[1].channel_url;void 0!=t&&""!=t||(t=F.channel_url),Y(arguments[0],t,arguments[1])}else Y(e,n,s)},Y=function(n,s,o){i("=== Invite Messaging ==="),n=n instanceof Array?n:new Array(n);var c=r({},L,o),u="messaging_invite/",g={app_id:k.app_id,session_key:k.guest_key,channel_url:s,guest_ids:n},d={};e(t(u),g,"POST",{SendBird:S+k.app_id},function(e){e.error?c.errorFunc(a,e.message):(r(F,e.channel),d=e,c.successFunc(j(d)))},function(e,n){c.errorFunc(e,n)})},Z=function(n,s){i("=== End Messaging ===");var o=r({},L,s),c="messaging_end/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:n},g={};e(t(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?o.errorFunc(a,e.message):(r(F,e),g=e,o.successFunc(j(g)))},function(e,n){o.errorFunc(e,n)})},K=function(n){i("=== Messaging Channel List ==="),n=r({},{limit:9999,page:1},n);var s=r({},L,n),o="messaging_list/",c={app_id:k.app_id,session_key:k.guest_key,page:s.page,limit:s.limit},u={};e(t(o),c,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(a,e.message):(u=e,u.channels.forEach(function(e,n){e=j(e)}),s.successFunc(u))},function(e,n){s.errorFunc(e,n)})},$=function(n){i("=== Messaging Channel List ==="),n=r({},{limit:9999,page:1},n);var s=r({},L,n),t="messaging_list/",o={app_id:k.app_id,session_key:k.guest_key,page:s.page,limit:s.limit},u={};e(c(t),o,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(a,e.message):(u=e,u.channels.forEach(function(e,n){e=j(e)}),s.successFunc(u))},function(e,n){s.errorFunc(e,n)})},Q=function(n,s){i("=== Messaging Channel Info ===");var o=r({},L,s),c="messaging_info/",u={app_id:k.app_id,session_key:k.guest_key,channel_id:n};e(t(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?o.errorFunc(a,e.message):B.onMessagingChannelUpdateReceived(j(e))},function(e,n){o.errorFunc(e,n)})},V=function(n,s){i("=== Message Mark As Read ===");var o=r({},L,s),c="mark_as_read/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:n},g={};e(t(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?o.errorFunc(a,e.message):(g=e,o.successFunc(g))},function(e,n){o.errorFunc(e,n)})},ee=function(n){i("=== Message Load More ==="),n=r({},{limit:20},n);var s=r({},L,n),o=(new Date).getTime(),c="message_list",u={app_id:k.app_id,session_key:k.guest_key,channel_url:F.channel_url,message_ts:0==M?o:M,prev_limit:s.limit,next_limit:0,include:!1},g=[];e(t(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(a,e.message):(e.messages.forEach(function(e,n){var s=JSON.parse(e.substring(4));0==M?M=s.ts:M>s.ts&&(M=s.ts),g.push(Fe(e))}),s.successFunc({messages:g}))},function(e,n){s.errorFunc(e,n)})},ne=function(n){i("=== User List ==="),n=r({},{token:"",page:1,limit:30},n);var s=r({},L,n),o="user_list/",c={app_id:k.app_id,session_key:k.guest_key,token:s.token,page:s.page,limit:s.limit};e(t(o),c,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(a,e.message):s.successFunc(e)},function(e,n){s.errorFunc(e,n)})},se=function(e,n){i("=== Upload File ===");var s=r({},L,n),t="upload_file/",c='{"app_id": "'+k.app_id+'"}',u=new FormData;u.append("meta",c),u.append("file",e);var g="",p=d+"v"+f.replace(/[^(0-9)]/gi,"")+"/"+t,l=void 0==s.async?!0:s.async,_=new XMLHttpRequest;_.open("POST",p,l),_.onload=function(){if(_.status>=a&&_.status<o){var n=_.responseText,t=JSON.parse(n);t.error?s.errorFunc(a,t.message):(g={error:!1,url:t.url},he({url:t.url,name:e.name,type:e.type,size:e.size,custom:""}),s.successFunc(g))}else s.errorFunc(_.status,_.statusText)},_.send(u)},te=function(){i("=== Typing Start ===");var e=(new Date).getTime();pe(h.TPST,{channel_id:F.id,time:e}),b=e,w=!0},ie=function(){i("=== Typing End ===");var e=(new Date).getTime();pe(h.TPEN,{channel_id:F.id,time:e}),b=0,w=!1},re=(setInterval(function(){var e=(new Date).getTime();w&&e-b>I&&ie()},I),function(n,s){i("=== Delete Message ===");var o=r({},L,s),c="message_delete/",u={app_id:k.app_id,session_key:k.guest_key,msg_id:n};e(t(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?o.errorFunc(a,e.message):o.successFunc(e)},function(e,n){o.errorFunc(e,n)})}),ae=function(e){i("=== Web Socket Connect ==="),ge();var n=r({},L,e);y=new WebSocket(p+v+k.app_id+"&key="+k.guest_key),y.onopen=function(e){le(k.guest_key);var s=(new Date).getTime();if(void 0===F.id||fe(F.id,s)){var t={};n.successFunc(t)}else n.errorFunc(o,"WebSocket is not connected yet.");me(!0)},y.onmessage=function(e){T=(new Date).getTime();for(var n=e.data.split("\n"),s=0;s<n.length;s++)if(0!=n[s].trim().length){var t=n[s].substring(0,4),i=n[s].substring(4);if(0!==t.trim().length||0!==i.trim().length)if(t===h.PONG)ve(!1);else if(t==h.MCUP){var r=JSON.parse(i);Q(r.channel_id)}else E(t,i)}},y.onerror=function(e){i("=== Web Socket onerror ==="),i(e),_isLeavingPage||ce(),me(!1),ve(!1)},y.onclose=function(e){i("=== Web Socket onclose ==="),i(e),_isLeavingPage||ce(),me(!1),ve(!1)}},oe=function(e){s="undefined"==typeof e?!0:e,i("=== Web Socket Disconnect ==="),ue()},ce=function(){s||(null==R?(i("=== Start Reconnect ==="),R=setTimeout(function(){ae(),R=null,i("=== Reconnect done ===")},3e3)):i("=== Reconnect is in progress. (skip) ==="))},ue=function(){y&&ge(),F={},M=0,O=null,P=null,R=null,N=0},ge=function(){y&&(y.close(),y.onmessage=function(e){},y.onopen=function(e){},y.onerror=function(e){},y.onclose=function(e){},y=null),M=0},de=function(){return y?y.readyState:WebSocket.CLOSED},pe=function(e,n){var s=e+JSON.stringify(n)+"\n";try{if(1!=y.readyState)return!1;y.send(s)}catch(t){return i(t),!1}return!0},le=function(e){pe(h.LOGI,{key:e})},fe=function(e,n){return pe(h.JOIN,{channel_id:e,last_ts:n})},_e=function(){var e=(new Date).getTime();N=e,pe(h.PING,{id:e})},me=function(e){null!=O&&(clearInterval(O),O=null),e?(i("=== Start Pinger ==="),O=setInterval(function(){var e=(new Date).getTime(),n=e-T,s=parseInt(n/1e3);s>0&&s%15==0&&(i(h.PING),_e(),ve(!0))},1e3)):i("=== Stop Pinger ===")},ve=function(e){null!=P&&(clearInterval(P),P=null),e?(i("=== Start Watchdog ==="),P=setInterval(function(){var e=(new Date).getTime(),n=e-T,s=parseInt(n/1e3);s>=20&&(i("=== Watchdog Barks! ==="),me(!1),ce())},4500)):i("=== Watchdog ===")},Se=function(e,n){"string"!=typeof e&&(e=e.toString()),n=n||"";var s=pe(h.MESG,{channel_id:F.id,message:e,data:"",tid:n});B.onMessageDelivery({sent:s,message:e,data:"",id:n}),s&&F.isMessaging&&setTimeout(function(){ie()},100)},ye=function(e,n,s){"string"!=typeof e&&(e=e.toString()),s=s||"";var t=pe(h.MESG,{channel_id:F.id,message:e,data:n,tid:s});B.onMessageDelivery({sent:t,message:e,data:n,tid:s}),t&&F.isMessaging&&setTimeout(function(){ie()},100)},he=function(e){pe(h.FILE,{channel_id:F.id,name:e.name,url:e.url,type:e.type,size:e.size,custom:e.custom})},ke=function(e){n=e},Fe=function(e){var n=e.substring(0,4),s=JSON.parse(e.substring(4));return{cmd:n,payload:s}},Te=function(e){return e==h.MESG},Me=function(e){return e==h.FILE},Oe=function(e){var n=e.url.split("."),s=n[n.length-1];return"png"==s||"jpeg"==s||"jpg"==s||"gif"==s||"bmp"==s?!0:e.type.indexOf("image")>=0},Pe=function(e){return e==J},Re=function(e){return e==D},Ne=function(e){var n=!1;try{n=JSON.parse(F.data).freeze}catch(s){n=!1}e({channel_url:F.channel_url,cover_img_url:F.cover_img_url,member_count:F.member_count,name:F.name,isMessaging:F.isMessaging,max_length_message:F.max_length_message,freeze:n})},we=function(e){e({guest_id:k.guest_id,image_url:k.image_url,nickname:k.user_name})},be=function(e){k.gcm_reg_token=e},Ie=function(e){k.apns_device_token=e},Ce="[version] "+m,Ee=function(e){M="string"==typeof e?parseInt(e):e};return{version:Ce,events:B,joinChannel:A,leaveChannel:U,getMemberList:x,getChannelSearch:W,getChannelList:z,joinMessagingChannel:q,startMessaging:H,inviteMessaging:X,endMessaging:Z,getMessagingChannelList:K,getPrivateChannelList:$,markAsRead:V,getMessageLoadMore:ee,getUserList:ne,sendFile:se,typeStart:te,typeEnd:ie,deleteMessage:re,connect:ae,disconnect:oe,message:Se,messageWithData:ye,sendFileURL:he,setDebugMessage:ke,isMessage:Te,isFileMessage:Me,hasImage:Oe,isGroupMessaging:Pe,isGroupMessagingChannel:Pe,isMessagingChannel:Re,getChannelInfo:Ne,getUserInfo:we,getConnectionState:de,registerGCMToken:be,registerAPNSToken:Ie,init:g,setMinMessageTs:Ee}};return c}); | ||
var _isLeavingPage=!1;"object"==typeof window&&(window.onbeforeunload=function(){_isLeavingPage=!0}),function(e,n){"function"==typeof define&&define.amd?define([],n()):"object"==typeof exports?module.exports=n().getInstance():(e.SB=n(),e.sendbird=e.SB.getInstance())}(this,function(){function e(){var e=navigator.userAgent.toLowerCase();return-1!=e.indexOf("msie")?parseInt(e.split("msie")[1]):!1}function n(n,s,t,i,r,a){var u=new XMLHttpRequest;if(!("withCredentials"in u)&&e()<10){u=new XDomainRequest,u.withCredentials=!0;try{switch(t.toLowerCase()){case"get":u.open("GET",n);break;default:u.open("POST",n)}}catch(g){u.open("POST",n)}for(var d in i)s[d]=i[d];u.onload=function(){var e=JSON.parse(u.responseText);e.error?a(u.status,u.statusText):r(e)},u.onerror=function(){a(404,"There was a connection error")}}else{try{switch(u=new XMLHttpRequest,t.toLowerCase()){case"get":u.open("GET",n);break;default:u.open("POST",n)}u.onload=function(){if(u.status>=o&&u.status<c){var e=u.responseText;r(JSON.parse(e))}else a(u.status,u.statusText)},u.onerror=function(){a(404,"There was a connection error")}}catch(p){u=new ActiveXObject("Microsoft.XMLHTTP");try{switch(t.toLowerCase()){case"get":u.open("GET",n);break;default:u.open("POST",n)}}catch(g){u.open("POST",n)}u.onreadystatechange=function(){if(4==u.readyState)if(u.status>=o&&u.status<c){var e=u.responseText;r(JSON.parse(e))}else a(u.status,u.statusText)}}u.setRequestHeader("Content-Type","text/plain; charset=UTF-8");for(var d in i)u.setRequestHeader(d,i[d])}switch(t.toLowerCase()){case"get":u.send();break;default:u.send(JSON.stringify(s))}}var s=!1,t=!1,i=window.console||{log:function(){}},r=function(e){s&&i.log(e)},a=function(e){e=e||{};for(var n=arguments.length,s=1;n>s;s++)if(arguments[s])for(var t in arguments[s])arguments[s].hasOwnProperty(t)&&(e[t]=arguments[s][t]);return e};"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});var o=200,c=400,u=function(){function e(){var e=new g;return e}var n,s=function(s){var t=a({},{newInstance:!1},s);return t.newInstance?e():(n||(n=e()),n)};return{getInstance:s}}(),g=function(){function e(e){return u(_+k.app_id),d+"v"+f.replace(/[^(0-9)]/gi,"")+"/"+e}function i(e){return u(_+k.app_id),d+"v3/"+e}function u(e,s,t){if(l)p="ws://localtest.me:9000",d="http://api.localtest.me:8000/","function"==typeof s&&s();else{var i=(new Date).getTime()/1e3;0==C||C-i>3?n(e,{},"GET",{SendBird:S+k.app_id},function(e){p=e.ws_server,d=e.api_server+"/",r("Routing Info Update: "+p+", "+d),C=i,"function"==typeof s&&s()},function(e,n){"function"==typeof t&&t(e,n)}):"function"==typeof s&&s()}}function g(e){k.app_id=e.app_id,k.guest_id=e.guest_id,k.user_name=e.user_name,k.image_url=void 0==e.image_url||null==e.image_url?"":e.image_url,k.access_token=void 0==e.access_token||null==e.access_token?"":e.access_token,G({successFunc:function(n){e.successFunc(n)},errorFunc:function(n,s){e.errorFunc(n,s)},async:e.async})}var d,p,l=!1,f="1",_="https://sbrouting.sendbird.com/app/",m="2.4.8",v="/?p=JS&pv="+encodeURI(navigator.userAgent)+"&sv="+m+"&ai=",S="JS,"+encodeURI(navigator.userAgent)+","+m+",",h=null,y={MESG:"MESG",FILE:"FILE",LOGI:"LOGI",JOIN:"JOIN",SYSM:"SYSM",BRDM:"BRDM",MCUP:"MCUP",READ:"READ",TPST:"TPST",TPEN:"TPEN",BAAN:"BAAN",FREZ:"FREZ",PING:"PING",PONG:"PONG"},k={},F={},T=0,M=0,O=null,P=null,R=null,w=0,N=!1,b=0,I=1e4,C=0,L=function(e,n){switch(e){case y.MESG:B.onMessageReceived(JSON.parse(n));break;case y.SYSM:B.onSystemMessageReceived(JSON.parse(n));break;case y.FILE:B.onFileMessageReceived(JSON.parse(n));break;case y.BRDM:B.onBroadcastMessageReceived(JSON.parse(n));break;case y.TPST:B.onTypeStartReceived(JSON.parse(n));break;case y.TPEN:B.onTypeEndReceived(JSON.parse(n));break;case y.PONG:r(y.PONG);break;case y.READ:B.onReadReceived(JSON.parse(n));break;case y.BAAN:B.onBanReceived(JSON.parse(n));break;case y.FREZ:var s=JSON.parse(n),t=!1;try{t=s.freeze}catch(i){t=!1}F.data=JSON.stringify({freeze:t}),B.onChannelFreezeReceived(s);break;default:B.onUndefinedMessageReceived(e,JSON.parse(n))}return JSON.parse(n)},E={successFunc:function(e){},errorFunc:function(e,n){r(e),r(n)}},B={onMessageReceived:function(e){r(e)},onSystemMessageReceived:function(e){r(e)},onFileMessageReceived:function(e){r(e)},onBroadcastMessageReceived:function(e){r(e)},onReadReceived:function(e){r(e)},onMessagingChannelUpdateReceived:function(e){r(e)},onTypeStartReceived:function(e){r(e)},onTypeEndReceived:function(e){r(e)},onMessageDelivery:function(e){r(e)},onBanReceived:function(e){r(e)},onChannelFreezeReceived:function(e){r(e)},onUndefinedMessageReceived:function(e,n){r(e),r(n)}},J=6,D=5,G=function(s){r("=== Start SendBird SDK ===");var t=a({},E,s),i="guest_login/",c={guest_id:k.guest_id,app_id:k.app_id,nickname:k.user_name,image_url:k.image_url,access_token:k.access_token};void 0!=k.gcm_reg_token&&""!=k.gcm_reg_token&&(c.gcm_reg_token=k.gcm_reg_token),void 0!=k.apns_device_token&&""!=k.apns_device_token&&(c.apns_device_token=k.apns_device_token),u(_+k.app_id,function(){n(e(i),c,"POST",{SendBird:S+k.app_id},function(e){e.error?t.errorFunc(o,e.message):(k.guest_key=e.key,t.successFunc({}))},function(e,n){t.errorFunc(e,n)})},function(e,n){t.errorFunc(e,n)})},A=function(s,t){r("=== Join Channel ===");var i=a({},E,t),c="channel_join/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:s},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(e.isMessaging=!1,a(F,e),g=F,i.successFunc(g))},function(e,n){i.errorFunc(e,n)})},x=function(s,t){r("=== Leave Channel ===");var i=a({},E,t),c="channel_leave",u={app_id:k.app_id,session_key:k.guest_key,channel_url:s},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(g=e,i.successFunc(g))},function(e,n){i.errorFunc(e,n)})},U=function(s,t){r("=== Member List ===");var i=a({},E,t),c="member_list/",u={app_id:k.app_id,channel_url:s},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(g=e,i.successFunc(g))},function(e,n){i.errorFunc(e,n)})},W=function(s){r("=== Channel List ==="),s=a({},{limit:20,page:1,query:""},s);var t=a({},E,s),i="channel_list/",c={app_id:k.app_id,page:t.page,limit:t.limit,query:t.query},u={};n(e(i),c,"POST",{SendBird:S+k.app_id},function(e){e.error?t.errorFunc(o,e.message):(u=e,t.successFunc(u))},function(e,n){t.errorFunc(e,n)})},z=function(e){W(e)},j=function(e){return void 0!=e.last_message&&""!=e.last_message&&(e.last_message=JSON.parse(e.last_message.substring(4))),e},q=function(s,t){r("=== Join Messaging Channel ===");var i=a({},E,t),c="messaging_join/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:s},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(e.channel.isMessaging=!0,a(F,e.channel),g=e,i.successFunc(j(g)))},function(e,n){i.errorFunc(e,n)})},H=function(s,t){r("=== Start Messaging ==="),s=s instanceof Array?s:new Array(s);var i=a({},E,t),c="messaging_start/",u={app_id:k.app_id,session_key:k.guest_key,guest_ids:s},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(a(F,e.channel),g=e,i.successFunc(j(g)))},function(e,n){i.errorFunc(e,n)})},X=function(e,n,s){if(2==arguments.length){var t=arguments[1].channel_url;(void 0==t||""==t)&&(t=F.channel_url),Y(arguments[0],t,arguments[1])}else Y(e,n,s)},Y=function(s,t,i){r("=== Invite Messaging ==="),s=s instanceof Array?s:new Array(s);var c=a({},E,i),u="messaging_invite/",g={app_id:k.app_id,session_key:k.guest_key,channel_url:t,guest_ids:s},d={};n(e(u),g,"POST",{SendBird:S+k.app_id},function(e){e.error?c.errorFunc(o,e.message):(a(F,e.channel),d=e,c.successFunc(j(d)))},function(e,n){c.errorFunc(e,n)})},Z=function(s,t){r("=== End Messaging ===");var i=a({},E,t),c="messaging_end/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:s},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(a(F,e),g=e,i.successFunc(j(g)))},function(e,n){i.errorFunc(e,n)})},K=function(s){r("=== Messaging Channel List ==="),s=a({},{limit:9999,page:1},s);var t=a({},E,s),i="messaging_list/",c={app_id:k.app_id,session_key:k.guest_key,page:t.page,limit:t.limit},u={};n(e(i),c,"POST",{SendBird:S+k.app_id},function(e){e.error?t.errorFunc(o,e.message):(u=e,u.channels.forEach(function(e,n){e=j(e)}),t.successFunc(u))},function(e,n){t.errorFunc(e,n)})},$=function(e){r("=== Messaging Channel List ==="),e=a({},{limit:9999,page:1},e);var s=a({},E,e),t="messaging_list/",c={app_id:k.app_id,session_key:k.guest_key,page:s.page,limit:s.limit},u={};n(i(t),c,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(o,e.message):(u=e,u.channels.forEach(function(e,n){e=j(e)}),s.successFunc(u))},function(e,n){s.errorFunc(e,n)})},Q=function(s,t){r("=== Messaging Channel Info ===");var i=a({},E,t),c="messaging_info/",u={app_id:k.app_id,session_key:k.guest_key,channel_id:s};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):B.onMessagingChannelUpdateReceived(j(e))},function(e,n){i.errorFunc(e,n)})},V=function(s,t){r("=== Message Mark As Read ===");var i=a({},E,t),c="mark_as_read/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:s},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(g=e,i.successFunc(g))},function(e,n){i.errorFunc(e,n)})},ee=function(s){r("=== Message Load More ==="),s=a({},{limit:20},s);var t=a({},E,s),i=(new Date).getTime(),c="message_list",u={app_id:k.app_id,session_key:k.guest_key,channel_url:F.channel_url,message_ts:0==M?i:M,prev_limit:t.limit,next_limit:0,include:!1},g=[];n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?t.errorFunc(o,e.message):(e.messages.forEach(function(e,n){var s=JSON.parse(e.substring(4));0==M?M=s.ts:M>s.ts&&(M=s.ts),g.push(Fe(e))}),t.successFunc({messages:g}))},function(e,n){t.errorFunc(e,n)})},ne=function(s){r("=== User List ==="),s=a({},{token:"",page:1,limit:30},s);var t=a({},E,s),i="user_list/",c={app_id:k.app_id,session_key:k.guest_key,token:t.token,page:t.page,limit:t.limit};n(e(i),c,"POST",{SendBird:S+k.app_id},function(e){e.error?t.errorFunc(o,e.message):t.successFunc(e)},function(e,n){t.errorFunc(e,n)})},se=function(e,n){r("=== Upload File ===");var s=a({},E,n),t="upload_file/",i='{"app_id": "'+k.app_id+'"}',u=new FormData;u.append("meta",i),u.append("file",e);var g="",p=d+"v"+f.replace(/[^(0-9)]/gi,"")+"/"+t,l=void 0==s.async?!0:s.async,_=new XMLHttpRequest;_.open("POST",p,l),_.onload=function(){if(_.status>=o&&_.status<c){var n=_.responseText,t=JSON.parse(n);t.error?s.errorFunc(o,t.message):(g={error:!1,url:t.url},ye({url:t.url,name:e.name,type:e.type,size:e.size,custom:""}),s.successFunc(g))}else s.errorFunc(_.status,_.statusText)},_.send(u)},te=function(){r("=== Typing Start ===");var e=(new Date).getTime();pe(y.TPST,{channel_id:F.id,time:e}),b=e,N=!0},ie=function(){r("=== Typing End ===");var e=(new Date).getTime();pe(y.TPEN,{channel_id:F.id,time:e}),b=0,N=!1},re=(setInterval(function(){var e=(new Date).getTime();N&&e-b>I&&ie()},I),function(s,t){r("=== Delete Message ===");var i=a({},E,t),c="message_delete/",u={app_id:k.app_id,session_key:k.guest_key,msg_id:s};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):i.successFunc(e)},function(e,n){i.errorFunc(e,n)})}),ae=function(e){r("=== Web Socket Connect ==="),ge();var n=a({},E,e);h=new WebSocket(p+v+k.app_id+"&key="+k.guest_key),h.onopen=function(e){le(k.guest_key);var s=(new Date).getTime();if(void 0===F.id||fe(F.id,s)){var t={};n.successFunc(t)}else n.errorFunc(c,"WebSocket is not connected yet.");me(!0)},h.onmessage=function(e){T=(new Date).getTime();for(var n=e.data.split("\n"),s=0;s<n.length;s++)if(0!=n[s].trim().length){var t=n[s].substring(0,4),i=n[s].substring(4);if(0!==t.trim().length||0!==i.trim().length)if(t===y.PONG)ve(!1);else if(t==y.MCUP){var r=JSON.parse(i);Q(r.channel_id)}else L(t,i)}},h.onerror=function(e){r("=== Web Socket onerror ==="),r(e),_isLeavingPage||ce(),me(!1),ve(!1)},h.onclose=function(e){r("=== Web Socket onclose ==="),r(e),_isLeavingPage||ce(),me(!1),ve(!1)}},oe=function(e){t="undefined"==typeof e?!0:e,r("=== Web Socket Disconnect ==="),ue()},ce=function(){t||(null==R?(r("=== Start Reconnect ==="),R=setTimeout(function(){ae(),R=null,r("=== Reconnect done ===")},3e3)):r("=== Reconnect is in progress. (skip) ==="))},ue=function(){h&&ge(),F={},M=0,O=null,P=null,R=null,w=0},ge=function(){h&&(h.close(),h.onmessage=function(e){},h.onopen=function(e){},h.onerror=function(e){},h.onclose=function(e){},h=null),M=0},de=function(){return h?h.readyState:WebSocket.CLOSED},pe=function(e,n){var s=e+JSON.stringify(n)+"\n";try{if(1!=h.readyState)return!1;h.send(s)}catch(t){return r(t),!1}return!0},le=function(e){pe(y.LOGI,{key:e})},fe=function(e,n){return pe(y.JOIN,{channel_id:e,last_ts:n})},_e=function(){var e=(new Date).getTime();w=e,pe(y.PING,{id:e})},me=function(e){null!=O&&(clearInterval(O),O=null),e?(r("=== Start Pinger ==="),O=setInterval(function(){var e=(new Date).getTime(),n=e-T,s=parseInt(n/1e3);s>0&&s%15==0&&(r(y.PING),_e(),ve(!0))},1e3)):r("=== Stop Pinger ===")},ve=function(e){null!=P&&(clearInterval(P),P=null),e?(r("=== Start Watchdog ==="),P=setInterval(function(){var e=(new Date).getTime(),n=e-T,s=parseInt(n/1e3);s>=20&&(r("=== Watchdog Barks! ==="),me(!1),ce())},4500)):r("=== Watchdog ===")},Se=function(e,n){"string"!=typeof e&&(e=e.toString()),n=n||"";var s=pe(y.MESG,{channel_id:F.id,message:e,data:"",tid:n});B.onMessageDelivery({sent:s,message:e,data:"",id:n}),s&&F.isMessaging&&setTimeout(function(){ie()},100)},he=function(e,n,s){"string"!=typeof e&&(e=e.toString()),s=s||"";var t=pe(y.MESG,{channel_id:F.id,message:e,data:n,tid:s});B.onMessageDelivery({sent:t,message:e,data:n,tid:s}),t&&F.isMessaging&&setTimeout(function(){ie()},100)},ye=function(e){pe(y.FILE,{channel_id:F.id,name:e.name,url:e.url,type:e.type,size:e.size,custom:e.custom})},ke=function(e){s=e},Fe=function(e){var n=e.substring(0,4),s=JSON.parse(e.substring(4));return{cmd:n,payload:s}},Te=function(e){return e==y.MESG},Me=function(e){return e==y.FILE},Oe=function(e){var n=e.url.split("."),s=n[n.length-1];return"png"==s||"jpeg"==s||"jpg"==s||"gif"==s||"bmp"==s?!0:e.type.indexOf("image")>=0},Pe=function(e){return e==J},Re=function(e){return e==D},we=function(e){var n=!1;try{n=JSON.parse(F.data).freeze}catch(s){n=!1}e({channel_url:F.channel_url,cover_img_url:F.cover_img_url,member_count:F.member_count,name:F.name,isMessaging:F.isMessaging,max_length_message:F.max_length_message,freeze:n})},Ne=function(e){e({guest_id:k.guest_id,image_url:k.image_url,nickname:k.user_name})},be=function(e){k.gcm_reg_token=e},Ie=function(e){k.apns_device_token=e},Ce="[version] "+m,Le=function(e){M="string"==typeof e?parseInt(e):e};return{version:Ce,events:B,joinChannel:A,leaveChannel:x,getMemberList:U,getChannelSearch:W,getChannelList:z,joinMessagingChannel:q,startMessaging:H,inviteMessaging:X,endMessaging:Z,getMessagingChannelList:K,getPrivateChannelList:$,markAsRead:V,getMessageLoadMore:ee,getUserList:ne,sendFile:se,typeStart:te,typeEnd:ie,deleteMessage:re,connect:ae,disconnect:oe,message:Se,messageWithData:he,sendFileURL:ye,setDebugMessage:ke,isMessage:Te,isFileMessage:Me,hasImage:Oe,isGroupMessaging:Pe,isGroupMessagingChannel:Pe,isMessagingChannel:Re,getChannelInfo:we,getUserInfo:Ne,getConnectionState:de,registerGCMToken:be,registerAPNSToken:Ie,init:g,setMinMessageTs:Le}};return u}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82431
15