NadekoBot/NadekoBot.Core/Common/ShardCom/ShardComClient.cs
2017-09-30 00:46:33 +02:00

29 lines
706 B
C#

using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace NadekoBot.Common.ShardCom
{
public class ShardComClient
{
private int port;
public ShardComClient(int port)
{
this.port = port;
}
public async Task Send(ShardComMessage data)
{
var msg = JsonConvert.SerializeObject(data);
using (var client = new UdpClient())
{
var bytes = Encoding.UTF8.GetBytes(msg);
await client.SendAsync(bytes, bytes.Length, IPAddress.Loopback.ToString(), port).ConfigureAwait(false);
}
}
}
}