<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Jaggery - Delicious Javascript</title>
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Le styles -->
    <link href="../css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
        body {
            padding-top: 60px;
        }
    </style>
    <link href="../css/prettify.css" rel="stylesheet">
    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="../images/favicon.ico">
    <link rel="apple-touch-icon" href="../images/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72"
          href="../images/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114"
          href="../images/apple-touch-icon-114x114.png">
</head>

<body>

<%
    include('/includes/topnavi.jag');
%>

<div class="container-fluid" style="width: 960px; margin: auto;">
<div class="row">
    <div class="span16">
        <div class="page-header">
            <h1>
                Documentation
                <small>API documentation for Jaggery.js</small>
            </h1>
        </div>
    </div>
</div>

<div class="row">
<div class="span4">
    <div class="well">
        <%
        include('/includes/navi.jag');
%>

    </div>

</div>
<div class="span12">
<div class="content" id="email" name="email">
<h3>webSocket</h3>
<h5>Server</h5>
            <pre class="prettyprint linenums">
&lt%
var log = new Log();
webSocket.ontext = function (data) {
    log.info('Client Sent : ' + data);
    var ws = this;
    setTimeout(function () {
       var currentDate = new Date();
       ws.send("Server Receive message "+data+" on "+currentDate);
    }, 1000);
};

webSocket.onbinary = function (stream) {
    log.info('Client Streamed : ' + stream.toString());
};
%&gt
</pre>

<h5>Client</h5>
<pre class="prettyprint linenums">
&ltscript&gt
var url = 'ws://localhost:9763/sample/ws/server.jag';
function start() {
ws = new WebSocket(url);
ws.onopen = function() {
	document.write("web Socket onopen. ");
};
//event handler for the message event in the case of text frames
ws.onmessage = function(event) {
	document.write("web Socket Onmessage from Server. " + event.data);
};
ws.onclose = function() {
	document.write("web Socket onclose. ");
};
ws.onopen();
var currentDate = new Date();
  //send message to server
  setTimeout(function() {
	 ws.send("Client Timestamp "+currentDate);
  }, 2000);

  //close socket from client
  setTimeout(function() {
	  ws.close();
  }, 5000);

}
&lt/script&gt
</pre>


<div id="pageLinks">
                <a class="navilink" href="#overview">Overview</a>
                <a class="navilink" href="#members">Members</a>
                <a class="navilink" href="#operations">Operations</a>
                </div>
                 <section id="overview">


                <h4>Overview</h4>
                <p class="description">Jaggery websocket enables full duplex transmission and 
                it supports <a href="http://dev.w3.org/html5/websockets/"> WebSocket specification</a>. It defines an API establishing "socket" connections
                 between a web browser and a server. In Simple words, There is an persistent connection between
                  the client and the server and both parties can start sending data at any time.</p>

                </section>

                <section id="members">
                <h4>Members</h4>


<table class="clsStd member-table">

<tbody>

<tr>

    <th>Member</th>
    <th>Type</th>
    <th>Description</th>

</tr>

<tr>

    <td><code>ontext</code>
    </td>
     <td>Scriptable</td>
    <td><pre class="prettyprint">webSocket.ontext = function (data) {
    log.info('Client sent : ' + data);
 };</pre>
    Create the instance that will process this inbound connection for text and allow to handle a GET request.
    </td>

</tr>
<tr>

    <td><code>onbinary</code>
    </td>
     <td>Scriptable</td>
    <td><pre class="prettyprint">webSocket.onbinary = function (stream) {    
    log.info('Client Streamed : ' + stream.toString());
 };</pre>
    Create the instance that will process this inbound connection for stream.
      </td>

</tr>


</tbody>
</table>
                </section>
<section id="operations">
    <h4>Operations</h4>

    <table class="clsStd operations-table">
    <tbody>
    <tr>
        <th>Operation</th>
        <th>Returns</th>
        <th>Description</th>
    </tr>
    <tr>

        <td><code>send (String text | Stream stream)</code></td>
		<td>None</td>
        <td>Sends data to the socket (inbound connection).<pre class="prettyprint">webSocket.ontext = function (data) {
    var ws = this;
    setTimeout(function () {
        ws.send(data);
    }, 5000);
 };</pre>
        </td>

    </tr>
    
    </tbody>

    </table>

</section>

</div>
<!-- /email div -->
<br>
<br>
</div>

</div>
<%
include('/includes/footer.jag');
%>

</div>

<!-- /container -->
<%
include('/includes/scripts.jag')
%>
	<script>	
		
		$(document).ready(function(){
        $('#webs').toggleClass('active')
		$('#docs').addClass('active')
        })
	</script>
</body>
</html>
