using System.Collections; using System.Collections.Generic; using UnityEngine; using RabbitMQ.Client; using System; using System.Threading.Channels; using UnityEditor.MemoryProfiler; using System.Text; public class Test : MonoBehaviour { [SerializeField] string user; [SerializeField] string password; [SerializeField] string host; [SerializeField] string port; [SerializeField] string vhost; [SerializeField] bool pub = false; //Uri Uri => new Uri($"amqp://{user}:{password}@{host}:{port}/{vhost}"); Uri Uri => new Uri($"amqp://{user}:{password}@{host}"); ConnectionFactory factory; private void Start() { factory = new ConnectionFactory(); factory.Uri = Uri; } private void Update() { if (pub) { pub = false; using (var conn = factory.CreateConnection()) using (var channel = conn.CreateModel()) { byte[] body = Encoding.UTF8.GetBytes("Hello, world!"); channel.BasicPublish("test", string.Empty, null, body); Debug.Log("ok"); } } } }