The MSN Messenger Protocol Torn Apart: Part 1/3 - Change Your Initial Status (Page 4 of 7 )
After we are authenticated, the first thing we do is to change our current status. We have a command called CHG. This command helps us to change our current status. This is what we sent to the server to change our initial status:
CHG 7 NLN
We have the command identifier CHG. We have the unique transaction id. We also have a parameter called "NLN". NLN tells the server to change our status to online. Like NLN, we have various parameters for other statuses. For example this would be the command we would send the server if we wanted to change our status to Hidden or Invisible:
CHG 7 HDN
Yes, HDN is the parameter we send to tell the server to change our status to Hidden/Invisible. There is a list of these parameters and what each one does in Microsoft's official draft on the protocol. I have attached the same at the end of this article.
The server then sends us back this reply confirming the status change:
CHG 7 HDN
The reply consists of the command identifier, the transaction id and the current status of the user.
Retrieval of a Few Important Server Messages By now, the client should be ready for a few messages from the server. What are these messages? Well, we could regard them as commands sent to us by the server but commands having a different format. We have seen the standard command format, which looks like this:
The message command doesn't in anyway look like this. If we see one such message we would be able to understand the format. As soon as we notify the server of our initial status, the server sends us this message command:
This is what the command looks like. We first have MSG, which is the command identifier. The next two parameters, say Hotmail and Hotmail and finally the number 450. The number 450 denotes the total number of bytes in the entire message excluding the current line (The line which has MSG in it, the first line).
Next, we have the mime version and content-type. The mime version would be same in all cases but the mime content-type is "text/x-msmsgsprofile" in this case. The char set of the message is mentioned in the same line thereafter. All the lines after that consist of the mime body.
This message, which the server sent us contains details about the .NET passport we signed into. The body of this message thus contains details of the user signed in like age, gender, birthday, postal code etc.
Another such message we should be ready to except is the following one:
Again, like all other message commands, this one consists of the command identifier, the two Hotmail parameters and the total number of bytes on the first line. Next we have a mime version, which is the same in all messages and the Content-Type, which is "text/x-msmsgsinitialemailnotification" in this case. We also have the char set on the same line thereafter.
This message contains details about email in the inbox of the user. You must have noticed when you login into your messenger account and you have any new unread mails you are prompted. Well this is the message responsible for that prompt. You see the string Inbox-Unread :0 in the mime body. That shows there are 0 unread mails in your inbox. This message also has a few other details about your inbox.
Again, these are messages that your client may or may not want to respond to. I have just included these in this article to let you know about the entire process in detail. In your version of msn messenger itís entirely up to you to prompt the user about new mail. In this case if you donít want your messenger to care about new unread mails in your inbox then you could ignore these messages. The first message sent to us by the server, which has the users .NET passport details passed through, is quite useless.