Skip to content

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

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta
Notifications You must be signed in to change notification settings

ccadori/sand-socket-unity

Repository files navigation

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.

About

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

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Packages

No packages published

Languages