Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
en:comet:simple-php-chat-example [2017/05/18 04:25] levhav |
en:comet:simple-php-chat-example [2019/12/18 02:05] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | <rst>EN::12-Examples::005-PHP chat example</rst> | ||
| + | <rst>Header: PHP chat example</rst> | ||
| ====== PHP chat example ====== | ====== PHP chat example ====== | ||
| - | An example of using the [[https://github.com/CppComet/comet-server|CppComet]] server to create a chat. For more information about CppComet, see [[en|documentation]] | + | An example of using the [[https://github.com/CppComet/comet-server|CppComet]] server to create a chat. |
| - | [[https://jsfiddle.net/Levhav/o35kvmn2/17/|jsfiddle.net online demo]] | + | * [[https://jsfiddle.net/Levhav/o35kvmn2/17/|jsfiddle.net online demo]] |
| + | * [[https://github.com/CppComet/php-chat-example|Github repo]] | ||
| {{ :en:comet:chat.gif |chat demo}} | {{ :en:comet:chat.gif |chat demo}} | ||
| - | ===== Scheme of chat ===== | + | ====== Scheme of chat ====== |
| Typical scheme of chat: | Typical scheme of chat: | ||
| Line 20: | Line 23: | ||
| * Add message to database (optional) | * Add message to database (optional) | ||
| - | ==== Step 1. Connecting to the comet server ==== | + | ====== Step 1. Connecting to the comet server ====== |
| [[https://github.com/CppComet/comet-server|CppComet]] has cloud saas alternative that can be used for testing and demo access. In the following examples I will use demonstration access from https://comet-server.com for those who could not or were too lazy to [[https://github.com/CppComet/comet-server#building-from-source|deploy the server on their VPS]] | [[https://github.com/CppComet/comet-server|CppComet]] has cloud saas alternative that can be used for testing and demo access. In the following examples I will use demonstration access from https://comet-server.com for those who could not or were too lazy to [[https://github.com/CppComet/comet-server#building-from-source|deploy the server on their VPS]] | ||
| Line 38: | Line 41: | ||
| - | ==== Step 2. send message to server ==== | + | ====== Step 2. Send message to server ====== |
| * Send ajax query to php back-end | * Send ajax query to php back-end | ||
| Line 61: | Line 64: | ||
| - | ==== Step 3. receive message from comet server ==== | + | ====== Step 3. Receive message from comet server ====== |
| - | subscription Code to the pipe on comet server. This callback will be called when somebody send message into channel `simplechat` | + | Subscription code to the pipe on comet server. This callback will be called when somebody sends message into channel `simplechat` |
| <code JavaScript> | <code JavaScript> | ||
| Line 73: | Line 76: | ||
| </code> | </code> | ||
| - | ==== Full chat code ==== | + | ====== Full chat code ====== |
| <html> | <html> | ||
| Line 79: | Line 82: | ||
| </html> | </html> | ||
| - | ==== Links ==== | + | ====== Links ====== |
| * [[en:comet:javascript_api|JavaScript API]] | * [[en:comet:javascript_api|JavaScript API]] | ||