Cleanup and consolidate MPSystemComponent and add StopListening to AzNetworking
This commit is contained in:
@@ -88,6 +88,11 @@ namespace AzNetworking
|
||||
//! @return boolean true if the packet is confirmed acknowledged, false if the packet number is out of range, lost, or still pending acknowledgment
|
||||
virtual bool WasPacketAcked(ConnectionId connectionId, PacketId packetId) = 0;
|
||||
|
||||
//! Closes the network interface to stop accepting new incoming connections.
|
||||
//! @param port the listen port number this network interface will potentially bind to, 0 if it's a don't care
|
||||
//! @return boolean true if the operation was successful, false if it failed
|
||||
virtual bool StopListening() = 0;
|
||||
|
||||
//! Disconnects the specified connection.
|
||||
//! @param connectionId identifier of the connection to terminate
|
||||
//! @param reason reason for the disconnect
|
||||
|
||||
@@ -162,6 +162,12 @@ namespace AzNetworking
|
||||
return connection->WasPacketAcked(packetId);
|
||||
}
|
||||
|
||||
bool TcpNetworkInterface::StopListening()
|
||||
{
|
||||
m_port = 0;
|
||||
return m_listenThread.StopListening(*this);
|
||||
}
|
||||
|
||||
bool TcpNetworkInterface::Disconnect(ConnectionId connectionId, DisconnectReason reason)
|
||||
{
|
||||
IConnection* connection = m_connectionSet.GetConnection(connectionId);
|
||||
|
||||
@@ -63,6 +63,7 @@ namespace AzNetworking
|
||||
bool SendReliablePacket(ConnectionId connectionId, const IPacket& packet) override;
|
||||
PacketId SendUnreliablePacket(ConnectionId connectionId, const IPacket& packet) override;
|
||||
bool WasPacketAcked(ConnectionId connectionId, PacketId packetId) override;
|
||||
bool StopListening() override;
|
||||
bool Disconnect(ConnectionId connectionId, DisconnectReason reason) override;
|
||||
//! @}
|
||||
|
||||
|
||||
@@ -359,6 +359,21 @@ namespace AzNetworking
|
||||
return connection->WasPacketAcked(packetId);
|
||||
}
|
||||
|
||||
bool UdpNetworkInterface::StopListening()
|
||||
{
|
||||
if (!m_socket->IsOpen())
|
||||
{
|
||||
AZ_Assert(false, "StopListen cannot be invoked on an already closed network interface");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_port = 0;
|
||||
m_readerThread.UnregisterSocket(m_socket.get());
|
||||
m_allowIncomingConnections = false;
|
||||
m_socket->Close();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UdpNetworkInterface::Disconnect(ConnectionId connectionId, DisconnectReason reason)
|
||||
{
|
||||
IConnection* connection = m_connectionSet.GetConnection(connectionId);
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace AzNetworking
|
||||
bool SendReliablePacket(ConnectionId connectionId, const IPacket& packet) override;
|
||||
PacketId SendUnreliablePacket(ConnectionId connectionId, const IPacket& packet) override;
|
||||
bool WasPacketAcked(ConnectionId connectionId, PacketId packetId) override;
|
||||
bool StopListening() override;
|
||||
bool Disconnect(ConnectionId connectionId, DisconnectReason reason) override;
|
||||
//! @}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user