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.
46 lines
1.1 KiB
46 lines
1.1 KiB
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");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|