mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 00:24:40 +00:00
commit
5344d89a6f
3 changed files with 41 additions and 36 deletions
|
|
@ -491,11 +491,10 @@ template<class T> T ReservedSocketList<T>::resolve(NetSocket socketToResolve)
|
||||||
EntryType &entry = mSocketList[socketToResolve.getHandle()];
|
EntryType &entry = mSocketList[socketToResolve.getHandle()];
|
||||||
return entry.used ? entry.value : -1;
|
return entry.used ? entry.value : -1;
|
||||||
}
|
}
|
||||||
|
ConnectionNotifyEvent* Net::smConnectionNotify = NULL;
|
||||||
static ConnectionNotifyEvent* smConnectionNotify = NULL;
|
ConnectionAcceptedEvent* Net::smConnectionAccept = NULL;
|
||||||
static ConnectionAcceptedEvent* smConnectionAccept = NULL;
|
ConnectionReceiveEvent* Net::smConnectionReceive = NULL;
|
||||||
static ConnectionReceiveEvent* smConnectionReceive = NULL;
|
PacketReceiveEvent* Net::smPacketReceive = NULL;
|
||||||
static PacketReceiveEvent* smPacketReceive = NULL;
|
|
||||||
|
|
||||||
ConnectionNotifyEvent& Net::getConnectionNotifyEvent()
|
ConnectionNotifyEvent& Net::getConnectionNotifyEvent()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -78,8 +78,8 @@ struct NetAddress
|
||||||
|
|
||||||
bool isSameAddress(const NetAddress &other) const
|
bool isSameAddress(const NetAddress &other) const
|
||||||
{
|
{
|
||||||
if (type != other.type)
|
if (type != other.type)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
|
@ -102,32 +102,32 @@ struct NetAddress
|
||||||
|
|
||||||
bool isSameAddressAndPort(const NetAddress &other) const
|
bool isSameAddressAndPort(const NetAddress &other) const
|
||||||
{
|
{
|
||||||
if (type != other.type)
|
if (type != other.type)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case NetAddress::IPAddress:
|
case NetAddress::IPAddress:
|
||||||
return (dMemcmp(other.address.ipv4.netNum, address.ipv4.netNum, 4) == 0) && other.port == port;
|
return (dMemcmp(other.address.ipv4.netNum, address.ipv4.netNum, 4) == 0) && other.port == port;
|
||||||
break;
|
break;
|
||||||
case NetAddress::IPV6Address:
|
case NetAddress::IPV6Address:
|
||||||
return (dMemcmp(other.address.ipv6.netNum, address.ipv6.netNum, 16) == 0) && other.port == port;
|
return (dMemcmp(other.address.ipv6.netNum, address.ipv6.netNum, 16) == 0) && other.port == port;
|
||||||
break;
|
break;
|
||||||
case NetAddress::IPBroadcastAddress:
|
case NetAddress::IPBroadcastAddress:
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case NetAddress::IPV6MulticastAddress:
|
case NetAddress::IPV6MulticastAddress:
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isEqual(const NetAddress &other) const
|
bool isEqual(const NetAddress &other) const
|
||||||
{
|
{
|
||||||
if (type != other.type)
|
if (type != other.type)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
|
@ -193,7 +193,7 @@ struct Net
|
||||||
WouldBlock,
|
WouldBlock,
|
||||||
NotASocket,
|
NotASocket,
|
||||||
UnknownError,
|
UnknownError,
|
||||||
NeedHostLookup
|
NeedHostLookup
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ConnectionState {
|
enum ConnectionState {
|
||||||
|
|
@ -215,6 +215,12 @@ struct Net
|
||||||
static bool smIpv4Enabled;
|
static bool smIpv4Enabled;
|
||||||
static bool smIpv6Enabled;
|
static bool smIpv6Enabled;
|
||||||
|
|
||||||
|
static ConnectionNotifyEvent* smConnectionNotify;
|
||||||
|
static ConnectionAcceptedEvent* smConnectionAccept;
|
||||||
|
static ConnectionReceiveEvent* smConnectionReceive;
|
||||||
|
static PacketReceiveEvent* smPacketReceive;
|
||||||
|
|
||||||
|
|
||||||
static bool init();
|
static bool init();
|
||||||
static void shutdown();
|
static void shutdown();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,8 @@ TEST(Net, TCPRequest)
|
||||||
handler.mDataReceived = 0;
|
handler.mDataReceived = 0;
|
||||||
|
|
||||||
// Hook into the signals.
|
// Hook into the signals.
|
||||||
Net::smConnectionNotify .notify(&handler, &TcpHandle::notify);
|
Net::smConnectionNotify ->notify(&handler, &TcpHandle::notify);
|
||||||
Net::smConnectionReceive.notify(&handler, &TcpHandle::receive);
|
Net::smConnectionReceive->notify(&handler, &TcpHandle::receive);
|
||||||
|
|
||||||
// Open a TCP connection to garagegames.com
|
// Open a TCP connection to garagegames.com
|
||||||
handler.mSocket = Net::openConnectTo("72.246.107.193:80");
|
handler.mSocket = Net::openConnectTo("72.246.107.193:80");
|
||||||
|
|
@ -85,8 +85,8 @@ TEST(Net, TCPRequest)
|
||||||
while(Process::processEvents() && (Platform::getRealMilliseconds() < limit) ) {}
|
while(Process::processEvents() && (Platform::getRealMilliseconds() < limit) ) {}
|
||||||
|
|
||||||
// Unhook from the signals.
|
// Unhook from the signals.
|
||||||
Net::smConnectionNotify .remove(&handler, &TcpHandle::notify);
|
Net::smConnectionNotify ->remove(&handler, &TcpHandle::notify);
|
||||||
Net::smConnectionReceive.remove(&handler, &TcpHandle::receive);
|
Net::smConnectionReceive->remove(&handler, &TcpHandle::receive);
|
||||||
|
|
||||||
EXPECT_GT(handler.mDataReceived, 0)
|
EXPECT_GT(handler.mDataReceived, 0)
|
||||||
<< "Didn't get any data back!";
|
<< "Didn't get any data back!";
|
||||||
|
|
@ -139,8 +139,8 @@ struct JournalHandle
|
||||||
mDataReceived = 0;
|
mDataReceived = 0;
|
||||||
|
|
||||||
// Hook into the signals.
|
// Hook into the signals.
|
||||||
Net::smConnectionNotify .notify(this, &JournalHandle::notify);
|
Net::smConnectionNotify ->notify(this, &JournalHandle::notify);
|
||||||
Net::smConnectionReceive.notify(this, &JournalHandle::receive);
|
Net::smConnectionReceive->notify(this, &JournalHandle::receive);
|
||||||
|
|
||||||
// Open a TCP connection to garagegames.com
|
// Open a TCP connection to garagegames.com
|
||||||
mSocket = Net::openConnectTo("72.246.107.193:80");
|
mSocket = Net::openConnectTo("72.246.107.193:80");
|
||||||
|
|
@ -149,8 +149,8 @@ struct JournalHandle
|
||||||
while(Process::processEvents()) {}
|
while(Process::processEvents()) {}
|
||||||
|
|
||||||
// Unhook from the signals.
|
// Unhook from the signals.
|
||||||
Net::smConnectionNotify .remove(this, &JournalHandle::notify);
|
Net::smConnectionNotify ->remove(this, &JournalHandle::notify);
|
||||||
Net::smConnectionReceive.remove(this, &JournalHandle::receive);
|
Net::smConnectionReceive->remove(this, &JournalHandle::receive);
|
||||||
|
|
||||||
EXPECT_GT(mDataReceived, 0)
|
EXPECT_GT(mDataReceived, 0)
|
||||||
<< "Didn't get any data back!";
|
<< "Didn't get any data back!";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue