<html><head><base href="x-msg://511/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,<div><br></div><div>You have to somehow pass that information to your script. If you wish to control the channel, you could use the "socket" application which establishes an outbound tcp connection to your application.<div><br></div><div>Otherwise, you could always send an event from the dialplan containing the call's uuid. The event socket connection can control of any calls on the system, how exactly are you bridging the call to your speech server?</div><div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div><span class="Apple-style-span" style="font-size: 12px; "><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></span><br class="Apple-interchange-newline">
</div>
<br><div><div>On 2010-12-14, at 2:20 PM, Brian Campbell wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; ">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;<span class="Apple-converted-space">&nbsp;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string uuid = '????????'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><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;<span class="Apple-converted-space">&nbsp;</span><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;<span class="Apple-converted-space">&nbsp;</span><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:<span class="Apple-converted-space">&nbsp;</span><a href="mailto:mrene_lists@avgs.ca">mrene_lists@avgs.ca</a><br>Date: Thu, 2 Dec 2010 12:05:42 -0500<br>To:<span class="Apple-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>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 class="ecxApple-style-span" style="font-size: 12px; "><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 class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal medium/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><div class="ecxhmmessage" style="font-family: Tahoma; font-size: 10pt; ">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 class="ecxApple-style-span" style="font-size: 12px; "><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 class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal medium/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><div class="ecxhmmessage" style="font-family: Tahoma; font-size: 10pt; ">&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<span class="Apple-converted-space">&nbsp;</span><a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><span class="Apple-converted-space">&nbsp;</span><a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<span class="Apple-converted-space">&nbsp;</span><a href="http://www.freeswitch.org">http://www.freeswitch.org</a><span class="Apple-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">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">http://www.freeswitch.org</a><br></div></span></blockquote></div><br></div></div></body></html>