• Register
  • Log In
  • Home
  • Quick Start
    • Configurator
    • Download YUI 3
  • Documentation
    • User Guides
    • Examples
    • API Docs
    • Environments
    • Tutorials
  • Community
    • Gallery
    • Blog
    • Forums
    • YUI Theater
    • Calendar
  • Contribute
    • YUI on GitHub »
    • File a Ticket
    • View Tickets
    • Dashboard
  • Other Projects
    • Shifter »
    • Yogi »
    • YUI 2
    • YUI Doc »
    • YUI Test
    • YUI Website
    • YUI Compressor »
    • YUI Builder »
    • YUI PHP Loader
    • Grid Builder »
    • Skin Builder »
  • YUI
  • >
  • Community
  • >
  • Gallery

Gallery

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • Yogi Documentation
  • Shifter Documentation
  • Developer Guide
  • Module Setup

Tag Cloud

Context Navigation

    YUI Library is not responsible for bugs or support with this module. It is available as a free service. For support please contact the module owner with the provided links.

    Live Messaging (gallery-live-messaging)

    Last Updated: 09/22/11
    + 0 -

    alejandro soto gonzalez

    YUI Contributor

    See 2 more by this user.

    Created: 08/16/11
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.4.1 PR1
    Free for use.

    With this module you only have to define the callback methods to show the messages that are being pulled from the server side, PHP in this case, or the configuration to publish messages to the live channel. However you will have to modify the max_execution_time variable in the PHP configuration (php.ini) to create a messages pool in your server. Is an alternative to develop rich applications with YUI 3 and to synchronize the browsers in order to have more responsive RIAs in real time.

    • Tags:
    • asotog88
    • Download
    • Docs
    • Homepage
    • Bugs
    • Source
    • Example
    • Forum
    • History

    As you can see, you only have to define the events in order to get the messages published by other clients or the event to know if a message was successfully sent.

    Code Sample

    YUI().use('gallery-live-messaging', function(Y) {
     
     
        function successEvent(event){
            //inject messages in the markup
            var ul =  Y.one('#list ul');
            ul.set('innerHTML', ul.get('innerHTML') + '<li>' + event.result.data + '</li>' )
        }
     
        function messageSentEvent(event){
            //message successfully sent
        }
     
        function messageSentErrorEvent(event){
            alert(event.message);
        }
     
        /* DOM READY TRIGGER */
        Y.on('domready', function() {
     
        	//configuration to publish messages
    	    var externalPublisherCfg = {
    	      channel : 'default',
    	      //dispatcher url
    	      url : 'back-end/dispatcher.php',
    	      //events
    	      success : messageSentEvent,
    	      error : function(){},
    	      complete : function(){} ,
    	      method : 'GET',
    	      //infinite timeout
    	      timeout : 0 // 0 to infinite timeout
    	    };
     
    	    //configuration to subscribe to messages
    	    var externalSubscriberCfg = {
    	        channel : 'default',
    	        //dispatcher url
    	        url : 'back-end/dispatcher.php',
    	        //events
    	        success : successEvent,
    	        error : function(event){},
    	        complete : function(event){},
    	        method : 'GET',
    	        //infinite timeout
    	        timeout : 0 // 0 to infinite timeout
    	        };
     
    	    //initializes the messaging object
        	var msgObject = new Y.messagingObject();
        	msgObject.publishToChannel(externalPublisherCfg);
        	msgObject.subscribeToChannel(externalSubscriberCfg);
        	msgObject.connect();
     
        	Y.one('#boton').on('click',function(e){
        		e.preventDefault();
        		msgObject.send(Y.one('#texto').get('value'));
        		Y.one('#texto').set('value','');
        	});
        });
     
    });

    © 2006-2013 Yahoo! Inc. All rights reserved.
    All code on this site is licensed under the BSD License unless stated otherwise.
    About This Site · Security Contact Info