Mercurial > hg > RemoteEditor > emacs
changeset 46:991526bc3f16
*** empty log message ***
author | gongo |
---|---|
date | Sat, 23 Aug 2008 17:42:25 +0900 |
parents | 653a9b9b7775 |
children | 1d131b6064ae |
files | ChangeLog redit-client-sm.el test/packet/redit-test-packet-send.pl |
diffstat | 3 files changed, 88 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sat Aug 23 17:09:19 2008 +0900 +++ b/ChangeLog Sat Aug 23 17:42:25 2008 +0900 @@ -1,3 +1,16 @@ +2008-08-23 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * redit-client-sm.el (redit-client-process-filter): + process-filter で受け取る文字列に + 複数の REP command が連結された状態になってて + それをどうやって読んでいくかっていうのを追加。多分動いてる。 + + 詳しい変更は test/packet を見ればわかると思う。多分。 + + test 書いてて思ったけど、やっぱり pack/unpack とか + そういうのは redit-client-sm.el に置くんじゃなくて + redit-util.el とかに置いた方が test でも使いやすい気がする。知らんけど + 2008-08-19 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> * thinking: buffer と session の関連性
--- a/redit-client-sm.el Sat Aug 23 17:09:19 2008 +0900 +++ b/redit-client-sm.el Sat Aug 23 17:42:25 2008 +0900 @@ -59,12 +59,18 @@ (defvar redit-max-string-length 1004 "Read-Write max length of string.") +(defvar redit-process-filter-resume nil + "String of the unprocessing in redit-client-process-filter") + ;; REP が使用する文字コード (defconst rep-string-encoding 'utf-8) ;; port (defconst redit-process-port 8766) +;; REP command header size +(defconst redit-command-header-size 24) + (defconst redit-open-command 1) (defconst redit-open-ack 2) (defconst redit-read-command 3) @@ -184,22 +190,6 @@ (defun redit-get-session-info-from-sid-table (sid) (gethash sid sid-to-session-table)) -(defun gongo-start () - (interactive) - (add-hook 'before-change-functions - 'redit-client-before-change-function t t) - (add-hook 'after-change-functions - 'redit-client-after-change-function t t) -) - -(defun gongo-stop () - (interactive) - (remove-hook 'before-change-functions - 'redit-client-before-change-function t) - (remove-hook 'after-change-functions - 'redit-client-after-change-function t) -) - ;;;;;;;;;;;;;;;;;;; ;; pack / unpack ;; @@ -450,50 +440,79 @@ (remove-hook 'after-change-functions 'redit-client-after-change-function t) - (message (concat "redit-client-process-filter: " string)) - (let ((command (rep-get-command-from-pkt string))) - ;; command がどの命令かを判断し、対応した処理をする。case みたい - (cond - ;; FIXME - ;;((if (= command redit-open-ack) - ;;(if (/= redit-client-editor-id (rep-get-editor-id-from-pkt string)) - ;;(redit-client-exec-open-ack string)))) + (message (format "redit-client-process-filter: %s" string)) + + (let (command textsize text allsize cursize) + ;; 前回に余った奴があれば、それを前方追加する + (setq string (concat redit-process-filter-resume string)) + (setq allsize (length string)) + + (block loop + ;; process-filter が受け取れるのは1024byteまで。 + ;; なので、string に入っているパケットが途中で切れてる可能性がある + (while (> allsize redit-command-header-size) + (setq command (rep-get-command-from-pkt string)) + (setq textsize (rep-get-text-size-from-pkt string)) + + ;; ヘッダ (redit-command-header-size) + テキストサイズ + (setq cursize (+ redit-command-header-size textsize)) - ((if (= command redit-read-ack) - (if (= redit-client-editor-id (rep-get-editor-id-from-pkt string)) - (redit-client-exec-read-ack string)))) + ;; パケットが 1024 byte の壁で途切れてる場合、 + ;; テキストが読めないので、ループを抜ける + (if (> cursize allsize) (return-from loop)) - ((if (= command redit-insert-ack) - (if (= redit-client-editor-id (rep-get-editor-id-from-pkt string)) - (redit-client-exec-insert-ack string)))) - - ((if (= command redit-delete-line-ack) - (if (= redit-client-editor-id (rep-get-editor-id-from-pkt string)) - (redit-client-exec-delete-line-ack string)))) + (let ((command (rep-get-command-from-pkt string))) + ;; command がどの命令かを判断し、対応した処理をする。case みたい + (cond + ;; FIXME + ;;((if (= command redit-open-ack) + ;;(if (/= redit-client-editor-id (rep-get-editor-id-from-pkt string)) + ;;(redit-client-exec-open-ack string)))) - ((if (= command redit-close-ack) - (if (= redit-client-editor-id (rep-get-editor-id-from-pkt string)) - (redit-client-exec-close-ack string)))) - - ((if (= command redit-insert-command) - (if (/= redit-client-editor-id (rep-get-editor-id-from-pkt string)) - (redit-client-exec-insert-line string)))) + ((if (= command redit-read-ack) + (if (= redit-client-editor-id (rep-get-editor-id-from-pkt string)) + (redit-client-exec-read-ack string)))) + + ((if (= command redit-insert-ack) + (if (= redit-client-editor-id (rep-get-editor-id-from-pkt string)) + (redit-client-exec-insert-ack string)))) + + ((if (= command redit-delete-line-ack) + (if (= redit-client-editor-id (rep-get-editor-id-from-pkt string)) + (redit-client-exec-delete-line-ack string)))) + + ((if (= command redit-close-ack) + (if (= redit-client-editor-id (rep-get-editor-id-from-pkt string)) + (redit-client-exec-close-ack string)))) + + ((if (= command redit-insert-command) + (if (/= redit-client-editor-id (rep-get-editor-id-from-pkt string)) + (redit-client-exec-insert-line string)))) + + ;; from Session Manager + ;; join ack (editor id) + ((if (= command redit-join-ack-command) + (redit-client-exec-join string))) + + ;; put ack (editor id) + ((if (= command redit-put-ack-command) + (redit-client-exec-put string))) - ;; from Session Manager - ;; join ack (editor id) - ((if (= command redit-join-ack-command) - (redit-client-exec-join string))) + ;; delete line + ((if (= command redit-delete-line-command) + (if (/= redit-client-editor-id (rep-get-editor-id-from-pkt string)) + (redit-client-exec-delete-line string)))) + ) - ;; put ack (editor id) - ((if (= command redit-put-ack-command) - (redit-client-exec-put string))) - - ;; delete line - ((if (= command redit-delete-line-command) - (if (/= redit-client-editor-id (rep-get-editor-id-from-pkt string)) - (redit-client-exec-delete-line string)))) - )) - + (setq allsize (- allsize cursize)) + ;; string の分割 + (setq string (substring string cursize)))))) + + ;; 途切れたやつは次の process-filter の string に入っているので + ;; この時点で余った奴を保存し、 + ;; 次の process-filter の string の前に連結する + (setq redit-process-filter-resume string) + (add-hook 'before-change-functions 'redit-client-before-change-function t t) (add-hook 'after-change-functions
--- a/test/packet/redit-test-packet-send.pl Sat Aug 23 17:09:19 2008 +0900 +++ b/test/packet/redit-test-packet-send.pl Sat Aug 23 17:42:25 2008 +0900 @@ -7,7 +7,7 @@ my $selector = new IO::Select(\*STDIN) or die "Cannot select stdin : $!\n"; # パケット送信する回数 -my $send_count = 320; +my $send_count = 10000; # パケット送信の間隔(秒) my $send_interval = 0;