Skip to content

Commit

Permalink
Update demos and Unity package to v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-weiland committed Jan 27, 2022
1 parent 5fbe1a5 commit fe7dae1
Show file tree
Hide file tree
Showing 41 changed files with 818 additions and 487 deletions.
2 changes: 1 addition & 1 deletion Demos/Console/ConsoleClient/ConsoleClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>RiptideNetworking.Demos.RudpTransport.ConsoleApp.TestClient</RootNamespace>
<RootNamespace>RiptideDemos.RudpTransport.ConsoleApp.TestClient</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down
11 changes: 6 additions & 5 deletions Demos/Console/ConsoleClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Copyright (c) 2021 Tom Weiland
// For additional information please see the included LICENSE.md file or view it on GitHub: https://github.com/tom-weiland/RiptideNetworking/blob/main/LICENSE.md

using RiptideNetworking;
using RiptideNetworking.Transports.RudpTransport;
using RiptideNetworking.Utils;
using System;
Expand All @@ -11,9 +12,9 @@
using System.Threading;
using Timer = System.Timers.Timer;

namespace RiptideNetworking.Demos.RudpTransport.ConsoleApp.TestClient
namespace RiptideDemos.RudpTransport.ConsoleApp.TestClient
{
class Program
internal class Program
{
private static Client client;
private static bool isRunning;
Expand Down Expand Up @@ -83,7 +84,7 @@ private static void Connected()
Console.WriteLine();
Console.WriteLine("Press enter to disconnect at any time.");

client.Send(Message.Create(MessageSendMode.reliable, (ushort)MessageId.startTest, 25).Add(isRoundTripTest).Add(testIdAmount));
client.Send(Message.Create(MessageSendMode.reliable, MessageId.startTest, 25).AddBool(isRoundTripTest).AddInt(testIdAmount));
}

private static void Disconnected()
Expand Down Expand Up @@ -185,8 +186,8 @@ private static void ReliabilityTestEnded()

private static void SendTestMessage(int reliableTestId)
{
Message message = Message.Create(MessageSendMode.reliable, (ushort)MessageId.testMessage);
message.Add(reliableTestId);
Message message = Message.Create(MessageSendMode.reliable, MessageId.testMessage);
message.AddInt(reliableTestId);

client.Send(message);
}
Expand Down
2 changes: 1 addition & 1 deletion Demos/Console/ConsoleServer/ConsoleServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>RiptideNetworking.Demos.RudpTransport.ConsoleApp.TestServer</RootNamespace>
<RootNamespace>RiptideDemos.RudpTransport.ConsoleApp.TestServer</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down
13 changes: 7 additions & 6 deletions Demos/Console/ConsoleServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
// Copyright (c) 2021 Tom Weiland
// For additional information please see the included LICENSE.md file or view it on GitHub: https://github.com/tom-weiland/RiptideNetworking/blob/main/LICENSE.md

using RiptideNetworking;
using RiptideNetworking.Transports.RudpTransport;
using RiptideNetworking.Utils;
using System;
using System.Collections.Generic;
using System.Threading;
using Timer = System.Timers.Timer;

namespace RiptideNetworking.Demos.RudpTransport.ConsoleApp.TestServer
namespace RiptideDemos.RudpTransport.ConsoleApp.TestServer
{
class Program
internal class Program
{
private static Server server;
private static bool isRunning;
Expand Down Expand Up @@ -68,13 +69,13 @@ private static void HandleStartTest(ushort fromClientId, Message message)
remainingTestIds.Add(i + 1);
}

server.Send(Message.Create(MessageSendMode.reliable, (ushort)MessageId.startTest, 25).Add(isRoundTripTest).Add(testIdAmount), fromClientId);
server.Send(Message.Create(MessageSendMode.reliable, MessageId.startTest, 25).AddBool(isRoundTripTest).AddInt(testIdAmount), fromClientId);
}

private static void SendTestMessage(ushort fromClientId, int reliableTestId)
{
Message message = Message.Create(MessageSendMode.reliable, (ushort)MessageId.testMessage);
message.Add(reliableTestId);
Message message = Message.Create(MessageSendMode.reliable, MessageId.testMessage);
message.AddInt(reliableTestId);

server.Send(message, fromClientId);
}
Expand Down Expand Up @@ -146,4 +147,4 @@ public enum MessageId : ushort
startTest = 1,
testMessage
}
}
}
4 changes: 2 additions & 2 deletions Demos/MonoGame/Server/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ internal static void SendPositions()

private Message CreateSpawnMessage()
{
Message message = Message.Create(MessageSendMode.reliable, (ushort)MessageId.PlayerSpawn);
Message message = Message.Create(MessageSendMode.reliable, MessageId.PlayerSpawn);
message.Add(id);
message.Add(position);
return message;
}

