AlexVeeBee's Wiki

Connect

  1. Create a void that has a Webocket class
public partial class MyGame : GameManager
{
	public async Task TestWebSocket()
	{
		WebSocket Socket = new();
	}
}
  1. Add a try catch statement to see if the connection was a success or not
public async Task TestWebSocket()
{
	WebSocket Socket = new();
  try {
  
  }
  catch ( Exception e ) 
  {
  	Log.Error( "Unable to connect" );
  }
}
  1. Connecting
public async Task TestWebSocket()
{
	WebSocket Socket = new();
  try {
  	await Socket.Connect( "ws://localhost:3000/" );
  	Log.Info("Connected")
  }
  catch ( Exception e ) 
  {
  	Log.Error( "Unable to connect" );
  }
}
  1. Dedect if the websocket has closed
Socket.OnDisconnected += ( s, r ) =>
{
	Log.Error("Discconected from server");
};

References ( commands )

dashboard

ANY ONE CAN ENTER HERE

{command: "dashboard"}

Get a live stat of the server and the ammount of connected users in the server

sql

AUTH KEYS WILL BE REQUIERED IN THE FUTURE

{command: "sql", query: "SELECT * FROM `test`"}

Send over sql code to insert into the database

block

ANYONE CAN USE THIS

{command: "block", ip: "IP"}

Block ips from connecting the websocket server