<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Thanks Mathieu&nbsp;<BR>
&nbsp;<BR>
I have up dated my code as per your instructions.<BR>
&nbsp;<BR>
FreeSwitch answers the call and then does a bridge to my Speech Server application. If there are 10 simultaneous&nbsp;calls going on there would be 20 channels.&nbsp;When I send 'api show channels', I get info back for all 20 channels. How do I go about deciding which one&nbsp;contains the correct uuid for the session that I am trying to set a custom channel variable for&nbsp;?<BR>
&nbsp;<BR>
Here is my code<BR>
&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp; private void injectCdrCode_ExecuteCode(object sender, EventArgs e)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TcpClient newClient = new TcpClient();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Connect to the port<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newClient.Connect(_host, _port);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NetworkStream tcpStream = newClient.GetStream();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; byte[] receivedBytes = new byte[newClient.ReceiveBufferSize];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int bytesRead = tcpStream.Read(receivedBytes, 0, newClient.ReceiveBufferSize);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string returnData = Encoding.ASCII.GetString(receivedBytes);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Authenticate<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; byte[] sendBytes = Encoding.ASCII.GetBytes("auth ClueCon\n\n");<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tcpStream.Write(sendBytes, 0, sendBytes.Length);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; receivedBytes = new byte[newClient.ReceiveBufferSize];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bytesRead = tcpStream.Read(receivedBytes, 0, newClient.ReceiveBufferSize);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; returnData = Encoding.ASCII.GetString(receivedBytes);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Get channel info<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sendBytes = Encoding.ASCII.GetBytes("api show channels\n\n");<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tcpStream.Write(sendBytes, 0, sendBytes.Length);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; receivedBytes = new byte[newClient.ReceiveBufferSize];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bytesRead = tcpStream.Read(receivedBytes, 0, newClient.ReceiveBufferSize);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; returnData = Encoding.ASCII.GetString(receivedBytes);<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // How do I get the proper UUID from the info provided by 'api show channels'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string uuid = '????????'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Set the Custom Channel Variable<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sendBytes = Encoding.ASCII.GetBytes("api uuid_setvar " + uuid + " qqOneReach_ApplicationId BRIAN" + "\n\n");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tcpStream.Write(sendBytes, 0, sendBytes.Length);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; receivedBytes = new byte[newClient.ReceiveBufferSize];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bytesRead = tcpStream.Read(receivedBytes, 0, newClient.ReceiveBufferSize);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; returnData = Encoding.ASCII.GetString(receivedBytes);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Clean everything up<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tcpStream.Flush();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tcpStream.Close();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newClient.Close();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (Exception ex)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw ex;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }<BR><BR>
&nbsp;<BR>
Thanks<BR>
&nbsp;<BR>
Brian Campbell<BR>
&nbsp;<BR>

