first commit

This commit is contained in:
2025-12-13 14:28:35 +01:00
commit 679c3c9a52
113 changed files with 715750 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
// This file is provided under The MIT License as part of RiptideSteamTransport.
// Copyright (c) Tom Weiland
// For additional information please see the included LICENSE.md file or view it on GitHub:
// https://github.com/tom-weiland/RiptideSteamTransport/blob/main/LICENSE.md
using Steamworks;
using System;
using System.Collections.Generic;
namespace Riptide.Transports.Steam
{
public class SteamConnection : Connection, IEquatable<SteamConnection>
{
public readonly CSteamID SteamId;
public readonly HSteamNetConnection SteamNetConnection;
internal bool DidReceiveConnect;
private readonly SteamPeer peer;
internal SteamConnection(CSteamID steamId, HSteamNetConnection steamNetConnection, SteamPeer peer)
{
SteamId = steamId;
SteamNetConnection = steamNetConnection;
this.peer = peer;
}
protected internal override void Send(byte[] dataBuffer, int amount)
{
peer.Send(dataBuffer, amount, SteamNetConnection);
}
/// <inheritdoc/>
public override string ToString() => SteamNetConnection.ToString();
/// <inheritdoc/>
public override bool Equals(object obj) => Equals(obj as SteamConnection);
/// <inheritdoc/>
public bool Equals(SteamConnection other)
{
if (other is null)
return false;
if (ReferenceEquals(this, other))
return true;
return SteamNetConnection.Equals(other.SteamNetConnection);
}
/// <inheritdoc/>
public override int GetHashCode()
{
return -721414014 + EqualityComparer<HSteamNetConnection>.Default.GetHashCode(SteamNetConnection);
}
public static bool operator ==(SteamConnection left, SteamConnection right)
{
if (left is null)
{
if (right is null)
return true;
return false; // Only the left side is null
}
// Equals handles case of null on right side
return left.Equals(right);
}
public static bool operator !=(SteamConnection left, SteamConnection right) => !(left == right);
}
}