?? proto.h
字號:
/* P2P 程序傳輸協(xié)議
*
* 日期:2004-5-21
*
* 作者:shootingstars(zhouhuis22@sina.com)
*
*/
#pragma once
#include <list>
// 定義iMessageType的值
#define LOGIN 1
#define LOGOUT 2
#define P2PTRANS 3
#define GETALLUSER 4
// 服務(wù)器端口
#define SERVER_PORT 2280
// Client登錄時(shí)向服務(wù)器發(fā)送的消息
struct stLoginMessage
{
char userName[10];
char password[10];
};
// Client注銷時(shí)發(fā)送的消息
struct stLogoutMessage
{
char userName[10];
};
// Client向服務(wù)器請求另外一個(gè)Client(userName)向自己方向發(fā)送UDP打洞消息
struct stP2PTranslate
{
char userName[10];
};
// Client向服務(wù)器發(fā)送的消息格式
struct stMessage
{
int iMessageType;
union _message
{
stLoginMessage loginmember;
stLogoutMessage logoutmember;
stP2PTranslate translatemessage;
}message;
};
// 客戶節(jié)點(diǎn)信息
struct stUserListNode
{
char userName[10];
unsigned int ip;
unsigned short port;
};
// Server向Client發(fā)送的消息
struct stServerToClient
{
int iMessageType;
union _message
{
stUserListNode user;
}message;
};
//======================================
// 下面的協(xié)議用于客戶端之間的通信
//======================================
#define P2PMESSAGE 100 // 發(fā)送消息
#define P2PMESSAGEACK 101 // 收到消息的應(yīng)答
#define P2PSOMEONEWANTTOCALLYOU 102 // 服務(wù)器向客戶端發(fā)送的消息
// 希望此客戶端發(fā)送一個(gè)UDP打洞包
#define P2PTRASH 103 // 客戶端發(fā)送的打洞包,接收端應(yīng)該忽略此消息
// 客戶端之間發(fā)送消息格式
struct stP2PMessage
{
int iMessageType;
int iStringLen; // or IP address
unsigned short Port;
};
using namespace std;
typedef list<stUserListNode *> UserList;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -