Compare commits
No commits in common. "7a27345f0a65f901c752e33e985572ed1f26ddc1" and "cb0a3ece4c89db2f6cffe2bc4a42fcf8814671d2" have entirely different histories.
7a27345f0a
...
cb0a3ece4c
5 changed files with 43 additions and 39 deletions
|
|
@ -378,7 +378,8 @@ 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,7 +3,6 @@ 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
|
||||||
{
|
{
|
||||||
|
|
@ -11,37 +10,42 @@ namespace DMX2
|
||||||
{
|
{
|
||||||
|
|
||||||
UdpClient udpCli=null;
|
UdpClient udpCli=null;
|
||||||
|
Thread pollThread = null;
|
||||||
|
bool running=true;
|
||||||
|
|
||||||
public OSCServer ()
|
public OSCServer ()
|
||||||
{
|
{
|
||||||
udpCli = new UdpClient(7772);
|
pollThread = new Thread(new ThreadStart(Loop));
|
||||||
udpCli.BeginReceive(UdpCliReceive,null);
|
pollThread.Start();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
void Loop ()
|
||||||
|
{
|
||||||
|
udpCli = new UdpClient (7772);
|
||||||
|
byte[] recv;
|
||||||
|
IPEndPoint remep = new IPEndPoint (IPAddress.Any, 0);
|
||||||
|
|
||||||
void UdpCliReceive(IAsyncResult ar)
|
|
||||||
{
|
try {
|
||||||
if (!ar.IsCompleted) return;
|
while (running) {
|
||||||
byte[] recv;
|
recv = udpCli.Receive (ref remep);
|
||||||
IPEndPoint remep = new IPEndPoint(IPAddress.Any, 0);
|
//Console.WriteLine(remep);
|
||||||
recv = udpCli.EndReceive(ar, ref remep);
|
OSCMessage msg = new OSCMessage(recv);
|
||||||
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);
|
||||||
ProcessMessage(msg, remep);
|
}catch{}
|
||||||
}
|
}
|
||||||
catch { }
|
} catch (SocketException ex) {
|
||||||
udpCli.BeginReceive(UdpCliReceive, null);
|
}
|
||||||
}
|
finally {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -343,8 +347,15 @@ namespace DMX2
|
||||||
protected virtual void Dispose (bool disposing)
|
protected virtual void Dispose (bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
if(udpCli!=null)
|
running=false;
|
||||||
|
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>index) {
|
if (ef-1>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>index) {
|
if (ef-1>index) {
|
||||||
ef++;
|
ef++;
|
||||||
commands[i] = ef.ToString() + cmd.Groups["params"].Value;
|
commands[i] = ef.ToString() + cmd.Groups["params"].Value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -309,7 +309,6 @@ 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))
|
||||||
|
|
@ -321,14 +320,7 @@ namespace DMX2
|
||||||
|
|
||||||
|
|
||||||
var buff = message.Encode();
|
var buff = message.Encode();
|
||||||
try
|
udpClient.Send(buff, buff.Length);
|
||||||
{
|
|
||||||
udpClient.Send(buff, buff.Length);
|
|
||||||
}
|
|
||||||
catch (SocketException)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -487,7 +479,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>index) {
|
if (ef-1>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