72 lines
1 KiB
C#
72 lines
1 KiB
C#
using System;
|
|
using System.Net;
|
|
using System.Net.Sockets;
|
|
using System.Threading;
|
|
using System.Collections.Generic;
|
|
|
|
namespace DMX2
|
|
{
|
|
public class OSCServer : IDisposable
|
|
{
|
|
|
|
UdpClient udpCli=null;
|
|
Thread pollThread = null;
|
|
bool running=true;
|
|
|
|
public OSCServer ()
|
|
{
|
|
pollThread = new Thread(new ThreadStart(Loop));
|
|
pollThread.Start();
|
|
}
|
|
|
|
void Loop ()
|
|
{
|
|
udpCli = new UdpClient (7772);
|
|
byte[] recv;
|
|
IPEndPoint remep = new IPEndPoint (IPAddress.Any, 0);
|
|
|
|
|
|
try {
|
|
while (running) {
|
|
recv = udpCli.Receive (ref remep);
|
|
}
|
|
} catch (SocketException ex) {
|
|
}
|
|
finally {
|
|
}
|
|
}
|
|
|
|
public void Flush ()
|
|
{
|
|
}
|
|
|
|
|
|
#region IDisposable implementation
|
|
|
|
|
|
public void Dispose ()
|
|
{
|
|
Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
protected virtual void Dispose (bool disposing)
|
|
{
|
|
if (disposing) {
|
|
running=false;
|
|
if(udpCli!=null)
|
|
udpCli.Close();
|
|
if(pollThread!=null)
|
|
{
|
|
if(!pollThread.Join(100))
|
|
pollThread.Abort();
|
|
pollThread=null;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|