create OscClient

This commit is contained in:
Cassandra de la Cruz-Munoz 2023-09-24 13:30:20 -04:00
parent f5f3a5e527
commit aa00d09708
2 changed files with 41 additions and 1 deletions

41
OscClient.cs Normal file
View File

@ -0,0 +1,41 @@
using System;
using System.Net;
using System.Net.Http;
using Godot;
namespace godotOscSharp
{
public class OscClient
{
private readonly OscReceiver receiver;
private readonly OscSender sender;
public OscClient(IPAddress host, int port)
{
receiver = new OscReceiver(port);
sender = new OscSender(host, port);
}
public void SenderConnect() {
sender.Connect();
}
public void Send(OscMessage message) {
sender.Send(message);
}
public void AddMessageReceived(EventHandler<OscMessageReceivedEventArgs> func) {
receiver.MessageReceived += func;
}
public void AddErrorReceived(EventHandler<OscErrorReceivedEventArgs> func) {
receiver.ErrorReceived += func;
}
public void Dispose()
{
receiver.Dispose();
sender.Dispose();
}
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Godot;
using System;
using System.Net;
using System.Net.Sockets;