Table of Contents

Class Network

Namespace
VsGlobal
Assembly
VSGlobal.dll
public static class Network
Inheritance
Network
Inherited Members

Methods

Broadcast<T>(T, string?)

Called when you want to broadcast to the server. Note; we don't have to be connected to call this. It's thread safe and sitting there patiently for the websocket state to be 'Open' (connected)
Example with a custom network message:

//First, we define our network packet somewhere like so.
[ProtoContract(ImplicitFields = ImplicitFields.AllPublic)]
public class CustomNetworkMessage
{
	public bool didSomething;
	public IClientPlayer sender;
	public string message = "Default Message";
}

// Later on, in a function body ...

// All we have to do is call broadcast. It's generic, so you can throw _anything_ in there. string, class, struct- Whatever.
VsGlobal.Broadcast(new CustomNetworkMessage(){didSomething = true, sender = api.World.Player, message = "Grungus"});
// What that will do is send the packet to the server and relay it to others.
// Once received, it'll invoke Events.OnPayloadReceived
public static void Broadcast<T>(T packet, string? module = null)

Parameters

packet T
module string

Type Parameters

T