Click here to Skip to main content
15,884,099 members
Articles / Programming Languages / Visual Basic
Article

YCC Trainer – Tutorial for Yahoo! Messenger

Rate me:
Please Sign up or sign in to vote.
4.64/5 (10 votes)
21 May 2007GPL34 min read 101.1K   3.8K   40   31
YCC Trainer is a sample application showing you how to program for the Yahoo! Messenger protocol

Screenshot - YCC_Trainer_main.gif

Introduction

YCC Trainer is designed to teach the logic needed to make your own Yahoo! Messenger client. YCC Trainer is geared towards programmers with little to moderate experience and an understanding of the .NET languages. YCC Trainer is written in Visual Basic .NET 2005 and is part of a larger project at Yahoo! Coder's Cookbook (www.ycoderscookbook.com) intended to teach you everything you need to know about the Yahoo! Messenger protocol. The Yahoo! Messenger protocol version used by YCC Trainer is 15.

YCC Trainer Program Structure

YCC Trainer currently consists of two different projects, the front end GUI and the backend protocol engine. The backend is designed to be separated from the GUI and used for any number of tasks. Since the goal of YCC Trainer is to show how the Yahoo! Messenger protocol works, I will primarily focus on the backend called YCC_YMSG_Functions.

Screenshot - YCC_Trainer_program.gif

YCC_YMSG_Functions

YCC_YMSG_Functions consists of four modules, modUser, modYFunctions, modByteFunctions, and modSockets. The only module that will need to be accessed is modUser as this is the place that all state data, function calls, and events reside.

Screenshot - YCC_Trainer_YMSG.gif

All high level communication within YCC_YMSG_Functions is contained in a structure called uPacket. A uPacket contains all the header information and payload in an easy to access structure without having to manually parse the information. The process for converting a packet to raw byte data and vice versa is contained in modYFunctions. When sending a YMSG message you should call modYFunctions.PacketToByte and when receiving a YMSG message you should convert it to a uPacket by calling modYFunctions.ByteToPacket. The third module, modByteFunctions, holds methods for byte operations such as byte concatenation, which is used throughout YCC_YMSG_Functions. Lastly, modSockets is the network facing module that converts the byte data into an asynchronous Windows API socket.

Because communications within the Yahoo! Messenger Protocol is asynchronous, data can be sent and received independently and at any time. To send data simply call the associated method in modUsers. Receiving data is more complicated but is handled by the socket_receive and modUser_ProcessPacket functions. socket_receive handles all of the special cases that a YMSG packet can contain and modUser_ProcessPacket takes action on a particular YMSG service.

Creating a GUI

The first step in creating a front end to modUser is to create a new instance of YCC_YMSG_Functions. After this has been done, call modUser.Login. In this case Login can be considered the New function because it initializes your instance of YCC_YMSG_Functions and makes it ready to become fully operational. The Login function is also special because it kicks off the packet sequence needed to validate a user against the Yahoo! servers. Once the AuthResp packet has been correctly sent, you can consider your user to be logged onto Yahoo!

VB.NET
Dim yUser As New YCC_YMSG_Functions.modUser
Dim UserData As New YCC_YMSG_Functions.modUser.uUserData
Dim ServerData As New YCC_YMSG_Functions.modUser.uServerData
_YUser = yUser

AddHandler yUser.PacketRecieved, AddressOf debug.modUser_PacketRecieved
AddHandler yUser.PacketSent, AddressOf debug.modUser_PacketSent
AddHandler yUser.LoginFail, AddressOf yUser_LoginFail
AddHandler yUser.NewMail, AddressOf yUser_NewMail
AddHandler yUser.BuddyListUpdate, AddressOf yUser_BuddyListUpdate
AddHandler yUser.ErrorMessage, AddressOf yUser_ErrorMessage
AddHandler yUser.MessageRecieve, AddressOf yUser_MessageRecieve
AddHandler yUser.NotifyRecieve, AddressOf yUser_NotifyRecieve

'Set the user data here such as server, port, etc.

yUser.Login(UserData, ServerData)

While you are creating a new instance of yUser you should also add handlers for the many modUser events that can be triggered. Some of these include LogonSuccess, LogonFail, BuddyListUpdate, and NewMail.

Homepage

YCC Trainer and many other useful programs are housed at Yahoo! Coder's Cookbook (http://ycoderscookbook.com). http://ycoderscookbook.com/YCC_Trainer.htm is the main page for YCC Trainer and a forum is located at http://ycoderscookbook.com/forums. Also at Yahoo! Coder's Cookbook is a full tutorial section explaining much of the Yahoo! Messenger protocol, frequently updated blog, other code samples for Messenger, and much more.

History

1.0.0.1

  • It will now fully logon. A programming error during the AuthResp did not properly process the response challenge strings
  • Uses YMSG protocol version 15
  • New program structure. The high level unit of data is now the uPacket
  • Multiple YMSG packets within a TCP packet can be handled
  • A YMSG message spanning multiple TCP packets can be handled
  • Buddy list properly implemented
  • Separate ignore list
  • Invisible logon
  • Basic message handling and notify messages
  • A few experimental procedures. Nothing interesting to report yet
  • Much more but these are the major fixes

1.0.0.0

  • Initial release

To Do

  • For now the debug window should be considered broken. It does its very basic job but I have a lot of work to do on the presentation. I have also implemented a custom data structure for the queue. The default size is 25 and I have not tested it over this limit. If it crashes after 25 sent or received messages then this is mostly likely the culprit.
  • Implement custom packet maker
  • Ability to update the buddy list status
  • Add, accept, or remove buddies
  • There is a bug during log off. Apparently instead of YMSG, the server sends ****

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Yahoo! Coder's Cookbook
United States United States
I am the webmaster for the Yahoo! Coder’s Cookbook located at http://ycoderscookbook.com. At the Yahoo! Coder’s Cookbook (YCC) I have a blog (http://ycoderscookbook.com/blog/), forum (http://ycoderscookbook.com/forums/), Yahoo! Messenger protocol tutorials (http://ycoderscookbook.com/tutorials/index.html) and several programs (http://ycoderscookbook.com/code/index.html). The most notable programs are YCC Yahoo! Bot Maker (http://ycoderscookbook.com/code/YCC_Yahoo_Bot_Maker.html) which is a Yahoo! account creation tool, YCC Cam Cap (http://ycoderscookbook.com/code/YCC_Cam_Cap.html) which automatically captures Yahoo! webcam windows, and YCC Trainer (http://ycoderscookbook.com/code/YCC_Trainer.html) which is a basic primer for learning the Yahoo! Messenger protocol, YMSG. I also offer developer services (http://ycoderscookbook.com/donations/index.html) for those wishing for their very own Yahoo! tool but do not have the time or expertise.

Comments and Discussions

 
QuestionCan this library work for Web Application(ASP.NET) ? Pin
Somnath kadam10-May-14 4:48
Somnath kadam10-May-14 4:48 
QuestionError! Pin
Jarab28-Oct-12 19:57
Jarab28-Oct-12 19:57 
QuestionVB 2008 code examples Pin
Member 808837016-Jul-11 13:56
Member 808837016-Jul-11 13:56 
AnswerRe: VB 2008 code examples Pin
hongphat851-Dec-11 0:56
hongphat851-Dec-11 0:56 
GeneralMy vote of 5 Pin
jaskolmibob7-Jan-11 21:18
jaskolmibob7-Jan-11 21:18 
GeneralForget it! Pin
Sam S Man29-Aug-10 16:41
Sam S Man29-Aug-10 16:41 
GeneralIn C# version Pin
cokiki9-Jan-10 21:36
cokiki9-Jan-10 21:36 
QuestionAuto Reconnect or login again after my internet connection is dead Pin
ariyok1-Oct-09 17:03
ariyok1-Oct-09 17:03 
GeneralYahoo conference client Pin
sadeghhp2-Sep-09 20:22
sadeghhp2-Sep-09 20:22 
Generalnot working with me Pin
shady05013-Aug-09 21:28
shady05013-Aug-09 21:28 
GeneralRe: not working with me Pin
simplu28-Aug-09 1:54
simplu28-Aug-09 1:54 
GeneralError occur when login Pin
kenoiloan9-Aug-09 22:01
kenoiloan9-Aug-09 22:01 
When I login to YM, have this error message:
Unable to load DLL 'E-F_YMSGLogin2.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Where can i find this dll? I do not turn on Antivirus, download and extract source code but still have this problem.
GeneralRe: Error occur when login Pin
tansqrx10110-Aug-09 9:50
tansqrx10110-Aug-09 9:50 
QuestionWhat I'd like to see more of... Pin
Alien FX Fiend™4-Jul-09 9:59
Alien FX Fiend™4-Jul-09 9:59 
QuestionHow do it work Pin
i_islamian30-Oct-08 20:18
i_islamian30-Oct-08 20:18 
AnswerRe: How do it work [modified] Pin
ChipRayzor1-Nov-08 6:13
ChipRayzor1-Nov-08 6:13 
AnswerRe: How do it work Pin
tansqrx1012-Nov-08 18:16
tansqrx1012-Nov-08 18:16 
QuestionRelease Pin
snoopcatt15-Oct-08 0:40
snoopcatt15-Oct-08 0:40 
GeneralYour website. Pin
xmd31415-Jun-08 13:33
xmd31415-Jun-08 13:33 
GeneralRe: Your website. Pin
tansqrx10118-Jun-08 10:47
tansqrx10118-Jun-08 10:47 
GeneralAccept/Add buddy request Pin
naghicalin20-May-08 21:41
naghicalin20-May-08 21:41 
GeneralRe: Accept/Add buddy request Pin
naghicalin22-May-08 3:14
naghicalin22-May-08 3:14 
QuestionRe: Accept/Add buddy request Pin
Radu_2011-Jul-08 3:53
Radu_2011-Jul-08 3:53 
AnswerRe: Accept/Add buddy request Pin
kkrisjoy27-Oct-08 6:07
kkrisjoy27-Oct-08 6:07 
Questionproxy support? Pin
Member 27559819-Apr-08 20:19
Member 27559819-Apr-08 20:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.