网络地址等基础类增加赋值函数,支持直接赋值拷贝
This commit is contained in:
parent
1014c0a3b7
commit
84bfeb50d7
|
@ -106,6 +106,13 @@ IPAddress& IPAddress::operator=(const Buffer& arr)
|
|||
return *this;
|
||||
}
|
||||
|
||||
IPAddress& IPAddress::operator=(const IPAddress& addr)
|
||||
{
|
||||
Value = addr.Value;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// 重载索引运算符[],让它可以像数组一样使用下标索引。
|
||||
byte& IPAddress::operator[](int i)
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
IPAddress& operator=(uint v) { Value = v; return *this; }
|
||||
IPAddress& operator=(const byte* v);
|
||||
IPAddress& operator=(const Buffer& arr);
|
||||
IPAddress& operator=(const IPAddress& addr);
|
||||
|
||||
// 重载索引运算符[],让它可以像数组一样使用下标索引。
|
||||
byte& operator[](int i);
|
||||
|
|
|
@ -40,6 +40,14 @@ IPEndPoint& IPEndPoint::operator=(const Buffer& arr)
|
|||
return *this;
|
||||
}
|
||||
|
||||
IPEndPoint& IPEndPoint::operator=(const IPEndPoint& endPoint)
|
||||
{
|
||||
Address = endPoint.Address;
|
||||
Port = endPoint.Port;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// 字节数组
|
||||
ByteArray IPEndPoint::ToArray() const
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ public:
|
|||
IPEndPoint(const Buffer& arr);
|
||||
|
||||
IPEndPoint& operator=(const Buffer& arr);
|
||||
IPEndPoint& operator=(const IPEndPoint& endPoint);
|
||||
|
||||
// 字节数组
|
||||
ByteArray ToArray() const;
|
||||
|
|
|
@ -74,6 +74,13 @@ MacAddress& MacAddress::operator=(const Buffer& arr)
|
|||
return *this;
|
||||
}
|
||||
|
||||
MacAddress& MacAddress::operator=(const MacAddress& mac)
|
||||
{
|
||||
Value = mac.Value;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// 重载索引运算符[],让它可以像数组一样使用下标索引。
|
||||
byte& MacAddress::operator[](int i)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@ public:
|
|||
MacAddress& operator=(UInt64 v);
|
||||
MacAddress& operator=(const byte* buf);
|
||||
MacAddress& operator=(const Buffer& arr);
|
||||
MacAddress& operator=(const MacAddress& mac);
|
||||
|
||||
// 重载索引运算符[],让它可以像数组一样使用下标索引。
|
||||
byte& operator[](int i);
|
||||
|
|
|
@ -382,8 +382,8 @@ void TokenClient::SayHello(bool broadcast)
|
|||
{
|
||||
auto ctrl = cs[0];
|
||||
auto sock = ctrl->Socket;
|
||||
ext.EndPoint.Address = sock->Host->IP;
|
||||
ext.EndPoint.Port = sock->Local.Port;
|
||||
//ext.EndPoint.Address = sock->Local.Address;
|
||||
ext.EndPoint = sock->Local;
|
||||
ext.Protocol = sock->Protocol == NetType::Udp ? 17 : 6;
|
||||
}
|
||||
|
||||
|
|
|
@ -178,8 +178,8 @@ bool TokenSession::OnHello(TokenMessage& msg)
|
|||
ext2.Key = key;
|
||||
|
||||
auto sock = Control.Socket;
|
||||
ext2.EndPoint.Address = sock->Host->IP;
|
||||
ext2.EndPoint.Port = sock->Local.Port;
|
||||
//ext2.EndPoint.Address = sock->Host->IP;
|
||||
ext2.EndPoint = sock->Local;
|
||||
|
||||
ext2.Cipher = "RC4";
|
||||
ext2.Name = Client.Cfg->User();
|
||||
|
|
Loading…
Reference in New Issue