2019-05-01 00:51:01 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
using Steamworks.Data;
|
|
|
|
|
|
|
|
|
|
namespace Steamworks
|
|
|
|
|
{
|
|
|
|
|
[TestClass]
|
|
|
|
|
[DeploymentItem( "steam_api64.dll" )]
|
2020-02-22 23:29:37 +03:00
|
|
|
|
[DeploymentItem( "steam_api.dll" )]
|
|
|
|
|
public class SteamNetworkingTest
|
2019-05-01 00:51:01 +03:00
|
|
|
|
{
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public async Task SendP2PPacket()
|
|
|
|
|
{
|
|
|
|
|
var sent = SteamNetworking.SendP2PPacket( SteamClient.SteamId, new byte[] { 1, 2, 3 } );
|
|
|
|
|
Assert.IsTrue( sent );
|
|
|
|
|
|
2020-02-25 15:33:16 +03:00
|
|
|
|
while ( !SteamNetworking.IsP2PPacketAvailable() )
|
|
|
|
|
{
|
|
|
|
|
await Task.Delay( 10 );
|
|
|
|
|
}
|
2019-05-01 00:51:01 +03:00
|
|
|
|
|
2020-02-25 15:33:16 +03:00
|
|
|
|
var packet = SteamNetworking.ReadP2PPacket();
|
2019-05-01 00:51:01 +03:00
|
|
|
|
|
|
|
|
|
Assert.IsTrue( packet.HasValue );
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual( packet.Value.SteamId, SteamClient.SteamId );
|
|
|
|
|
Assert.AreEqual( packet.Value.Data[1], 2 );
|
|
|
|
|
Assert.AreEqual( packet.Value.Data.Length, 3 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|