NadekoBot/NadekoBot.Core/Common/ShardCom/ShardComClient.cs

29 lines
706 B
C#
Raw Normal View History

2017-07-17 19:42:36 +00:00
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
2017-07-17 19:42:36 +00:00
using Newtonsoft.Json;
2017-07-17 19:42:36 +00:00
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);
}
}
}
}