MLAPI/MLAPI/Data/ClientIdKey.cs
2018-03-13 09:24:46 +01:00

39 lines
981 B
C#

namespace MLAPI.Data
{
struct ClientIdKey
{
internal readonly int hostId;
internal readonly int connectionId;
internal ClientIdKey (int hostId, int connectionId)
{
this.hostId = hostId;
this.connectionId = connectionId;
}
public override bool Equals (object obj)
{
if (obj == null || GetType() != obj.GetType())
return false;
ClientIdKey key = (ClientIdKey)obj;
return (hostId == key.hostId) && (connectionId == key.hostId);
}
public override int GetHashCode()
{
return hostId ^ connectionId;
}
public static bool operator ==(ClientIdKey x, ClientIdKey y)
{
return x.hostId == y.hostId && x.connectionId == y.connectionId;
}
public static bool operator !=(ClientIdKey x, ClientIdKey y)
{
return !(x == y);
}
}
}