<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Hi,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
So I figured it out</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="font-family:monospace"><span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">static</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
</span><span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">switch_status_t</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> read_packet(</span><span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">listener_t</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
 *listener, </span><span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">switch_event_t</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> **event,
</span><span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">uint32_t</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> timeout)
</span><br>
{ <br>
       <span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">switch_size_t</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> mlen, bytes = 0;
</span><br>
       <span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">char</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> *mbuf =
</span><span style="font-weight: bold; color: rgb(255, 84, 84); background-color: rgb(255, 255, 255);">NULL</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">;
</span><br>
       <span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">char</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> newLine[2] =
</span><span style="font-weight: bold; color: rgb(255, 255, 84); background-color: rgb(255, 255, 255);">"\n"</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">;  //added this new line str</span><br>
       <span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">char</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> buf[1024] =
</span><span style="font-weight: bold; color: rgb(255, 255, 84); background-color: rgb(255, 255, 255);">""</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">;
</span><br>
       <span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">switch_size_t</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> len;
</span><br>
       <span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">switch_status_t</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> status =
</span><span style="font-weight: bold; color: rgb(255, 84, 84); background-color: rgb(255, 255, 255);">SWITCH_STATUS_SUCCESS</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">;</span><br>
</span>.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="font-family:monospace"><span style="font-weight: bold; color: rgb(255, 255, 84); background-color: rgb(255, 255, 255);">if</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> (switch_test_flag(listener,
</span><span style="font-weight: bold; color: rgb(255, 84, 84); background-color: rgb(255, 255, 255);">LFLAG_EVENTS</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">)) {
</span><br>
                               <span style="font-weight: bold; color: rgb(255, 255, 84); background-color: rgb(255, 255, 255);">while</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> (switch_queue_trypop(listener->event_queue,
 &pop) == </span><span style="font-weight: bold; color: rgb(255, 84, 84); background-color: rgb(255, 255, 255);">SWITCH_STATUS_SUCCESS</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">) {
</span><br>
                                       <span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">char</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> hbuf[512];
</span><br>
                                       <span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">switch_event_t</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> *pevent = (</span><span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">switch_event_t</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
 *) pop; </span><br>
                                       <span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">char</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> *etype;
</span><br>
<br>
                                       do_sleep = 0; <br>
                                       <span style="font-weight: bold; color: rgb(255, 255, 84); background-color: rgb(255, 255, 255);">if</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> (listener->format ==
</span><span style="font-weight: bold; color: rgb(255, 84, 84); background-color: rgb(255, 255, 255);">EVENT_FORMAT_PLAIN</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">) {
</span><br>
                                               etype = <span style="font-weight: bold; color: rgb(255, 255, 84); background-color: rgb(255, 255, 255);">
"plain"</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">;
</span><br>
                                               switch_event_serialize(pevent, &listener->ebuf,
<span style="font-weight: bold; color: rgb(255, 84, 84); background-color: rgb(255, 255, 255);">
SWITCH_TRUE</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">);
</span><br>
                                       } <span style="font-weight: bold; color: rgb(255, 255, 84); background-color: rgb(255, 255, 255);">
else</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
</span><span style="font-weight: bold; color: rgb(255, 255, 84); background-color: rgb(255, 255, 255);">if</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> (listener->format ==
</span><span style="font-weight: bold; color: rgb(255, 84, 84); background-color: rgb(255, 255, 255);">EVENT_FORMAT_JSON</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">) {
</span><br>
                                               etype = <span style="font-weight: bold; color: rgb(255, 255, 84); background-color: rgb(255, 255, 255);">
"json"</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">;
</span><br>
                                               switch_event_serialize_json(pevent, &listener->ebuf);
<br>
                                               strcat(listener->ebuf, newLine); //concatenate new line str to the event<br>
                                       } <span style="font-weight: bold; color: rgb(255, 255, 84); background-color: rgb(255, 255, 255);">
else</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> {
</span><br>
                                               <span style="color: rgb(24, 178, 24); background-color: rgb(255, 255, 255);">switch_xml_t</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> xml;
</span><br>
                                               etype = <span style="font-weight: bold; color: rgb(255, 255, 84); background-color: rgb(255, 255, 255);">
"xml"</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">;
</span><br>
<br>
                                               <span style="font-weight: bold; color: rgb(255, 255, 84); background-color: rgb(255, 255, 255);">if</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> ((xml = switch_event_xmlize(pevent,
</span><span style="font-weight: bold; color: rgb(255, 84, 84); background-color: rgb(255, 255, 255);">SWITCH_VA_NONE</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">))) {
</span><br>
                                                       listener->ebuf = switch_xml_toxml(xml,
<span style="font-weight: bold; color: rgb(255, 84, 84); background-color: rgb(255, 255, 255);">
SWITCH_FALSE</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">);
</span><br>
                                                       switch_xml_free(xml); <br>
                                               } <span style="font-weight: bold; color: rgb(255, 255, 84); background-color: rgb(255, 255, 255);">
else</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> {
</span><br>
                                                       switch_log_printf(<span style="font-weight: bold; color: rgb(255, 84, 84); background-color: rgb(255, 255, 255);">SWITCH_CHANNEL_SESSION_LOG</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">(listener->sessio</span><span style="color: rgb(255, 255, 255); background-color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"></span><br>
                                                       <span style="color: rgb(178, 24, 178); background-color: rgb(255, 255, 255);">goto</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"> endloop;
</span><br>
                                               } <br>
                                       }<br>
</span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div id="divtagdefaultwrapper" style="font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Calibri, Arial, Helvetica, sans-serif;">
Mahmood Alkhalil.</div>
</div>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> FreeSWITCH-users <freeswitch-users-bounces@lists.freeswitch.org> on behalf of Mahmood Alkhalil <mahmood.alkhalil@outlook.com><br>
<b>Sent:</b> Thursday, January 20, 2022 10:49 AM<br>
<b>To:</b> freeswitch-users@lists.freeswitch.org <freeswitch-users@lists.freeswitch.org><br>
<b>Subject:</b> [Freeswitch-users] Add new line ending after mod_event_socket JSON event</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
</div>
Hi FS Community,
<div><br>
</div>
<div>I'm trying to add a '\n' new line after the JSON event sent from FS on the mod_event_socket when the event type is JSON, I need to do so as I'm writing a JAVA event parser and it would make the code much simpler if I can add this new line after the event.</div>
<div><br>
</div>
<div>I'm not able to know where to edit exactly in the mod_event_scoket file (I have no experience in C lang at all) but I think it is somewhere around line 1274.</div>
<div><br>
</div>
<div>If someone could help with this, I would really appreciate it.</div>
<div><br>
</div>
<div>(the java socket lib am writing uses Netty DelimiterBasedFrameDecoder on '\n' nut it breaks as after the JSON event there is no new line and Content-Length: is directly written after the JSON event)</div>
<div><br>
</div>
Mahmood Alkhalil.
<div>
<div id="x_Signature">
<div>
<div id="x_divtagdefaultwrapper" style="font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif">
</div>
</div>
</div>
</div>
</div>
</body>
</html>