Compare commits
3 commits
cb0a3ece4c
...
7a27345f0a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a27345f0a | ||
|
|
0a3b58f73d | ||
|
|
ea8ee8040a |
5 changed files with 39 additions and 43 deletions
|
|
@ -378,8 +378,7 @@ namespace DMX2
|
||||||
if (tickThread != null) {
|
if (tickThread != null) {
|
||||||
running = false;
|
running = false;
|
||||||
tickThread.Join (50);
|
tickThread.Join (50);
|
||||||
tickThread.Abort ();
|
}
|
||||||
}
|
|
||||||
foreach (var seq in sequenceurs) {
|
foreach (var seq in sequenceurs) {
|
||||||
IDisposable idis = seq as IDisposable;
|
IDisposable idis = seq as IDisposable;
|
||||||
if(idis!=null) idis.Dispose();
|
if(idis!=null) idis.Dispose();
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DMX2
|
namespace DMX2
|
||||||
{
|
{
|
||||||
|
|
@ -10,42 +11,37 @@ namespace DMX2
|
||||||
{
|
{
|
||||||
|
|
||||||
UdpClient udpCli=null;
|
UdpClient udpCli=null;
|
||||||
Thread pollThread = null;
|
|
||||||
bool running=true;
|
|
||||||
|
|
||||||
public OSCServer ()
|
public OSCServer ()
|
||||||
{
|
{
|
||||||
pollThread = new Thread(new ThreadStart(Loop));
|
udpCli = new UdpClient(7772);
|
||||||
pollThread.Start();
|
udpCli.BeginReceive(UdpCliReceive,null);
|
||||||
}
|
|
||||||
|
|
||||||
void Loop ()
|
}
|
||||||
{
|
|
||||||
udpCli = new UdpClient (7772);
|
|
||||||
byte[] recv;
|
|
||||||
IPEndPoint remep = new IPEndPoint (IPAddress.Any, 0);
|
|
||||||
|
|
||||||
|
void UdpCliReceive(IAsyncResult ar)
|
||||||
try {
|
{
|
||||||
while (running) {
|
if (!ar.IsCompleted) return;
|
||||||
recv = udpCli.Receive (ref remep);
|
byte[] recv;
|
||||||
//Console.WriteLine(remep);
|
IPEndPoint remep = new IPEndPoint(IPAddress.Any, 0);
|
||||||
OSCMessage msg = new OSCMessage(recv);
|
recv = udpCli.EndReceive(ar, ref remep);
|
||||||
|
OSCMessage msg = new OSCMessage(recv);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Console.Write(msg.Address);
|
Console.Write(msg.Address);
|
||||||
Console.Write(" ");
|
Console.Write(" ");
|
||||||
foreach(var arg in msg.Args)
|
foreach (var arg in msg.Args)
|
||||||
Console.WriteLine(arg.GetString());
|
Console.WriteLine(arg.GetString());
|
||||||
#endif
|
#endif
|
||||||
try{
|
try
|
||||||
ProcessMessage(msg,remep);
|
{
|
||||||
}catch{}
|
ProcessMessage(msg, remep);
|
||||||
}
|
}
|
||||||
} catch (SocketException ex) {
|
catch { }
|
||||||
}
|
udpCli.BeginReceive(UdpCliReceive, null);
|
||||||
finally {
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -347,15 +343,8 @@ namespace DMX2
|
||||||
protected virtual void Dispose (bool disposing)
|
protected virtual void Dispose (bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
running=false;
|
if(udpCli!=null)
|
||||||
if(udpCli!=null)
|
|
||||||
udpCli.Close();
|
udpCli.Close();
|
||||||
if(pollThread!=null)
|
|
||||||
{
|
|
||||||
if(!pollThread.Join(100))
|
|
||||||
pollThread.Abort();
|
|
||||||
pollThread=null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -658,7 +658,7 @@ namespace DMX2
|
||||||
var cmd = regexCommand2.Match(commands[i]);
|
var cmd = regexCommand2.Match(commands[i]);
|
||||||
if(cmd.Success){
|
if(cmd.Success){
|
||||||
int ef = int.Parse(cmd.Groups["effet"].Value);
|
int ef = int.Parse(cmd.Groups["effet"].Value);
|
||||||
if (ef-1>index) {
|
if (ef>index) {
|
||||||
ef++;
|
ef++;
|
||||||
commands[i] = ef.ToString() + cmd.Groups["params"].Value;
|
commands[i] = ef.ToString() + cmd.Groups["params"].Value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -566,7 +566,7 @@ namespace DMX2
|
||||||
var cmd = regexCommand2.Match(commands[i]);
|
var cmd = regexCommand2.Match(commands[i]);
|
||||||
if(cmd.Success){
|
if(cmd.Success){
|
||||||
int ef = int.Parse(cmd.Groups["effet"].Value);
|
int ef = int.Parse(cmd.Groups["effet"].Value);
|
||||||
if (ef-1>index) {
|
if (ef>index) {
|
||||||
ef++;
|
ef++;
|
||||||
commands[i] = ef.ToString() + cmd.Groups["params"].Value;
|
commands[i] = ef.ToString() + cmd.Groups["params"].Value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -309,6 +309,7 @@ namespace DMX2
|
||||||
string[] data = enCours.Commande.Split(' ');
|
string[] data = enCours.Commande.Split(' ');
|
||||||
|
|
||||||
OSCMessage message = new OSCMessage(data[0]);
|
OSCMessage message = new OSCMessage(data[0]);
|
||||||
|
if (data.Length < 2) return;
|
||||||
for (int i = 1; i < data.Length; i++)
|
for (int i = 1; i < data.Length; i++)
|
||||||
{
|
{
|
||||||
if (int.TryParse(data[i], out int di))
|
if (int.TryParse(data[i], out int di))
|
||||||
|
|
@ -320,7 +321,14 @@ namespace DMX2
|
||||||
|
|
||||||
|
|
||||||
var buff = message.Encode();
|
var buff = message.Encode();
|
||||||
udpClient.Send(buff, buff.Length);
|
try
|
||||||
|
{
|
||||||
|
udpClient.Send(buff, buff.Length);
|
||||||
|
}
|
||||||
|
catch (SocketException)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -479,7 +487,7 @@ namespace DMX2
|
||||||
var cmd = regexCommand2.Match(commands[i]);
|
var cmd = regexCommand2.Match(commands[i]);
|
||||||
if(cmd.Success){
|
if(cmd.Success){
|
||||||
int ef = int.Parse(cmd.Groups["effet"].Value);
|
int ef = int.Parse(cmd.Groups["effet"].Value);
|
||||||
if (ef-1>index) {
|
if (ef>index) {
|
||||||
ef++;
|
ef++;
|
||||||
commands[i] = ef.ToString() + cmd.Groups["params"].Value;
|
commands[i] = ef.ToString() + cmd.Groups["params"].Value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue