You may have noticed that over the past few weeks I have been trying to build more
interactive elements into this blog, some of these include.
- Most viewed posts webpart.
- Rate a post.
- Highest Rated posts webpart.
- Concurrent user indicator.
- MSN client, online / offline status.
- Sessions per hour graph.
My intention was that this blog would start to expose more of the interesting content
and create a slight online presence awareness by subtly reacting to how it is interacted
with.
Most of the features I just listed are part of a Sqlite stats database that I’ve
been logging certain sessions/hits/ratings to. I hope to make this available in
the near future with a slightly improved version of the Sqlite datalayer.
But for now here is how to install the code I am using to control the MSN client
and a preview of the Concurrent user indicator.
How to install this webpart.
Step 1: Create yourself a new ‘bot’ msn account that your website
will use, than add yourself to the bot’s contact list.
Step 2: Add these 2 events to your Global.asax file
protected
void Session_OnStart()
{
kowitz.SingleUserBlog.Services.
OnlineUsers RecordUser(Session.SessionID);
kowitz.WebsiteMSN.
MSNInstance.SignOn();
}
protectedvoid Session_OnEnd()
{
kowitz.SingleUserBlog.Services. OnlineUsers.DeleteUser(Session.SessionID);
if (kowitz.SingleUserBlog.Services.SqliteBlogStatRecorder.ConcurrentUsers() <= 0)
{
kowitz.WebsiteMSN.MSNInstance SignOff();
}
}
Step 3: Copy the webpart control into the Webparts folder.
Copy the images into your images directory and copy the two dlls (kowitz.WebsiteMSN.dll
and XihSolutions.DotMSN.dll) into your Bin directory.
Step 4: Add the webpart to your Masterpage’s catalogue zone.
<uc1:MessengerOnlinePresenceID="MessengerOnlinePresence1"Title="Messenger Online Presence"runat="server"/>Step 5: Add this to your BlogConfiguration.xml file:
<MyMSNAccount>
MyMSNAccount@hotmail.com
</MyMSNAccount>
<BotMSNAccount>
msnbot@mywebsite.net
</BotMSNAccount>
<BotMSNPassword>mybotspassword
</BotMSNPassword>Step 6, Allowing your bot to message you when someone leaves feedback:
Add this line to the
void CommentForm1_CommentAdded() function
(just after the call to "Notifications.NotifyAdministrator(subject,
body);") in your Posts.aspx page.
kowitz.WebsiteMSN.MSNInstance.SendMeAMessage(body);
Finally
Your blog should now be logging onto MSN when there is at least 1 active session
on your site.
As I mentioned before, a lot more of the things I’ve added are part of the Sqlite
stats db / blog datalayer I’ve been making and hopefully I’ll also be releasing
this soon.
Download
MessengerOnlinePresence webpart