Commit e68bc710 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

files for testing lighttpd mod_wstunnel

parent ba354660
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
#!/usr/bin/perl -Tw
$SIG{PIPE} = 'IGNORE';
for (my $FH; accept($FH, STDIN); close $FH) {
    select($FH); $|=1; # $FH->autoflush;
    print $FH $_ while (<$FH>);
}
+9 −0
Original line number Diff line number Diff line
server.document-root = "/www/pages"  # not used in this example
#server.bind = "127.0.0.1" 
server.port = 8080

server.modules += ("mod_proxy")
proxy.server = ( "/" => (( "host" => "127.0.0.1", "port" => "8081" )))
proxy.header = ( "upgrade" => "enable" )

 
+23 −0
Original line number Diff line number Diff line
server.document-root = "/tmp"  # not used in this example
#server.bind = "127.0.0.1" 
#server.port = 8081
server.port = 80
mimetype.assign = (".txt" => "text/plain", ".html" => "text/html" )

server.modules += ("mod_wstunnel")
wstunnel.server = (
  "/ws/" => (
    (
      "socket" => "/tmp/wstunnel.socket",
      "bin-path" => "/www/pages/echo.pl",
      "max-procs" => 1
    )
  ),
  "/ws-nobin/" => (
    (
      "socket" => "/tmp/wstunnel-nobin.socket",
#      "bin-path" => "/www/pages/echo.pl",
      "max-procs" => 1
    )
  )
) 
+18 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<!-- modified from example in https://github.com/joewalnes/websocketd README.md -->
<pre id="log"></pre>
<script>
  // helper function: log message to screen
  var logelt = document.getElementById('log');
  function log(msg) { logelt.textContent += msg + '\n'; }
  // helper function: send websocket msg with count (1 .. 5)
  var host = location.hostname;
  log('SERVER: '+host);
  var ll = 0;
  function send_msg() { if (++ll <= 5) { log('SEND: '+ll); ws.send(ll+'\n'); } }
  // setup websocket with callbacks
  var ws = new WebSocket('ws://'+host+':80/ws/');
  ws.onopen = function()         { log('CONNECT\n'); send_msg(); };
  ws.onclose = function()        { log('DISCONNECT'); };
  ws.onmessage = function(event) { log('RECV: ' + event.data); send_msg(); };
</script>