css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

<h3>Auth chat</h3>
<div class="note">
    <p><a href="https://github.com/CppComet/auth-example">Git repository with all code of this example.</a></p> 
    <p>In this example show how authenticate on CppComet and how send personal messages to users via CppComet</p> 
        <li><a href="http://comet-server.org/doku.php/en" target="_blank">More info about CppComet</a></li>
        <li><a href="http://comet-server.org/doku.php/en:comet:cometql"  target="_blank">More info about CometQL</a></li>
        <li><a href="http://comet-server.org/doku.php/en:comet:authentication"  target="_blank">More info about auth in CppComet</a></li> 
        Open the example in two or more browsers, Copy your `USER_ID` from one 
        window and paste it into another window in the field labeled 
        'Identificator of user who must will receive the message` 
        enter the message text and press send. You will see that the message 
        will come only to the window with the same USER_ID you specified when 
        sending it.
<div class="root"> 
    <div><span id="userId"></span> - use this id to send message</div>
    <div class="status">
        We are waiting for authorization on the comet server
    <input type="text" placeholder="Message" id="text"> - Personal text message for user<br>
    <input type="text" placeholder="user_id" id="to_user_id"> - Identificator of user who must will receive the message<br>
    <button onclick="send($('#to_user_id').val(), $('#text').val())">Send</button>
    <div id="log"></div>



    padding:1px 10px;
function log()

// Authorization on comets server
function auth()
    var user_id = 0;
        user_id = localStorage['user_id']
        user_id = Math.floor(Math.random()*1000000)
        user_id = Math.floor(Math.random()*1000000)
        localStorage['user_id'] = user_id

    $("#userId").text("USER_ID = "+user_id);
    log("Request authorization for user_id="+user_id)
    var user_key = "PassForUser"+user_id

    //  The first step – it is sending user’s ID and a random hash in your system to the comet-server via CometQL.
    //  auth.php ( https://github.com/CppComet/auth-example/blob/master/auth.php )
    return $.when($.ajax({
        url: "https://comet-server.com/doc/CometQL/auth-chat/auth.php?user_id="+user_id+"&user_key="+user_key+"&t="+Math.floor(Math.random()*1000000),
        type: "GET",
        $(".status").html("We are waiting for connection to the comet server");
        // The function start accepts connection settings and opens new connection. 
        // https://comet-server.com/wiki/doku.php/en:comet:javascript_api#connection_with_server
            node: "app.comet-server.ru",
            dev_id: 15,

 * @param {integer} user_id  
 * @param {string} text 
function send(user_id, text)
    // Send message
    // send.php ( https://github.com/CppComet/auth-example/blob/master/send.php )
        url: "https://comet-server.com/doc/CometQL/auth-chat/send.php?user_id="+user_id+"&msg="+text+"&t="+Math.floor(Math.random()*1000000),
        type: "GET", 

    // We will initialize the call after successful authorization on the comet server.
    log("Authorization on the comet server is complete")
    $(".status").html("Authorization on the comet server is complete");
    cometApi.getTrackPipeUsers("track_authExample", function(){

cometApi.subscription("msg.message", function(e){ 

cometApi.subscription("track_authExample.subscription", function(msg)

cometApi.subscription("track_authExample.unsubscription", function(msg)


🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................