<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[A script pane belonging to all sessions]]></title><description><![CDATA[<p dir="auto">I would like to be able to have two or three different sessions and write only one script to deal with all sessions at the same time; for example, on one script I would like to have onLogRecord event for each and every session.<br />
This feature is very useful in building testing devices/software with multiple sockets/communication channels.<br />
Does IO Ninja have this capability?</p>
]]></description><link>http://64.23.185.212/forum/topic/7/a-script-pane-belonging-to-all-sessions</link><generator>RSS for Node</generator><lastBuildDate>Tue, 06 Oct 2026 19:16:03 GMT</lastBuildDate><atom:link href="http://64.23.185.212/forum/topic/7.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 22 Jul 2021 04:25:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to A script pane belonging to all sessions on Wed, 04 Aug 2021 05:34:33 GMT]]></title><description><![CDATA[<p dir="auto">I see; thanks a lot for the complete answer.</p>
]]></description><link>http://64.23.185.212/forum/post/19</link><guid isPermaLink="true">http://64.23.185.212/forum/post/19</guid><dc:creator><![CDATA[Mohammad]]></dc:creator><pubDate>Wed, 04 Aug 2021 05:34:33 GMT</pubDate></item><item><title><![CDATA[Reply to A script pane belonging to all sessions on Thu, 22 Jul 2021 06:41:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://64.23.185.212/forum/uid/3">@mohammad</a> Welcome to IO Ninja Forums! <img src="http://64.23.185.212/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=miq4h6da9ug" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" title=":)" alt="🙂" /></p>
<p dir="auto">IO Ninja doesn't have this capability. It's not that it's technically impossible, but it would complicate a lot of things and what's more important, would be very difficult to use.</p>
<p dir="auto">Imagine, your <code>onLogRecord()</code> callback is being called for <em>each and every</em> record in all opened sessions. How do you distinguish an incoming <code>log.StdRecordCode.Rx</code> block of one session from that of another? The only way is to introduce some sort of a session identifier and pass it to your callback. Now, this raises questions. First, what this session identifier should look like? Session title? It is not unique, and strings are not cheap to conditionally <em>branch on</em> in your script (for each added log record!). A number? You would need to somehow look up (or assign) this identifier for each open session. OK, let's say we have this identifier. But adding session-specific branching to your script essentially "binds" it to <em>this particular set of open sessions</em>! What if you close and reopen IO Ninja and start a different set of sessions? You would need to update your <code>onLogRecord</code> callback every time!</p>
<p dir="auto">The same reasoning applies to <code>transmit</code> -- you would need to somehow specify which session to transmit data to (and again we gonna have session identifiers and the need to update your script if the set of open sessions changes).</p>
<p dir="auto">Another consideration against such design is that each session is running in a dedicated process, and having such a "supervisor" script would require passing memory blocks across process boundaries -- which is not a cheap operation.</p>
<p dir="auto">So I strongly feel like keeping it as is -- in-app scripts are running in the context of a session process, so they are strictly <em>per-session</em>. <code>onLogRecord</code> is called for records of <em>this particular session</em>, and <code>transmit</code> sends data again to <em>this particular session</em>. Also, calling <code>onLogRecord()</code> is relatively cheap. It doesn't even involve in-process memory copy! We create a so-called <em>pointer validator</em> -- to prevent your script from accidentally (or intentionally <img src="http://64.23.185.212/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=miq4h6da9ug" class="not-responsive emoji emoji-android emoji--wink" title=";)" alt="😉" /> accessing or corrupting memory beyond the log record block -- and pass it directly to you <code>onLogRecord()</code>.</p>
<p dir="auto">Overall, this is a much simpler and cleaner design.</p>
]]></description><link>http://64.23.185.212/forum/post/8</link><guid isPermaLink="true">http://64.23.185.212/forum/post/8</guid><dc:creator><![CDATA[Vladimir]]></dc:creator><pubDate>Thu, 22 Jul 2021 06:41:15 GMT</pubDate></item></channel></rss>