P2pConst.pas
资源名称:P2P.rar [点击查看]
上传用户:zhanghw123
上传日期:2021-11-15
资源大小:312k
文件大小:3k
源码类别:
P2P编程
开发平台:
Delphi
- Unit P2pConst;
- Interface
- Uses
- ComCtrls, Graphics;
- Type
- TAddress = String[21];
- // 命令头
- Phead = ^Thead;
- Thead = Packed Record
- ID: Integer;
- End;
- // 登陆包
- PLoginUser = ^TLoginUser;
- TLoginUser = Packed Record
- ID: Thead;
- Name: String[20]; //用户名称
- End;
- // 登陆返回包 result
- PResutLoginBack = ^TResutLoginBack;
- TResutLoginBack = Packed Record
- ID: Thead;
- State: Byte; //1成功登陆 2已经登陆了
- Addr: TAddress; //返回用户的IP和端口号
- UserID: Cardinal; //用户ID号
- End;
- // 退出登陆包
- PLoginoutUser = ^TLoginoutUser;
- TLoginoutUser = Packed Record
- ID: Thead;
- UserID: Cardinal;
- End;
- // 广播的用户包
- PNewUser = ^TNewUser;
- TNewUser = Packed Record
- ID: Thead;
- IP: String[15];
- Port: Word;
- Call: String[20];
- UserID: Cardinal;
- End;
- //开门
- TOpenDoor = Packed Record
- ID: Thead;
- End;
- // 想要对方开门
- PWantDoor = ^TWantDoor;
- TWantDoor = Packed Record
- ID: Thead;
- SourceID, {发起}
- DestID: Cardinal; {目标}
- End;
- // 说Hello
- PSayHello = ^TSayHello;
- TSayHello = Packed Record
- ID: Thead;
- UserID: Cardinal;
- End;
- // 心跳
- PLiving = ^TLiving;
- TLiving = Packed Record
- ID: Thead;
- SourceUserID: Cardinal;
- End;
- Const
- P2pLogin = 1001; //登陆
- P2pLoginOut = 1002; //退出
- P2pWantDoor = 1003; //用户请求其它用户开门
- P2pDoorOpened = 1004; //告诉服务端这个用户的门已经打开
- P2pResultLoginBack = 2001; //返回登陆
- P2PGiveUserlist = 2002; //给用户列表
- P2pSomeOneWantDoor = 2003; //给用户请求P2P开门命令
- P2pDoneDoor = 2004; //通知客户端已经打开门了
- P2pOpenDoor = 4001; //接到请求的用户给对方开门
- P2pSayHello = 4002; //发起握手的信息
- P2pChat = 4003; //用户发送聊天消息
- P2pSayHelloResponse = 5002; //对方回复握手信息
- P2PALLNewUser = 6001; //广播有新用户加入
- P2pALLLeaveUser = 6002; //广播有用户离开
- P2pAnyLifeing = 7001; //心跳包
- P2pAnyToAntLifeing = 7002; //心跳回复包
- Type
- TREFont = Packed Record
- Charset: TFontCharset;
- Name: TFontName;
- Size: Integer;
- Color: TColor;
- Style: TFontStyles;
- Pitch: TFontPitch;
- End;
- Procedure SetRichEditFont(RichEdit: TRichEdit; Font: TFont);
- Implementation
- Procedure SetRichEditFont(RichEdit: TRichEdit; Font: TFont);
- Begin
- With RichEdit.SelAttributes Do
- Begin
- Charset := Font.Charset;
- Name := Font.Name;
- Size := Font.Size;
- Color := Font.Color;
- Style := Font.Style;
- Pitch := Font.Pitch;
- End;
- End;
- End.