Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/szunami/client-sdk-csharp


https://github.com/szunami/client-sdk-csharp

Last synced: about 21 hours ago
JSON representation

Awesome Lists containing this project

README

        

# Hathora C# Client SDK

[![openupm](https://img.shields.io/npm/v/com.hathora.client?label=openupm&registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.hathora.client/)
[![NuGet version (Hathora.ClientSdk)](https://img.shields.io/nuget/v/Hathora.ClientSdk.svg?style=flat-square)](https://www.nuget.org/packages/Hathora.ClientSdk/)

## Installation

### OpenUPM

```bash
openupm add com.hathora.client
```

### Nuget
```bash
dotnet add package Hathora.ClientSdk --version 2.0.0
```

## Usage

```csharp
string appId = "...";
Hathora.Client client = new Hathora.Client(appId);
string token = await client.LoginAnonymous();
string roomId = await client.Create(token, new byte[] { });
ClientWebSocket webSocket = await client.Connect(token, roomId);
if (webSocket.State == WebSocketState.Open)
{
ArraySegment bytesReceived = new ArraySegment(new byte[1024]);
WebSocketReceiveResult readResult = await webSocket.ReceiveAsync(bytesReceived, CancellationToken.None);
await webSocket.SendAsync(Encoding.UTF8.GetBytes("{ message: \"Hello world\" }"), WebSocketMessageType.Binary, true, CancellationToken.None);
}

```

## Publishing Instructions

### OpenUPM

Update `package.json` version to $VERSION; commit this change.
```bash
git tag $VERSION
git push origin $VERSION
```
Then openUPM will trigger a build pipeline; see https://openupm.com/packages/com.hathora.client/?subPage=pipelines

### Nuget

Update the `client-sdk-csharp.csproj` `Version` property to `$VERSION`.
```bash
dotnet pack --configuration Release
nuget push ./bin/Release/Hathora.ClientSdk.$RELEASE.nupkg -Source https://api.nuget.org/v3/index.json
```