<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Javascript &#8211; Abetoo IoT wiki</title>
	<atom:link href="https://abetoo.com/wiki/article-categories/javascript/feed" rel="self" type="application/rss+xml" />
	<link>https://abetoo.com/wiki</link>
	<description>Abetoo IOT Framework</description>
	<lastBuildDate>Thu, 29 Jun 2017 10:37:02 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.8.25</generator>

<image>
	<url>http://abetoo.com/wiki/wp-content/uploads/cache/2017/04/logo_white/141125888.png</url>
	<title>Javascript &#8211; Abetoo IoT wiki</title>
	<link>https://abetoo.com/wiki</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Introduction. Installation</title>
		<link>https://abetoo.com/wiki/knowledge-base/introduction-installation</link>
		<comments>https://abetoo.com/wiki/knowledge-base/introduction-installation#respond</comments>
		<pubDate>Mon, 26 Jun 2017 09:26:31 +0000</pubDate>
		<dc:creator><![CDATA[abetoo]]></dc:creator>
		
		<guid isPermaLink="false">http://abetoo.com/wiki/?post_type=ht_kb&#038;p=459</guid>
		<description><![CDATA[With the Abetoo Javascript library you can send messages to a whatever device in the world from a web page, no matter if your end device is a desktop application, a mobile app or an arduino device. Simply download the javascript library code and use it in your own webpages.]]></description>
				<content:encoded><![CDATA[<p>With the Abetoo Javascript library you can send messages to a whatever device in the world from a web page, no matter if your end device is a desktop application, a mobile app or an arduino device.</p>
<p>Simply download the javascript library code and use it in your own webpages.</p>
<aside class="download-box">

	<img width="480" height="240" src="https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card.png" class="attachment-full size-full wp-post-image" alt="" srcset="https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card.png 480w, https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card-300x150.png 300w, https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card-50x25.png 50w, https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card-320x160.png 320w" sizes="(max-width: 480px) 100vw, 480px" />
	<div
		class="download-count">431 downloads</div>

	<div class="download-box-content">

		<h1 id="abetoo-javascript-library" >Abetoo Javascript Library</h1>

		
		<a class="download-button" title="" href="http://abetoo.com/wiki/download/460/" rel="nofollow">
			Download File			<small>abetoo.js &ndash; 2 KB</small>
		</a>

	</div>
</aside>



]]></content:encoded>
			<wfw:commentRss>https://abetoo.com/wiki/knowledge-base/introduction-installation/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First steps. Hello World</title>
		<link>https://abetoo.com/wiki/knowledge-base/first-steps-hello-world</link>
		<comments>https://abetoo.com/wiki/knowledge-base/first-steps-hello-world#respond</comments>
		<pubDate>Mon, 26 Jun 2017 09:50:46 +0000</pubDate>
		<dc:creator><![CDATA[abetoo]]></dc:creator>
		
		<guid isPermaLink="false">http://abetoo.com/wiki/?post_type=ht_kb&#038;p=471</guid>
		<description><![CDATA[Once you&#8217;ve downloaded the last version of the Abetoo Javascript library you&#8217;re done to start. We&#8217;re going to build a website which allow us to connect and receive messages. Open a regular text editor and create a new file called helloworld.html, and copy the following lines, let&#8217;s go and check [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Once you&#8217;ve downloaded the last version of the Abetoo Javascript library you&#8217;re done to start.</p>
<p>We&#8217;re going to build a website which allow us to connect and receive messages.</p>
<p>Open a regular text editor and create a new file called <em>helloworld.html</em>, and copy the following lines,</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;html&gt;
&lt;body&gt;
   &lt;div&gt;&lt;h2&gt;Abetoo Library JavaScript Hello World&lt;/h2&gt;&lt;/div&gt;
   &lt;div&gt;Messages Received&lt;/div&gt;
   &lt;div&gt;
   &lt;textarea readonly id=&quot;messagesreceived&quot; rows=&quot;13&quot; cols=&quot;40&quot; &gt;
   &lt;/textarea&gt;
   &lt;/div
&lt;/body&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;abetoo.js&quot;&gt;&lt;/script&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;

   // Define a new Abetoo connection
   var abetoo = Abetoo.getInstance();
   abetoo.init(&quot;-7glliYjxdE-H6QudCmEL7g636307126198941784#&quot;+
               &quot;8dd71c893d5502f2b5ae0e5175a8c588a0060474&quot;, callback);
   function callback(newmessage)
   {
      // Once a new message is received, 
      // append it to the messages received box
      var textelement = document.getElementById('messagesreceived');
      textelement.value += newmessage + &quot;\n&quot;;
      textelement.scrollTop = textelement.scrollHeight;
   }
&lt;/script&gt;
&lt;/html&gt;
</pre>
<p>let&#8217;s go and check it out the source code more deeply,</p>
<p>The most important thing you have to do is to include the abetoo library with the following line, the file <em>abetoo.js</em> has to be on the same folder you are working on.</p>
<pre class="brush: jscript; title: ; notranslate">
....
&lt;script type=&quot;text/javascript&quot; src=&quot;abetoo.js&quot;&gt;&lt;/script&gt;
....
</pre>
<p>Then we can define and launch the connection,</p>
<pre class="brush: jscript; title: ; notranslate">
....
   // Define a new Abetoo connection
   var abetoo = Abetoo.getInstance();
   abetoo.init(&quot;-7glliYjxdE-H6QudCmEL7g636307126198941784#&quot;+
               &quot;8dd71c893d5502f2b5ae0e5175a8c588a0060474&quot;, callback);
....
</pre>
<p>&#8230; and establish a listener for the incoming messages,</p>
<pre class="brush: jscript; title: ; notranslate">
function callback(newmessage)
   {
      // Once a new message is received, 
      // append it to the messages received box
      var textelement = document.getElementById('messagesreceived');
      textelement.value += newmessage + &quot;\n&quot;;
      textelement.scrollTop = textelement.scrollHeight;
   }
</pre>
<p>in this particular case, whenever a new message is received, it&#8217;s appended to the received messages box.</p>
<p>If you open the generated <em>helloworld.html</em> file with a web browser you&#8217;ll see something like that,</p>
<p><a href="http://abetoo.com/wiki/wp-content/uploads/2017/06/javascipt_hello_world.bmp"><img class="size-full wp-image-478 aligncenter" src="http://abetoo.com/wiki/wp-content/uploads/2017/06/javascipt_hello_world.bmp" alt="" width="471" height="348" /></a></p>
<p>You can download the full source code of this example.</p>
<aside class="download-box">

	<img width="480" height="240" src="https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card.png" class="attachment-full size-full wp-post-image" alt="" srcset="https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card.png 480w, https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card-300x150.png 300w, https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card-50x25.png 50w, https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card-320x160.png 320w" sizes="(max-width: 480px) 100vw, 480px" />
	<div
		class="download-count">271 downloads</div>

	<div class="download-box-content">

		<h1 id="hello-world-source-code" >Hello World source code</h1>

		
		<a class="download-button" title="" href="http://abetoo.com/wiki/download/482/" rel="nofollow">
			Download File			<small>helloworld_example.zip &ndash; 2 KB</small>
		</a>

	</div>
</aside>



]]></content:encoded>
			<wfw:commentRss>https://abetoo.com/wiki/knowledge-base/first-steps-hello-world/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>To Infinity and Beyond</title>
		<link>https://abetoo.com/wiki/knowledge-base/javascript_to-infinity-and-beyond</link>
		<comments>https://abetoo.com/wiki/knowledge-base/javascript_to-infinity-and-beyond#comments</comments>
		<pubDate>Mon, 26 Jun 2017 10:19:48 +0000</pubDate>
		<dc:creator><![CDATA[abetoo]]></dc:creator>
		
		<guid isPermaLink="false">http://abetoo.com/wiki/?post_type=ht_kb&#038;p=480</guid>
		<description><![CDATA[Once you&#8217;ve understood the basics, you&#8217;re ready to communicate the web app with the world. We&#8217;re going to build a web app that allows us to send and receive messages to/from any other connected devices, even another web app. This web app will also allow us to test the connectivity [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Once you&#8217;ve understood the basics, you&#8217;re ready to communicate the web app with the world.</p>
<p>We&#8217;re going to build a web app that allows us to send and receive messages to/from any other connected devices, even another web app. This web app will also allow us to test the connectivity against remote devices.</p>
<p>If you don&#8217;t change the Remote Channel id, every message sent will appear at the abetoo website.</p>
<p>Open a regular text editor and create a new file called <em>messagetesttool.html</em> and copy the following code,</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;html&gt;
&lt;body&gt;
 &lt;div&gt;&lt;h2&gt;Abetoo Library JavaScript Test Tool&lt;/h2&gt;&lt;/div&gt;
 &lt;table&gt;
 &lt;tr&gt;
 &lt;td&gt;
 &lt;div&gt;Remote Channel Id&lt;/div&gt;
 &lt;div&gt;&lt;textarea id=&quot;remotechannel&quot; rows=&quot;5&quot; cols=&quot;40&quot; &gt;&lt;/textarea&gt;
 &lt;div&gt;Message Content&lt;/div&gt;
 &lt;div&gt;
 &lt;textarea id=&quot;messagecontent&quot; placeholder=&quot;write a new message...&quot; 
 rows=&quot;5&quot; cols=&quot;40&quot; &gt;&lt;/textarea&gt;&lt;/div&gt;
 &lt;div&gt;&lt;button type=&quot;button&quot; onclick=&quot;sendMessage();&quot;/&gt;Send&lt;/div&gt;
 &lt;/td&gt;
 &lt;td&gt;
 &lt;div&gt;Messages Received&lt;/div&gt;
 &lt;div&gt;&lt;textarea readonly id=&quot;messagesreceived&quot; rows=&quot;13&quot; cols=&quot;40&quot; &gt;
 &lt;/textarea&gt;
 &lt;/td&gt;
 &lt;/tr&gt;
 &lt;/table&gt;
&lt;/body&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;abetoo.js&quot;&gt;&lt;/script&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;

 // Default remote channel
 var remoteChannelId = &quot;-7glliYjxdE-H6QudCmEL7g636307126198941784#&quot; +
 &quot;8dd71c893d5502f2b5ae0e5175a8c588a0060474&quot;;
 var textarea = document.getElementById('remotechannel');
 textarea.value = remoteChannelId;
 
 // Define a new Abetoo connection
 var abetoo = Abetoo.getInstance();
 abetoo.init(&quot;-7glliYjxdE-H6QudCmEL7g636307126198941784#&quot;+ 
 &quot;8dd71c893d5502f2b5ae0e5175a8c588a0060474&quot;, callback);
 function callback(newmessage)
 {
  // Once a new message is received, append it to the messages received box
  var textelement = document.getElementById('messagesreceived');
  textelement.value += newmessage + &quot;\n&quot;;
  textelement.scrollTop = textelement.scrollHeight;
 }

 // This function is called whenever the send button is clicked
 function sendMessage()
 {
  var remotechannel = document.getElementById('remotechannel').value;
  var messagecontent = document.getElementById('messagecontent').value;
  var correlationid = &quot;-&quot;;
  abetoo.sendMessage(remotechannel, messagecontent, correlationid);
 } 
 &lt;/script&gt;
&lt;/html&gt;
</pre>
<p>There&#8217;s a few changes over the hello world sample code.</p>
<p>We&#8217;ve introduced a new function to send messages, whenever the <em>send</em> button is clicked a new message is sent to the remote channel introduced and with the content defined in the textarea with the id <em>messagecontent</em>.</p>
<pre class="brush: jscript; title: ; notranslate">
....
 // This function is called whenever the send button is clicked
 function sendMessage()
 {
  var remotechannel = document.getElementById('remotechannel').value;
  var messagecontent = document.getElementById('messagecontent').value;
  var correlationid = &quot;-&quot;;
  abetoo.sendMessage(remotechannel, messagecontent, correlationid);
 } 
....
</pre>
<p>If you want to change the default local Channel id, please modify the <em>abetoo.init</em> function call with your unique channel id.</p>
<p>If you launch the code above with a regular web browser, you&#8217;ll see something like that,</p>
<p><a href="http://abetoo.com/wiki/wp-content/uploads/2017/06/javascipt_librarytesttool.bmp"><img class="size-full wp-image-494 aligncenter" src="http://abetoo.com/wiki/wp-content/uploads/2017/06/javascipt_librarytesttool.bmp" alt="" width="685" height="361" /></a></p>
<p>This app is very useful not only to communicate with another web app but to be able to test quickly ours desktop/mobile app. You can use it as a remote console test.</p>
<p>You can download the full source code of this example with the following link.</p>
<aside class="download-box">

	<img width="480" height="240" src="https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card.png" class="attachment-full size-full wp-post-image" alt="" srcset="https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card.png 480w, https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card-300x150.png 300w, https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card-50x25.png 50w, https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card-320x160.png 320w" sizes="(max-width: 480px) 100vw, 480px" />
	<div
		class="download-count">296 downloads</div>

	<div class="download-box-content">

		<h1 id="test-tool-source-code" >Test tool source code</h1>

		
		<a class="download-button" title="" href="http://abetoo.com/wiki/download/495/" rel="nofollow">
			Download File			<small>abetootesttool_example.zip &ndash; 2 KB</small>
		</a>

	</div>
</aside>



]]></content:encoded>
			<wfw:commentRss>https://abetoo.com/wiki/knowledge-base/javascript_to-infinity-and-beyond/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Basic Chat application.</title>
		<link>https://abetoo.com/wiki/knowledge-base/basic-chat-application</link>
		<comments>https://abetoo.com/wiki/knowledge-base/basic-chat-application#respond</comments>
		<pubDate>Mon, 26 Jun 2017 14:11:46 +0000</pubDate>
		<dc:creator><![CDATA[abetoo]]></dc:creator>
		
		<guid isPermaLink="false">http://abetoo.com/wiki/?post_type=ht_kb&#038;p=502</guid>
		<description><![CDATA[With the following application you can communicate two web pages with each other, even guessing that they aren&#8217;t at the same location. Download and open the app zip file, you&#8217;ll find two files jschatuser1.html and jschatuser2.html. You can open the files with any web browser, either both locally or in separate [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>With the following application you can communicate two web pages with each other, even guessing that they aren&#8217;t at the same location.</p>
<div class="pki" style="height: 330px; width: 800px;"></div>
		<script>
			jQuery(function($){
				var vidbgContainerValue = '.pki';
				var vidbgMp4Value = 'http://abetoo.com/wiki/wp-content/uploads/2017/06/capture-6.mp4';
				var vidbgWebmValue = '#';
				var vidbgPosterValue = '#';
				var vidbgIsMuted = true;
				var vidbgIsLoop = true;
				var vidbgIsOverlay = false;
				var vidbgOverlayColor = '#888';
				var vidbgOverlayAlpha = '0.3';

				$(vidbgContainerValue).vidbg({
					'mp4': vidbgMp4Value,
					'webm': vidbgWebmValue,
					'poster': vidbgPosterValue,
				}, {
					muted: vidbgIsMuted,
					loop: vidbgIsLoop,
					overlay: vidbgIsOverlay,
					overlayColor: vidbgOverlayColor,
					overlayAlpha: vidbgOverlayAlpha,
				});
			});
		</script>
<p>Download and open the app zip file, you&#8217;ll find two files <em>jschatuser1.html</em> and <em>jschatuser2.html. </em>You can open the files with any web browser, either both locally or in separate computers.</p>
<aside class="download-box">

	<img width="480" height="240" src="https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card.png" class="attachment-full size-full wp-post-image" alt="" srcset="https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card.png 480w, https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card-300x150.png 300w, https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card-50x25.png 50w, https://abetoo.com/wiki/wp-content/uploads/2017/06/javascript-card-320x160.png 320w" sizes="(max-width: 480px) 100vw, 480px" />
	<div
		class="download-count">339 downloads</div>

	<div class="download-box-content">

		<h1 id="web-chat-source-code" >Web Chat source code</h1>

		
		<a class="download-button" title="" href="http://abetoo.com/wiki/download/518/" rel="nofollow">
			Download File			<small>chatjavascript.zip &ndash; 3 KB</small>
		</a>

	</div>
</aside>



]]></content:encoded>
			<wfw:commentRss>https://abetoo.com/wiki/knowledge-base/basic-chat-application/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Library reference</title>
		<link>https://abetoo.com/wiki/knowledge-base/javascript_library-reference</link>
		<comments>https://abetoo.com/wiki/knowledge-base/javascript_library-reference#respond</comments>
		<pubDate>Mon, 26 Jun 2017 14:30:21 +0000</pubDate>
		<dc:creator><![CDATA[abetoo]]></dc:creator>
		
		<guid isPermaLink="false">http://abetoo.com/wiki/?post_type=ht_kb&#038;p=523</guid>
		<description><![CDATA[Constructor (Singleton) var abetoo = Abetoo.getInstance(); The object is defined as a singleton object, so first at all you have to get the instance. Methods init(QueueName, Callback) Used to establish a connection with the remote server, normally called just after obtain the instance Abetoo object. Once the connection is triggered, [&#8230;]]]></description>
				<content:encoded><![CDATA[<h3 id="constructor" id="constructor-singleton" ><em><strong>Constructor (Singleton)</strong></em></h3>
<h4 id="public-abtooconnectionstring-queuename-int-heartbeat" id="var-abetoo-abetoo-getinstance" ><strong>var abetoo = Abetoo.getInstance();</strong></h4>
<p>The object is defined as a singleton object, so first at all you have to get the instance.</p>
<h3 id="methods" id="methods" ><em><strong>Methods</strong></em></h3>
<h4 id="initqueuename-callback" ><strong>init(</strong><strong>QueueName, Callback</strong><strong>)</strong></h4>
<p>Used to establish a connection with the remote server, normally called just after obtain the instance Abetoo object. Once the connection is triggered, the abetoo object takes care about connection lost management and reconnections. You need to pass two parameters.</p>
<ul>
<li><strong>QueueName</strong>, This is an string which represents the local channel id.</li>
<li><b>Callback</b>, Used to define a function called whenever a new message is received.</li>
</ul>
<h4 id="public-void-disconnect" id="_" ></h4>
<h4 id="public-bool-sendmessagestring-destinationid-string-body-string-correlationid" id="bool-sendmessagestring-destinationid-string-body-string-correlationid" ><strong>bool sendMessage(String DestinationId, String Body, String Correlationid)</strong></h4>
<p>Used to send messages to a remote device using it’s channel id</p>
<ul>
<li><strong>DestinationId</strong>, channel id of the remote device you want to send a message.</li>
<li><strong>Body</strong>, message as a XML/JSON or as a plain text.</li>
<li><strong>Correlationid, </strong>used to keep track about the messages sent/received. If you want to use a challenge/response approach you can associate the challenge sent message with a correlation id, once a message is received you can use its correlation id to identify the associated challenge message.</li>
</ul>
<h3 id="events" id="_" ></h3>
]]></content:encoded>
			<wfw:commentRss>https://abetoo.com/wiki/knowledge-base/javascript_library-reference/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