internal void SendPosition()
{
Message message = Message.Create(MessageSendMode.unreliable, (ushort)MessageId.PlayerPosition);
Message message = Message.Create(MessageSendMode.unreliable, MessageId.PlayerPosition);
message.AddUShort(id);
message.AddVector2(position);
Program.Server.SendToAll(message, id);
Expand Down
4 changes: 2 additions & 2 deletions Demos/Unity/Client/Assets/Scripts/CameraController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

using UnityEngine;

namespace RiptideNetworking.Demos.RudpTransport.Unity.ExampleClient
namespace RiptideDemos.RudpTransport.Unity.ExampleClient
{
public class CameraController : MonoBehaviour
{
Expand Down Expand Up @@ -57,4 +57,4 @@ private void ToggleCursorMode()
Cursor.lockState = CursorLockMode.None;
}
}
}
}
35 changes: 24 additions & 11 deletions Demos/Unity/Client/Assets/Scripts/Multiplayer/MessageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@
// Copyright (c) 2021 Tom Weiland
// For additional information please see the included LICENSE.md file or view it on GitHub: https://github.com/tom-weiland/RiptideNetworking/blob/main/LICENSE.md

using RiptideNetworking;
using UnityEngine;

namespace RiptideNetworking.Demos.RudpTransport.Unity.ExampleClient
namespace RiptideDemos.RudpTransport.Unity.ExampleClient
{
public static class MessageExtensions
{
#region Vector2
/// <inheritdoc cref="Add(Message, Vector2)"/>
/// <remarks>Relying on the correct Add overload being chosen based on the parameter type can increase the odds of accidental type mismatches when retrieving data from a message. This method calls <see cref="Add(Message, Vector2)"/> and simply provides an alternative type-explicit way to add a <see cref="Vector2"/> to the message.</remarks>
public static Message AddVector2(this Message message, Vector2 value) => Add(message, value);

/// <summary>Adds a <see cref="Vector2"/> to the message.</summary>
/// <param name="value">The <see cref="Vector2"/> to add.</param>
/// <returns>The message that the <see cref="Vector2"/> was added to.</returns>
public static Message Add(this Message message, Vector2 value)
{
message.Add(value.x);
message.Add(value.y);
message.AddFloat(value.x);
message.AddFloat(value.y);
return message;
}

Expand All @@ -29,14 +34,18 @@ public static Vector2 GetVector2(this Message message)
#endregion

#region Vector3
/// <inheritdoc cref="Add(Message, Vector3)"/>
/// <remarks>Relying on the correct Add overload being chosen based on the parameter type can increase the odds of accidental type mismatches when retrieving data from a message. This method calls <see cref="Add(Message, Vector3)"/> and simply provides an alternative type-explicit way to add a <see cref="Vector3"/> to the message.</remarks>
public static Message AddVector3(this Message message, Vector3 value) => Add(message, value);

/// <summary>Adds a <see cref="Vector3"/> to the message.</summary>
/// <param name="value">The <see cref="Vector3"/> to add.</param>
/// <returns>The message that the <see cref="Vector3"/> was added to.</returns>
public static Message Add(this Message message, Vector3 value)
{
message.Add(value.x);
message.Add(value.y);
message.Add(value.z);
message.AddFloat(value.x);
message.AddFloat(value.y);
message.AddFloat(value.z);
return message;
}

Expand All @@ -49,15 +58,19 @@ public static Vector3 GetVector3(this Message message)
#endregion

#region Quaternion
/// <inheritdoc cref="Add(Message, Quaternion)"/>
/// <remarks>Relying on the correct Add overload being chosen based on the parameter type can increase the odds of accidental type mismatches when retrieving data from a message. This method calls <see cref="Add(Message, Quaternion)"/> and simply provides an alternative type-explicit way to add a <see cref="Quaternion"/> to the message.</remarks>
public static Message AddQuaternion(this Message message, Quaternion value) => Add(message, value);

/// <summary>Adds a <see cref="Quaternion"/> to the message.</summary>
/// <param name="value">The <see cref="Quaternion"/> to add.</param>
/// <returns>The message that the <see cref="Quaternion"/> was added to.</returns>
public static Message Add(this Message message, Quaternion value)
{
message.Add(value.x);
message.Add(value.y);
message.Add(value.z);
message.Add(value.w);
message.AddFloat(value.x);
message.AddFloat(value.y);
message.AddFloat(value.z);
message.AddFloat(value.w);
return message;
}

Expand All @@ -69,4 +82,4 @@ public static Quaternion GetQuaternion(this Message message)
}
#endregion
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
// Copyright (c) 2021 Tom Weiland
// For additional information please see the included LICENSE.md file or view it on GitHub: https://github.com/tom-weiland/RiptideNetworking/blob/main/LICENSE.md

using RiptideNetworking;
using RiptideNetworking.Utils;
using System;
using UnityEngine;

namespace RiptideNetworking.Demos.RudpTransport.Unity.ExampleClient
namespace RiptideDemos.RudpTransport.Unity.ExampleClient
{
public enum ServerToClientId : ushort
{
Expand Down
Binary file not shown.
Loading

0 comments on commit fe7dae1

Please sign in to comment.