Since March 10, 2003 - Version 2.1
hypothetic.org

MSN Messenger Protocol

Resources - FAQ

Back To Normal Layout

Overview

This page serves to answer the most frequently asked questions. Below is a list of questions and their respective answers. Please read through this before asking someone an obvious question.

Submitting an Entry

We do not currently have a system for submitting entries. If you have a good question and response you would like to see here, please contact us.

Category

How can I parse incoming data as to separate commands without running into trouble with payload commands?

We recommend implementing your program in a manner similar to the one below.

Here is how Mike Mintz implements this in Python. The function read_buffer() is called every time there is data in the socket waiting to be read (determined by a select loop).

def read_buffer(self):
    lines = string.split(self.inbuffer, '\r\n')
    if len(lines) < 2:
        return
    words = string.split(lines[0])
    if self.inbuffer[:3] in ['MSG', 'NOT']: # Incoming payload commands
        length = int(words[3])
        remaining_lines = string.join(lines[1:], '\r\n')
        if len(remaining_lines) >= length:
            self.inbuffer = self.inbuffer[(len(lines[0]) + 2 + length):]
            self.cmd_handler(lines[0] + '\r\n' + remaining_lines[:length])
        else:
            return 0
    else:
        self.inbuffer = self.inbuffer[(len(lines[0]) + 2):]
        self.cmd_handler(lines[0])
    self.read_buffer()

Copyright ©2002-2004 to Mike Mintz.
<http://www.mikemintz.com/>