Changeset 40024 in project


Ignore:
Timestamp:
04/17/21 15:27:37 (4 weeks ago)
Author:
rgherdt
Message:

Add example.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/json-rpc

    r40023 r40024  
    5656JSON-RPC 2.0 demands that all requests are answered. This functions loops over {{input-port}} and answers to the requests through {{output-port}} using the handlers defined in {{json-rpc-handler-table}}.
    5757
    58 === Changelog
     58=== Examples
    5959
    60 * 0.0.1 Initial version.
     60<enscript highlight=scheme>
     61 ;; server.scm
     62 (import (json-rpc))
     63 (parameterize
     64   ((json-rpc-handler-table
     65      `(("hello" . ,(lambda (params)
     66                      (let ((name (cdr (assoc 'name params))))
     67                        (string-append "Hello " name))))
     68        ("exit" . ,(lambda (params)
     69                     (json-rpc-exit)
     70                     #f)))))
     71  (json-rpc-start-server/tcp 4242))
     72</enscript>
    6173
    62 === LICENSE
     74<enscript highlight=scheme>
     75 ;; client.scm
     76 (import (json-rpc))
     77 (json-rpc-call/tcp "localhost" 4242 "hello" '((name . "World!")))
     78</enscript>
     79
     80=== License
    6381
    6482MIT License
     
    83101FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    84102DEALINGS IN THE SOFTWARE.
     103
     104=== Version History
     105
     106* 0.0.1 Initial version.
     107
Note: See TracChangeset for help on using the changeset viewer.