Skip to content

Commit

Permalink
Merge pull request #25 from ChanyaVRC/dev
Browse files Browse the repository at this point in the history
Release v1.3.2
  • Loading branch information
ChanyaVRC committed Nov 14, 2022
2 parents c533ea6 + c1cb093 commit c3f2b4d
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 44 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
ubuntu-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Restore dependencies
Expand All @@ -25,9 +25,9 @@ jobs:
windows-build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Restore dependencies
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ I can also download from [NuGet Package Manager](https://docs.microsoft.com/nuge


## Usage in code
Please check the `Sample` for the combination with the actual application.

### About avatar parameters
If you want to control avatar parameters, use classes in `BuildSoft.VRChat.Osc.Avatar`.
Expand Down Expand Up @@ -104,6 +105,36 @@ await Task.Delay(1000);
OscButtonInput.Jump.Release();
```

### About Chatbox
If you want to use button input with OSC, use classes in `BuildSoft.VRChat.Osc.Chatbox`.

#### e.g.) Send a string to Chatbox
```cs
using BuildSoft.VRChat.Osc.Chatbox;

OscChatbox.SendMessage("some message", direct: true);
```

#### e.g.) Send a string to Chatbox UI
```cs
using BuildSoft.VRChat.Osc.Chatbox;

OscChatbox.SendMessage("some message", direct: false);
```

#### e.g.) Act like typing
```cs
using BuildSoft.VRChat.Osc.Chatbox;
using System.Threading.Tasks;

// typing during 3 second.
OscChatbox.SetIsTyping(true);
await Task.Delay(3000);

OscChatbox.SendMessage("some message", direct: true);
```


<!-- ## Contact
* Twitter: [@ChanyaVRChat1](https://twitter.com/ChanyaVRChat1)
* Discord: [Chanya#0386](https://discord.com/channels/@me/924538047373115392) -->
49 changes: 19 additions & 30 deletions src/vrcosclib.Test/TestUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,50 +95,39 @@ public static void RestoreOscDirectory()
}
}

#if NETFRAMEWORK
#if !NET6_0_OR_GREATER
public static async Task WaitAsync(this Task task, TimeSpan timeout)
{
// if not running, start task
try
{
task.Start();
}
catch (InvalidOperationException)
{
}
var source = CreateCancellationTokenSourceWithDelay(timeout);

bool isSuccessed = Task.Run(() => { while (task.Status == TaskStatus.Running || task.Status == TaskStatus.WaitingForActivation) ; }).Wait(timeout);
if (!isSuccessed)
await Task.Run(() =>
{
throw new TimeoutException();
}
while (true)
{
if (source.IsCancellationRequested) { throw new TimeoutException(); }
if (task.IsCompleted) { break; }
}
});
if (task.IsFaulted)
{
throw task.Exception.InnerException;
throw task.Exception!.InnerException!;
}
}

public static async Task<T> WaitAsync<T>(this Task<T> task, TimeSpan timeout)
{
// if not running, start task
try
{
task.Start();
}
catch (InvalidOperationException)
{
}
await WaitAsync((Task)task, timeout);
return task.Result;
}

bool isSuccessed = Task.Run(() => { while (task.Status == TaskStatus.Running || task.Status == TaskStatus.WaitingForActivation) ; }).Wait(timeout);
if (!isSuccessed)
{
throw new TimeoutException();
}
if (task.IsFaulted)
private static CancellationTokenSource CreateCancellationTokenSourceWithDelay(TimeSpan delay)
{
CancellationTokenSource source = new(delay);
if (delay <= TimeSpan.Zero)
{
throw task.Exception.InnerException;
source.Cancel();
}
return task.Result;
return source;
}
#endif
}
12 changes: 5 additions & 7 deletions src/vrcosclib.Test/vrcosclib.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
<RootNamespace>BuildSoft.VRChat.Osc.Test</RootNamespace>
<LangVersion>10.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<IsPackable>false</IsPackable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.0" />
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" version="4.1.0" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/vrcosclib/Avatar/OscAvatarParametorContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public OscAvatarParametorContainer(ImmutableArray<OscAvatarParameter> parameters
for (int i = 0; i < parameters.Length; i++)
{
var param = parameters[i];
var outputInterface = param.Output;
var outputInterface = param.Output!;
Debug.Assert(outputInterface != null);
allParams.AddValueChangedEventByAddress(outputInterface.Address, GetValueCallback);
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 5 additions & 2 deletions src/vrcosclib/vrcosclib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<Nullable>enable</Nullable>
<RootNamespace>BuildSoft.VRChat.Osc</RootNamespace>
<RootNamespace>BuildSoft.VRChat.Osc</RootNamespace>
<LangVersion>10.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>

<BaseOutputPath>..\..\bin</BaseOutputPath>

<PackageId>VRCOscLib</PackageId>
<Version>1.3.1</Version>
<Version>1.3.2</Version>
<Authors>ChanyaKushima</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageDescription>A OSC library for VRChat</PackageDescription>
Expand All @@ -22,6 +22,9 @@
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard2.0'))">
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
</ItemGroup>

Expand Down

0 comments on commit c3f2b4d

Please sign in to comment.