]> code.delx.au - gnu-emacs-elpa/blob - chess-transport.el
Proper file header.
[gnu-emacs-elpa] / chess-transport.el
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;;
3 ;; An example of a generic transport engine, based on the protocol
4 ;; used by chess-network.el. The only parts missing are send and
5 ;; receive. This could be used for transmitting chess.el protocol
6 ;; over CTCP, for example.
7 ;;
8
9 (require 'chess-network)
10
11 (defvar chess-transport-regexp-alist chess-network-regexp-alist)
12
13 (defun chess-transport-handler (game event &rest args)
14 "This is an example of a generic transport engine."
15 (unless chess-engine-handling-event
16 (cond
17 ((eq event 'initialize)
18 ;; Initialize the transport here, if necessary. Make sure that
19 ;; any housekeeping data you use is kept in buffer-local
20 ;; variables. Otherwise, multiple games played using the same
21 ;; kind of transport might collide. For example:
22 ;;
23 ;; (set (make-local-variable 'chess-transport-data) (car args))
24 ;;
25 ;; NOTE: Be sure not to return a process, or else chess-engine
26 ;; will do all the transport work!
27 t)
28
29 ((eq event 'send)
30 ;; Transmit the string given in `(car args)' to the outbound
31 ;; transport from here
32 )
33
34 (t
35 ;; Pass all other events down to chess-network
36 (apply 'chess-network-handler game event args)))))
37
38 ;; Call `(chess-engine-submit engine STRING)' for text that arrives
39 ;; from the inbound transport
40
41 (provide 'chess-transport)
42
43 ;;; chess-transport.el ends here