using System;
using System.Net;
using Lidgren.Network;
using Robust.Shared.ViewVariables;
namespace Robust.Shared.Network
{
///
/// A network channel between this peer and a remote peer.
///
[NotContentImplementable]
public interface INetChannel
{
///
/// The NetPeer this belongs to.
///
INetManager NetPeer { get; }
///
/// The Unique Identifier of the connection.
///
long ConnectionId { get; }
///
/// The IP end point.
///
IPEndPoint RemoteEndPoint { get; }
///
/// The session ID for this channel.
/// On the server, this is the session ID for this client.
/// On the client, this is the session ID for the client.
///
[ViewVariables]
NetUserId UserId { get; }
[ViewVariables]
string UserName { get; }
[ViewVariables]
LoginType AuthType { get; }
///
/// Offset between local RealTime and remote RealTime.
///
TimeSpan RemoteTimeOffset { get; }
///
/// Remote RealTime.
///
TimeSpan RemoteTime { get; }
///
/// Average round trip time in milliseconds between the remote peer and us.
///
[ViewVariables]
short Ping { get; }
///
/// Whether or not the channel is currently connected to a remote peer.
///
[ViewVariables]
bool IsConnected { get; }
NetUserData UserData { get; }
///
/// Has the serializer handshake completed and been ran?
///
bool IsHandshakeComplete { get; }
///
/// Diagnostic indicating the maximum transmission unit being used for this connection.
///
///
[ViewVariables]
public int CurrentMtu { get; }
///
/// Creates a new NetMessage to be filled up and sent.
///
/// The derived NetMessage type to send.
/// A new instance of the net message.
[Obsolete("Just new NetMessage directly")]
T CreateNetMessage()
where T : NetMessage, new();
///
/// Sends a NetMessage over this NetChannel.
///
/// The NetMessage to send.
void SendMessage(NetMessage message);
///
/// Disconnects this channel from the remote peer.
///
/// Reason why it was disconnected.
void Disconnect(string reason);
///
/// Disconnects this channel from the remote peer.
///
/// Reason why it was disconnected.
/// If false, we ghost the remote client and don't tell them they got disconnected properly.
void Disconnect(string reason, bool sendBye);
///
/// Check whether the networking layer has space to immediately send a message with the given parameters.
///
///
/// If this returns true, messages may still be sent, but they will be queued until there is space available.
///
bool CanSendImmediately(NetDeliveryMethod method, int sequenceChannel);
}
}