Skip to content

Instantly share code, notes, and snippets.

@JshWright
Created May 28, 2010 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JshWright/417503 to your computer and use it in GitHub Desktop.
Save JshWright/417503 to your computer and use it in GitHub Desktop.
var client = new APE.Client();
client.load();
client.addEvent('load', function() {
posted_by = prompt('Your name?');
client.core.start({"name": posted_by});
$("input[name='posted_by']").val(posted_by);
});
client.addEvent('ready', function() {
//Once APE is ready, join the messages channel and wait for new messages
client.core.join('messages');
client.onRaw('postmsg', function(raw, pipe) {
append_message(raw.data);
});
});
function append_message(data) {
message_str = data.msg + '\nPosted by: <strong>'
+ data.posted_by + '</strong> on: '
+ data.timestamp;
new_div = $('<div>').addClass('message').html(message_str);
$('div#current_messages').append(new_div);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment