[Freeswitch-svn] [commit] r9365 - in freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket: . Commands SipEvents
Freeswitch SVN
verifier at freeswitch.org
Tue Aug 26 04:17:44 EDT 2008
Author: verifier
Date: Tue Aug 26 04:17:43 2008
New Revision: 9365
Modified:
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Originate.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventManager.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventParser.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventSocket.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceIn.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceOut.cs
Log:
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Originate.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Originate.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Originate.cs Tue Aug 26 04:17:43 2008
@@ -23,9 +23,10 @@
private SofiaSipAddress _caller;
private Address _destination;
private readonly IList<ChannelVariable> _variables = new List<ChannelVariable>();
- private string _callerIdName = null;
- private string _callerIdNumber = null;
- private bool _varsAdded = false;
+ private string _callerIdName;
+ private string _callerIdNumber;
+ private bool _varsAdded;
+ private bool _autoAnswer;
public Originate()
{}
@@ -80,6 +81,9 @@
if (!string.IsNullOrEmpty(_callerIdNumber))
_variables.Add(new ChannelVariable("origination_caller_id_number", _callerIdNumber));
_varsAdded = true;
+
+ if (_autoAnswer)
+ _variables.Add(new ChannelVariable("sip_auto_answer", "true"));
}
string variables = string.Empty;
@@ -92,20 +96,21 @@
}
}
+ public bool AutoAnswer
+ {
+ get { return _autoAnswer; }
+ set { _autoAnswer = value; }
+ }
+
public override CommandReply CreateReply(string dataToParse)
{
string[] nameValue = dataToParse.Split(' ');
if (nameValue[0].Length > 0 && nameValue[0][0] == '+')
return new OriginateReply(true, nameValue[1]);
- else
- {
- OriginateReply reply = new OriginateReply(false, string.Empty);
- if (nameValue.Length > 1)
- reply.ErrorMessage = nameValue[1];
- else
- reply.ErrorMessage = dataToParse;
- return reply;
- }
+
+ OriginateReply reply = new OriginateReply(false, string.Empty);
+ reply.ErrorMessage = nameValue.Length > 1 ? nameValue[1] : dataToParse;
+ return reply;
}
}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventManager.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventManager.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventManager.cs Tue Aug 26 04:17:43 2008
@@ -15,6 +15,8 @@
public event EventHandler EventReceived;
private readonly EventsWriter _writer;
private readonly TextWriter _rawLog;
+ private object _logLocker = new object();
+
public string Password
{
set { _socket.Password = value; }
@@ -47,7 +49,8 @@
private void OnData(string data)
{
- _writer(data);
+ lock (_logLocker)
+ _writer(data);
}
/// <summary>
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventParser.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventParser.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventParser.cs Tue Aug 26 04:17:43 2008
@@ -61,7 +61,7 @@
private void IgnoreLineBreaks(ref int i)
{
- while (i < Text.Length && (Text[i] == '\n' || Text[i] == '\r'))
+ while (i < _text.Length && (_text[i] == '\n' || _text[i] == '\r'))
++i;
}
@@ -80,15 +80,15 @@
}
PlainEventMsg plainEvent;
- lock (Text)
+ lock (_text)
{
int i = 0;
// find complete header
bool found = false;
- for (; i < Text.Length - 1; ++i)
+ for (; i < _text.Length - 1; ++i)
{
- if (Text[i] == '\n' && Text[i+1] == '\n')
+ if (_text[i] == '\n' && _text[i + 1] == '\n')
{
found = true;
break;
@@ -99,13 +99,8 @@
// extract header
char[] chars = new char[i];
- Text.CopyTo(0, chars, 0, i);
+ _text.CopyTo(0, chars, 0, i);
string headers = new string(chars);
-#if DEBUG
- Console.WriteLine("====================================");
- Console.WriteLine("Headers: ");
- Console.WriteLine(headers);
-#endif
IgnoreLineBreaks(ref i);
plainEvent = new PlainEventMsg();
@@ -117,12 +112,12 @@
// Start of Empty header bugfix
// FS seems to send a header with content-length without sending an actual body
// this will eat that kind of header.
- if (Text.Length >= BugWorkaround.Length + i)
+ if (_text.Length >= BugWorkaround.Length + i)
{
found = true;
for (int index = 0; index < BugWorkaround.Length; ++index)
{
- if (Text[index + i] != BugWorkaround[index])
+ if (_text[index + i] != BugWorkaround[index])
{
found = false;
break;
@@ -130,7 +125,7 @@
}
if (found)
{
- Text.Remove(0, i);
+ _text.Remove(0, i);
Console.WriteLine("Removing empty content header.");
return null;
}
@@ -138,12 +133,12 @@
// end of bugfix.
// not enough data for body.
- if (plainEvent.ContentLength + i > Text.Length)
+ if (plainEvent.ContentLength + i > _text.Length)
return null;
// extract body
chars = new char[plainEvent.ContentLength];
- Text.CopyTo(i, chars, 0, plainEvent.ContentLength);
+ _text.CopyTo(i, chars, 0, plainEvent.ContentLength);
plainEvent.Body = new string(chars);
// check for errors.
@@ -156,14 +151,10 @@
Console.WriteLine("Body");
Console.WriteLine(plainEvent.Body);
Console.WriteLine("=========================== EVERYTHING in _text ==============================");
- Console.WriteLine(Text);
- throw new InvalidDataException("Fucked up event: " + Text);
+ Console.WriteLine(_text);
+ throw new InvalidDataException("Fucked up event: " + _text);
}
-#if DEBUG
- Console.WriteLine("Body:");
- Console.WriteLine(plainEvent.Body);
-#endif
if (plainEvent.Body.Length < plainEvent.ContentLength)
throw new InvalidDataException("Body contents are too small!");
@@ -174,7 +165,7 @@
// remove header( + body) from buffer
- Text.Remove(0, i);
+ _text.Remove(0, i);
}
return plainEvent;
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventSocket.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventSocket.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventSocket.cs Tue Aug 26 04:17:43 2008
@@ -127,6 +127,9 @@
string inbuffer;
try
{
+ if (_stream == null)
+ return; // closed socket.
+
int bytesRead = _stream.EndRead(ar);
if (bytesRead == 0)
{
@@ -144,7 +147,7 @@
return;
}
- if (DataReceived != null)
+ if (DataReceived != null && !string.IsNullOrEmpty(inbuffer))
DataReceived(inbuffer);
try
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceIn.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceIn.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceIn.cs Tue Aug 26 04:17:43 2008
@@ -4,7 +4,7 @@
{
public override string ToString()
{
- return "PresenceIn." + base.ToString();
+ return "In." + base.ToString();
}
}
}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceOut.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceOut.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceOut.cs Tue Aug 26 04:17:43 2008
@@ -4,7 +4,7 @@
{
public override string ToString()
{
- return "PresenceOut." + base.ToString();
+ return "Out." + base.ToString();
}
More information about the Freeswitch-svn
mailing list