var _login = prompt( "What's your username for this demo ?" );
$.wesbmessenger.singleton()
// Connect on the WorkESB server
.connect( 'com.worbesb.demo', 'CHAT', {
server: "ws://marcbuils.no-ip.org:80/"
} )
// Bind talk on workesb to add
.bind( 'talk', function( p_text ){
$( '#conversation' ).prepend( $( '<li />' ).text( p_text ) );
})
.trigger( 'talk', '>>> ' + _login + ' is now connected' );
// Trigger a talk event on the WorkESB server when the user write a new line
$( '#send_button' ).click( function(){
$.wesbmessenger.singleton().trigger( 'talk', _login + ': ' + $( '#send_text' ).val() );
});
<ul id="conversation">
</ul>
<div class="bottom">
<input type="text" id="send_text" />
<input type="button" id="send_button" value="send" />
</div>
#conversation {
list-style: none outside none;
box-shadow: 2px 2px 3px #555555;
height: 300px;
overflow: auto;
width: 440px;
margin-bottom: 10px;
}
#send_text {
width: 390px;
}
#send_button {
width: 48px;
}
External resources loaded into this fiddle: