testQQCommon.pas
上传用户:xgd119
上传日期:2007-05-02
资源大小:514k
文件大小:3k
源码类别:

P2P编程

开发平台:

Delphi

  1. unit testQQCommon;
  2. interface
  3. //-------------------常量定义---------------------
  4. Const  SERVER_PORT=9001;
  5.        CLIENT_PORT=5001;
  6.        IsFalse='0';
  7.        IsTrue='1';
  8.        LogonSign=1;             //注册信号
  9.        HandSign=2;             //握手数据,用于保持会话连接,如网关的NAT端口
  10.        FriendDataSign=3;       //好友资料
  11.        LogoutSign=4;           //注销信号
  12.        ChatMsgSign=5;          //聊天信息
  13.        ChatMsgRecvedSign=6;    //收到聊天信息
  14. //-------------------数据头定义---------------------
  15. type  TTQQUDPHead=record
  16.          MsgType:String[2];       {数据类型}
  17.          DataSize:LONGWORD;
  18. end;
  19. //-------------------数据体定义---------------------
  20.        {4.0 登录上线数据格式}
  21. type  TLogonData=packed record
  22.          Account:array [0..20] of Char;      {账号}
  23.          MyPublicIP:array [0..20] of Char;   {IP}
  24.          MyPublicPORT:array[0..5] of Char;   {PORT}
  25.          lResult:array[0..1] of Char;        {验证结果:  1,成功;0,失败}
  26. end;
  27.        {4.1 登录下线数据格式}
  28. type  TLogoutData=packed record
  29.          Account:array [0..20] of Char;      {账号}
  30.          lResult:array[0..1] of Char;        {验证结果:  1,成功;0,失败}
  31. end;
  32. type  THandData=packed record
  33.          Account:array [0..20] of Char;      {账号}
  34.          Mark:array[0..1] of Char;    {是否是上线信号}
  35.          DesIP:array [0..20] of Char;   {IP}
  36.          DesPORT:array[0..5] of Char;   {PORT}
  37.          NeedReBack:Array[0..2] of Char;  {是否需要反馈}
  38.          IsDirected:array[0..1] of Char;  {是否是直接发送}
  39. end;
  40.        {聊天消息数据格式}
  41. type TChatData=packed record
  42.         fromAccount:array [0..20] of Char;     {账号}
  43.         toAccount:array [0..20] of Char;      {}
  44.         Msg:array[0..499] of Char;    {消息内容}
  45.         IsNeedReBack:array[0..1] of Char;  {是否需要接收成功反馈}
  46.         IsReBackSigh:array[0..1] of Char;  {是否为反馈信息}
  47. end;
  48. //-------------------用户基本信息定义---------------------
  49. type  TUserData=packed record
  50.          Account:array [0..20] of Char;      {用户ID}
  51.          IP:array[0..15] of Char;            {IP地址}
  52.          PORT:array[0..6] of Char;
  53.          IsFirstOne:array[0..2] of Char;     {是否为第一个,特殊处理}
  54. end;
  55. //-------------------整体结构定义格式包---------------------
  56.          {(Package) 登录上线验证数据格式}
  57. type  TLogonDataPackage=packed record
  58.          Head:TTQQUDPHead;
  59.          Body:TLogonData;
  60. end;
  61. type TLogoutDataPackage=packed record
  62.          Head:TTQQUDPHead;
  63.          Body:TLogoutData;
  64. end;
  65.         {握手[打洞]数据格式}
  66. type  THandDataPackage=packed record
  67.          Head:TTQQUDPHead;
  68.          Body:THandData;
  69. end;
  70.          {好友信息数据}
  71. type  TFriendDataPackage=packed record
  72.          Head:TTQQUDPHead;
  73.          Body:TUserData;
  74. end;
  75.         {聊天消息数据格式}
  76. type TChatDataPackage=packed record
  77.          Head:TTQQUDPHead;
  78.          Body:TChatData;
  79. end;
  80. //-------------------在线信息---------------------
  81. type   PServerUserBasicInfo=^TServerUserBasicInfo;
  82.        TServerUserBasicInfo=class  //在线用户数据表
  83.        UserData:TUserData;
  84.        IsActive:Boolean;
  85. end;
  86. implementation
  87. end.