Unclaimed Package Is this your package? Claim it to unlock full analytics and manage your listing.
Claim This Package

Install via UPM

Add to Unity Package Manager using this URL

https://www.pkglnk.dev/sandsocketunity.git

README Markdown

Copy this to your project's README.md

Style
Preview
pkglnk installs badge
## Installation

Add **Sand Socket Unity** to your Unity project via Package Manager:

1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/sandsocketunity.git
```

[![pkglnk](https://www.pkglnk.dev/badge/sandsocketunity.svg?style=pkglnk)](https://www.pkglnk.dev/pkg/sandsocketunity)

README

openupm

Sand Unity

Sand Unity is a Unity3D client for Sand, built as a UPM (Unity Package Manager).

Installing

As long as Sand Unity is a UPM, all you need to do is to add a package to your project with this repo url (dont forget the .git extension).

Usage

Using Sand Unity is very easy, add a Sand.Client component to any GameObject in your scene, and call the method Connect whenever you want to start your connection with the server.

public Sand.Client client;

public void Start() {
  // Starting the server
  client.Connect();
  
  // Adding listeners
  // Connected is called when the client has completed the handshake with the server
  client.Emitter.On("connected", OnConnected);
  // Listening to chat messages
  client.Emitter.On("chat", OnChat);
}

public void OnConnected(string data) {
  Debug.Log("Connected");
}

public void OnChat(string data) {
  Debug.Log("Received data: " + data);
}

Examples

For full examples with server and client please visit this repository.

Delimiters

If you changed the package or event delimiter in the server, you'll need to change it in the client too.

public Sand.Client client;

public void Start() {
  // Starting the server
  client.Connect();
  client.SetDelimiters("packetDelimiter", "eventDelimiter");
}

Using TLS

You can easely use TLS in your client by defining the Client's property "useTLS" as true.

public Sand.Client client;

public void Start() {
  // Starting the server
  client.useTLS = true;
  client.Connect();
}

PS: If you are using a self-signed certificate in your server, you'll have to define the Client's property "validateCert" as false, because Unity by default prevents this type of authentication triggering a cert error.

public Sand.Client client;

public void Start() {
  // Starting the server
  client.useTLS = true;
  client.validateCert = false;
  client.Connect();
}

Roadmap

  • Use bytes instead of text as data format.

Comments

No comments yet. Be the first!