quote:
Originally posted by markee
@ deAd: Your code has a chance of not working properly. There is a chance that a contact sends a message between these events being called and that will cause problems.
This is highly, highly, highly unlikely. Right from the Plus! documentation:
quote:
Originally posted by Documentation
Because Messenger Plus! analyses messages received only when they reach the chat window, it is not possible to determine exactly from which contact the message came from. However, several methods can be used to guess if the message was actually sent by the current user. For example, to determine whether or not the personalized status messages should be sent when a message is received, Messenger Plus! compares the time of the last ChatWndSendMessage event with the current time. If it is less than 1 second, the message is considered to come from the current user and the previously recorded time is reset. Even if this method of analysis can seem too simplistic, it works in almost every scenario as it is extremely rare to receive a message sent by a contact between the time the "Send" button was pressed and the time the message of the current user was added to the window (as Messenger does not wait to receive a reply from the server before adding the message to the history control).
The code I posted works in a similar way to what Plus! describes. However, instead of using a timer, it simply checks the next message. In this way, it is susceptible to the same
extremely rare problem that Plus!'s detection has, but also accounts for messenger hanging for any reason and the message being delivered after more than just a second.
The way you are doing it is more prone to error and confusion because somebody can set their name/chat-only name to yours. The chance of this is much, much higher than the chance of a message being received between the time the Send button was pressed and the sent message is added to the history box.