I am fairly new to signalr. Im using signalr core to make connection between unity and signalr but my code doesn't return me anything at all. That leaving me wondering if my code is actually working or not.
After I've established connection, unity will wait for server side to call a function then it will execute what it need to do.
here is my code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Microsoft.AspNetCore.SignalR.Client;
public class tyrNewSignalR : MonoBehaviour {
void Start()
{
var connection = new HubConnectionBuilder()
.WithUrl("http://api-dev-vrcafe.azurewebsites.net/restart")
.WithConsoleLogger()
.Build();
connection.On<string>("Restart", data =>
{
Console.WriteLine($"Received: {data}");
// Create unity part
// Unity logic
Debug.Log("Connection Success!");
cleanCart();
});
connection.On<string>("Cart", data =>
{
Console.WriteLine($"Received: {data}");
// Create unity part
// Unity logic
});
connection.StartAsync();
}
void cleanCart()
{
// Do cleaning cart here
}
}
I appreciate if someone can help a newbie. Thank you