<HR id=stopSpelling>
From: mrene_lists@avgs.ca<BR>Date: Thu, 2 Dec 2010 12:05:42 -0500<BR>To: freeswitch-users@lists.freeswitch.org<BR>Subject: Re: [Freeswitch-users] Custom Channel Variables via C#<BR><BR>
<META name=Generator content="Microsoft SafeHTML"><BASE>You need to authenticate first.
<DIV><BR></DIV>
<DIV>
<DIV>Trying 127.0.0.1...</DIV>
<DIV>Connected to localhost</DIV>
<DIV>Escape character is '^]'.</DIV>
<DIV>Content-Type: auth/request</DIV>
<DIV><BR></DIV>
<DIV>auth ClueCon</DIV>
<DIV><BR></DIV>
<DIV>Content-Type: command/reply</DIV>
<DIV>Reply-Text: +OK accepted</DIV>
<DIV><BR></DIV>
<DIV>api show channels</DIV>
<DIV><BR></DIV>
<DIV>Content-Type: api/response</DIV>
<DIV>Content-Length: 748</DIV>
<DIV><BR></DIV>
<DIV>uuid,direction,created,created_epoch,name,state,cid_name,cid_num,ip_addr,dest,application,application_data,dialplan,context,read_codec,read_rate,read_bit_rate,write_codec,write_rate,write_bit_rate,secure,hostname,presence_id,presence_data,callstate,callee_name,callee_num,callee_direction,call_uuid</DIV>
<DIV>aa6e6bee-1c3b-4493-b824-765c5a15f02c,outbound,2010-12-02 12:03:58,1291309438,loopback/park-a,CS_CONSUME_MEDIA,,0000000000,,park,,,inline,inline,L16,8000,128000,L16,8000,128000,,mrene.local,,,RINGING,,,,c9781e01-667e-446b-93e8-a081f0287d15</DIV>
<DIV>78ff4bb6-573e-4a60-a920-bfdb67f3ed6b,inbound,2010-12-02 12:03:58,1291309438,loopback/park-b,CS_EXECUTE,,0000000000,,park,park,,inline,inline,L16,8000,128000,L16,8000,128000,,mrene.local,,,RINGING,,,,</DIV>
<DIV><BR></DIV>
<DIV>2 total.</DIV></DIV>
<DIV><BR></DIV>
<DIV>Then you can use the uuid_* commands.</DIV>
<DIV><BR>
<DIV>
<DIV>
<DIV><SPAN style="FONT-SIZE: 12px" class=ecxApple-style-span>
<DIV>Mathieu Rene</DIV>
<DIV>Avant-Garde Solutions Inc</DIV>
<DIV>Office: + 1 (514) 664-1044 x100</DIV>
<DIV>Cell: +1 (514) 664-1044 x200</DIV>
<DIV><A href="mailto:mrene@avgs.ca">mrene@avgs.ca</A></DIV>
<DIV><BR></DIV>
<DIV><BR></DIV></SPAN></DIV><BR class=ecxApple-interchange-newline></DIV><BR>
<DIV>
<DIV>On 2010-12-02, at 10:03 AM, Brian Campbell wrote:</DIV><BR class=ecxApple-interchange-newline>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt" class=ecxhmmessage>Thanks, the link was very helpful<BR>&nbsp;<BR>I have taken a look at the link that you provided<BR>&nbsp;<BR>I assume now that I can use uuid_setvar to accomplish what I want<BR>&nbsp;<BR>Assuming that the uuid is 53d37581-1f90-44bf-860a-addbc8430e3a,&nbsp;it seems that my code would need to change to<BR>&nbsp;<BR>&nbsp;<BR>private void injectCdrCode_ExecuteCode(object sender, EventArgs e)<BR>{<BR>&nbsp; try<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; TcpClient newClient = new TcpClient();<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; newClient.Connect("127.0.0.1", 8021);<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; NetworkStream tcpStream = newClient.GetStream();<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; byte[] sendBytes = Encoding.ASCII.GetBytes("api uuid_setvar 53d37581-1f90-44bf-860a-addbc8430e3a myChannelVariable&nbsp;12345");<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; tcpStream.Write(sendBytes, 0, sendBytes.Length);<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; tcpStream.Close();<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; newClient.Close();<BR>&nbsp; }<BR>&nbsp; catch(Exception ex)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; throw ex;<BR>&nbsp; }<BR>}<BR><BR>My question now becomes, how do I go about finding out the uuid for the session ? Is that obtainable via mod_event_socket or is there another way ?<BR>&nbsp;<BR>Thanks<BR>&nbsp;<BR>Brian&nbsp;<BR>
<HR id=ecxstopSpelling>
From:<SPAN class=ecxApple-converted-space>&nbsp;</SPAN><A href="mailto:mrene_lists@avgs.ca">mrene_lists@avgs.ca</A><BR>Date: Wed, 1 Dec 2010 16:53:53 -0500<BR>To:<SPAN class=ecxApple-converted-space>&nbsp;</SPAN><A href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</A><BR>Subject: Re: [Freeswitch-users] Custom Channel Variables via C#<BR><BR>
<DIV>Hi,</DIV>
<DIV><BR></DIV>
<DIV>You can't send XML dialplan actions on the socket and expect FreeSWITCH to understand it, you must follow the event socket protocol.
<DIV><BR></DIV>
<DIV>See&nbsp;<A href="http://wiki.freeswitch.org/wiki/Event_socket" target=_blank>http://wiki.freeswitch.org/wiki/Event_socket</A>&nbsp;for more information.</DIV>
<DIV><BR>
<DIV>
<DIV><SPAN style="FONT-SIZE: 12px" class=ecxApple-style-span>
<DIV>Mathieu Rene</DIV>
<DIV>Avant-Garde Solutions Inc</DIV>
<DIV>Office: + 1 (514) 664-1044 x100</DIV>
<DIV>Cell: +1 (514) 664-1044 x200</DIV>
<DIV><A href="mailto:mrene@avgs.ca">mrene@avgs.ca</A></DIV>
<DIV><BR></DIV>
<DIV><BR></DIV></SPAN></DIV><BR class=ecxApple-interchange-newline></DIV><BR>
<DIV>
<DIV>On 2010-12-01, at 4:46 PM, Brian Campbell wrote:</DIV><BR class=ecxApple-interchange-newline>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt" class=ecxhmmessage>&nbsp;<BR>I can set a custom channel variable in my incomming dial plan like this...<BR>&nbsp;<BR>&lt;action application='set' data='MyChannelVariable=12345' /&gt;<BR>&nbsp;<BR>And it shows up fine in the CDR<BR>&nbsp;<BR>I am now attempting to use mod_event_socket to set a custom channel variable and have it&nbsp;appear in the CDR<BR>&nbsp;<BR>Here is the C# code so far, the code is part of a Microsoft Speech Server application that is answering the call<BR>&nbsp;<BR>private void injectCdrCode_ExecuteCode(object sender, EventArgs e)<BR>{<BR>&nbsp; try<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; TcpClient newClient = new TcpClient();<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; newClient.Connect("127.0.0.1", 8021);<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; NetworkStream tcpStream = newClient.GetStream();<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; byte[] sendBytes = Encoding.ASCII.GetBytes("&lt;action application='set' data='MyChannelVariable=12345' /&gt;");<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; tcpStream.Write(sendBytes, 0, sendBytes.Length);<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; tcpStream.Close();<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; newClient.Close();<BR>&nbsp; }<BR>&nbsp; catch(Exception ex)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; throw ex;<BR>&nbsp; }<BR>}<BR>&nbsp;<BR>After the call is answered, the C# code seems to run fine, but I dont see the custom channel variable in the resulting CDR<BR>&nbsp;<BR>I figure I am not setting it correctly<BR>&nbsp;<BR>Can anyone advise on what I am doing wrong ?<BR>&nbsp;<BR>Thanks<BR>&nbsp;<BR>&nbsp;<BR>Brian<BR>&nbsp;<BR>&nbsp;<BR>_______________________________________________<BR>FreeSWITCH-users mailing list<BR><A href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</A><BR><A href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target=_blank>http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</A><BR>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<BR><A href="http://www.freeswitch.org/" target=_blank>http://www.freeswitch.org</A><BR></DIV></SPAN></BLOCKQUOTE></DIV><BR></DIV></DIV><BR>_______________________________________________ FreeSWITCH-users mailing list<SPAN class=ecxApple-converted-space>&nbsp;</SPAN><A href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</A><SPAN class=ecxApple-converted-space>&nbsp;</SPAN><A href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target=_blank>http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</A>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<SPAN class=ecxApple-converted-space>&nbsp;</SPAN><A href="http://www.freeswitch.org/" target=_blank>http://www.freeswitch.org</A><SPAN class=ecxApple-converted-space>&nbsp;</SPAN>_______________________________________________<BR>FreeSWITCH-users mailing list<BR><A href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</A><BR><A href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target=_blank>http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</A><BR>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<BR><A href="http://www.freeswitch.org/" target=_blank>http://www.freeswitch.org</A><BR></DIV></SPAN></BLOCKQUOTE></DIV><BR></DIV></DIV><BR>_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org                                               </body>
</html>