You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
|
using UnityEngine.Networking;
|
|
|
|
|
|
|
|
|
|
|
|
namespace UltraCombos
|
|
|
|
|
|
{
|
|
|
|
|
|
public class GrpcNetworkDiscovery : NetworkDiscovery
|
|
|
|
|
|
{
|
|
|
|
|
|
public class Config
|
|
|
|
|
|
{
|
|
|
|
|
|
public string serviceName;
|
|
|
|
|
|
public string host;
|
|
|
|
|
|
public int port;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
|
public class MessageEvent : UnityEvent<Config>
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public MessageEvent onReceivedBroadcast = new MessageEvent();
|
|
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
Initialize();
|
|
|
|
|
|
StartAsServer();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnReceivedBroadcast(string fromAddress, string data)
|
|
|
|
|
|
{
|
|
|
|
|
|
var config = JsonUtility.FromJson<Config>(data);
|
|
|
|
|
|
//config.host = System.Net.IPAddress.Parse(fromAddress).MapToIPv4().ToString();
|
|
|
|
|
|
|
|
|
|
|
|
onReceivedBroadcast.Invoke(config);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|