Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the remote-js Reference Manual, version 0.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 14:53:55 2020 GMT+0.
• Introduction | What remote-js is all about | |
• Systems | The systems documentation | |
• Modules | The modules documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
Send JavaScript from Common Lisp to a browser.
First, we create a context object:
(defvar ctx (remote-js:make-context))
Then we start the WebSockets server:
(remote-js:start ctx)
Now, remote-js gives us a function that generates the HTML of a simple page that
connects to this context and notifies it when it's connected. We write the HTML
to ~/test.html
:
(with-open-file (stream (merge-pathnames #p"test.html" (user-homedir-pathname))
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(write-string (remote-js:html ctx) stream))
Open the file in your browser. Now you can do:
(remote-js:eval ctx "alert('hello!')")
And you will see the alert box pop up in your browser.
remote-js defines a function in the generated HTML, RemoteJS.send
, which takes
a string and sends it to the server. You can specify a callback for receiving
messages like this:
(defvar ctx (remote-js:make-context
:callback #'(lambda (message) (format t "Received: ~A~%" message))))
Then, start everything and generate the HTML file again:
(remote-js:start ctx)
(with-open-file (stream (merge-pathnames #p"test.html" (user-homedir-pathname))
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(write-string (remote-js:html ctx) stream))
And open test.html
in your browser.
Now you can send messages to the server like this:
CL-USER> (remote-js:eval ctx "RemoteJS.send('hi!')")
Received: hi!
Note: when a client connects to the server, it sends the string
remote-js:+connected-message+
.
The tests use trivial-open-browser, and running them will open your default browser to a temporary file.
Copyright (c) 2016 Fernando Borretti
Licensed under the MIT License.
Next: Modules, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The remote-js system |
Fernando Borretti <eudoxiahp@gmail.com>
Fernando Borretti <eudoxiahp@gmail.com>
(:git "git@github.com:ceramic/remote-js.git")
MIT
Send JavaScript from Common Lisp to a browser.
# remote-js
[](https://travis-ci.org/ceramic/remote-js)
Send JavaScript from Common Lisp to a browser.
# Overview
# Usage
## Simple Example
First, we create a context object:
“‘lisp
(defvar ctx (remote-js:make-context))
“‘
Then we start the WebSockets server:
“‘lisp
(remote-js:start ctx)
“‘
Now, remote-js gives us a function that generates the HTML of a simple page that
connects to this context and notifies it when it’s connected. We write the HTML
to ‘~/test.html‘:
“‘lisp
(with-open-file (stream (merge-pathnames #p"test.html" (user-homedir-pathname))
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(write-string (remote-js:html ctx) stream))
“‘
Open the file in your browser. Now you can do:
“‘lisp
(remote-js:eval ctx "alert(’hello!’)")
“‘
And you will see the alert box pop up in your browser.
## Talking to the server
remote-js defines a function in the generated HTML, ‘RemoteJS.send‘, which takes
a string and sends it to the server. You can specify a callback for receiving
messages like this:
“‘lisp
(defvar ctx (remote-js:make-context
:callback #’(lambda (message) (format t "Received: ~A~%" message))))
“‘
Then, start everything and generate the HTML file again:
“‘lisp
(remote-js:start ctx)
(with-open-file (stream (merge-pathnames #p"test.html" (user-homedir-pathname))
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(write-string (remote-js:html ctx) stream))
“‘
And open ‘test.html‘ in your browser.
Now you can send messages to the server like this:
“‘lisp
CL-USER> (remote-js:eval ctx "RemoteJS.send(’hi!’)")
Received: hi!
“‘
**Note:** when a client connects to the server, it sends the string
‘remote-js:+connected-message+‘.
# Tests
The tests use [trivial-open-browser][tob], and running them will open your
default browser to a temporary file.
# License
Copyright (c) 2016 Fernando Borretti
Licensed under the MIT License.
[tob]: http://quickdocs.org/trivial-open-browser/
0.1
remote-js.asd (file)
src (module)
Modules are listed depth-first from the system components tree.
• The remote-js/src module |
remote-js (system)
src/
remote-js.lisp (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The remote-js.asd file | ||
• The remote-js/src/remote-js.lisp file |
Next: The remote-js/src/remote-js․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
remote-js.asd
remote-js (system)
Previous: The remote-js․asd file, Up: Lisp files [Contents][Index]
src (module)
src/remote-js.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The remote-js package |
The main package.
remote-js.lisp (file)
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported special variables | ||
• Exported functions | ||
• Exported generic functions | ||
• Exported classes |
Next: Exported functions, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
remote-js.lisp (file)
Next: Exported generic functions, Previous: Exported special variables, Up: Exported definitions [Contents][Index]
Create a buffered context object.
remote-js.lisp (file)
Create a context object.
remote-js.lisp (file)
Next: Exported classes, Previous: Exported functions, Up: Exported definitions [Contents][Index]
The address the WebSockets server will run on.
remote-js.lisp (file)
Whether or not the client is connected.
remote-js.lisp (file)
The port the WebSockets server will run on.
remote-js.lisp (file)
Whether the server is running.
remote-js.lisp (file)
The trivial-websockets server.
remote-js.lisp (file)
Send some JavaScript to evaluate remotely. Return the string.
remote-js.lisp (file)
Send JavaScript to evaluate, if the buffer is connected. Otherwise, add the code to the buffer.
If there’s anything in the buffer and the client is connected, send it all in
order before evaluating the string.
Return the HTML for this context.
remote-js.lisp (file)
Return the JS for this context.
remote-js.lisp (file)
Start the WebSockets server.
remote-js.lisp (file)
Stop the WebSockets server.
remote-js.lisp (file)
Previous: Exported generic functions, Up: Exported definitions [Contents][Index]
The buffered context stores evaluation commands in a buffer until a client connects, then sends all of them at once.
remote-js.lisp (file)
context (class)
Whether or not the client is connected.
context-connected-p (generic function)
(setf context-connected-p) (generic function)
A list of JavaScript strings to evaluate.
list
:buffer
context-buffer (generic function)
(setf context-buffer) (generic function)
A context object.
remote-js.lisp (file)
standard-object (class)
buffered-context (class)
The address the WebSockets server will run on.
string
:address
trivial-ws:+default-address+
context-address (generic function)
The port the WebSockets server will run on.
integer
:port
(find-port:find-port)
context-port (generic function)
The number of seconds after which the WebSockets server will disconnect an inactive client.
integer
:timeout
trivial-ws:+default-timeout+
context-timeout (generic function)
The trivial-websockets server.
:server
context-server (generic function)
(setf context-server) (generic function)
The server handler.
:handler
context-handler (generic function)
(setf context-handler) (generic function)
Whether the server is running.
context-running-p (generic function)
(setf context-running-p) (generic function)
Whether or not to record sent HTML.
boolean
:recordp
context-record-p (generic function)
(setf context-record-p) (generic function)
The function that is called when the client sends a message.
:callback
remote-js::+default-callback+
context-callback (generic function)
(setf context-callback) (generic function)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables | ||
• Internal functions | ||
• Internal generic functions |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
remote-js.lisp (file)
remote-js.lisp (file)
Next: Internal generic functions, Previous: Internal special variables, Up: Internal definitions [Contents][Index]
remote-js.lisp (file)
Previous: Internal functions, Up: Internal definitions [Contents][Index]
A list of JavaScript strings to evaluate.
remote-js.lisp (file)
The function that is called when the client sends a message.
remote-js.lisp (file)
The server handler.
remote-js.lisp (file)
Whether or not to record sent HTML.
remote-js.lisp (file)
The number of seconds after which the WebSockets server will disconnect an inactive client.
remote-js.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F L M R |
---|
Jump to: | F L M R |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | (
C E F G H J M S |
---|
Jump to: | (
C E F G H J M S |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | %
+
A B C H P R S T |
---|
Jump to: | %
+
A B C H P R S T |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | B C P R S |
---|
Jump to: | B C P R S |
---|