Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:comet:javascript_api [2018/02/17 01:25]
anastation468 [Getting a number of subscribers]
en:comet:javascript_api [2019/12/18 02:05] (current)
Line 107: Line 107:
 ====== Sending messages to channel from JS (pipes web_*) ====== ====== Sending messages to channel from JS (pipes web_*) ======
  
-The function web_pipe_send allows ​to send messages from JavaScript to channel by passing your server (directly calls comet server). It allows resending messages between clients without loading your server. Also owing to direct call to comet server, delivery time of message from client to client is minimal.+The function web_pipe_send allows ​sending ​messages from JavaScript to channel by passing your server (directly calls comet server). It allows resending messages between clients without loading your server. Alsoowing to direct call to comet server, delivery time of message from client to client is minimal.
  
 <note important>​Sending messages to channel from JavaScript is able when name of channel begins with “web_”. CometQL does not have any limitations in this case.</​note>​ <note important>​Sending messages to channel from JavaScript is able when name of channel begins with “web_”. CometQL does not have any limitations in this case.</​note>​
Line 133: Line 133:
 </​code>​ </​code>​
  
-Field server_info.user_id in incoming message fills out by some information besides zero just if message was sent to channel from JavaScript API and sender was authorized on comet server. Also it contains sender’s user_id.+Field server_info.user_id in incoming message fills out by some information besides zero just if message was sent to channel from JavaScript API and sender was authorized on comet server. Alsoit contains sender’s user_id.
 ====== Getting the last messages from channel ====== ====== Getting the last messages from channel ======
-The comet server includes possibility to activate ​storing the last N messages mechanism for some channels.+The comet server includes possibility to activated ​storing the last N messages mechanism for some channels.
 <note tip>​Logging of transferred messages may be activate by CometQL query to table “[[en:​comet:​cometql|pipes_settings]]”.</​note> ​ <note tip>​Logging of transferred messages may be activate by CometQL query to table “[[en:​comet:​cometql|pipes_settings]]”.</​note> ​
  
Line 144: Line 144:
 ======= Getting a number of subscribers ======= ======= Getting a number of subscribers =======
  
-The function “count_user_in_pipe” can helps to determine a number of subscribes for current channel.+The function “count_user_in_pipe” can help to determine a number of subscribes for current channel.
  
-Also this function has the first argument – name of channel and the second is callback function which holds an answer.+Alsothis function has the first argument – name of channel and the second is callback function which holds an answer.
 <code Javascript>​ <code Javascript>​
 cometApi.count_users_in_pipe("​web_chat_pipe",​ function(res) cometApi.count_users_in_pipe("​web_chat_pipe",​ function(res)
Line 176: Line 176:
 These functions will be called when authorization status will be changing. I.e. at least once an authorization will be successful or unsuccessful when connecting to comet server or while status will be changed. ​ These functions will be called when authorization status will be changing. I.e. at least once an authorization will be successful or unsuccessful when connecting to comet server or while status will be changed. ​
  
-Also you can call the function “isAuthorized” to determine authorization status.+You can also call the function “isAuthorized” to determine authorization status.
 <code JavaScript>​cometApi.isAuthorized()</​code>​ <code JavaScript>​cometApi.isAuthorized()</​code>​
 The function “isAuthorized” may return 3 different values: ​ The function “isAuthorized” may return 3 different values: ​
   * false – authorization is not complete;   * false – authorization is not complete;
-  * true authorization is complete;+  * true – authorization is complete;
   * undefined – the status in undefined – this answer returns even before an attempt to connect to comet server.   * undefined – the status in undefined – this answer returns even before an attempt to connect to comet server.