Changeset 199
- Timestamp:
- 04/24/07 22:15:07 (18 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/package.lisp ¶
r193 r199 142 142 ;; DCC specific dictionary 143 143 :dcc-connection 144 :dcc-chat-connection 144 145 :irc-connection 145 146 :close-on-main 146 147 :remote-user 147 148 :dcc-close 149 :make-dcc-chat-connection 148 150 ))) 149 151 -
TabularUnified trunk/protocol.lisp ¶
r197 r199 336 336 #+armedbear (ext:destroy-thread process)) 337 337 338 (defun read-message-loop (connection) 338 (defgeneric read-message-loop (connection)) 339 (defmethod read-message-loop (connection) 339 340 (loop while (read-message connection))) 340 341 … … 361 362 raw-message)) 362 363 363 (defmethod get-hooks ((connection connection) (class symbol)) 364 ;;applies to both irc and dcc-connections 365 (defmethod get-hooks (connection (class symbol)) 364 366 "Return a list of all hooks for `class'." 365 367 (gethash class (hooks connection))) 366 368 367 (defmethod add-hook ((connection connection) class hook) 369 ;;applies to both irc and dcc-connections 370 (defmethod add-hook (connection class hook) 368 371 "Add `hook' to `class'." 369 372 (setf (gethash class (hooks connection)) … … 480 483 ;; CHAT related generic functions 481 484 (defgeneric send-dcc-message (connection message)) 485 ;;already defined in relation to `connection' 486 ;; (defgeneric read-message (connection)) 487 ;;(defgeneric dcc-message-event (message)) <defined in event.lisp> 482 488 483 489 ;; SEND related generic functions … … 487 493 (and (streamp stream) 488 494 (open-stream-p stream)))) 495 496 (defmethod send-dcc-message ((connection dcc-connection) message) 497 (format (output-stream connection) "~A~%" message) 498 (force-output (network-stream connection))) 489 499 490 500 (defmethod dcc-close ((connection dcc-connection)) … … 498 508 (dcc-connections (irc-connection connection)) 499 509 (remove connection (dcc-connections (irc-connection connection))))) 510 511 512 (defclass dcc-chat-connection (dcc-connection) 513 ((output-stream 514 :initarg :output-stream 515 :initform nil 516 :accessor output-stream 517 :documentation "Stream used to communicate with the other end 518 of the network pipe.") 519 (hooks 520 :initform (make-hash-table :test #'equal) 521 :accessor hooks)) 522 (:documentation "")) 523 524 525 (defun make-dcc-chat-connection (&key (remote-user nil) 526 ;; (remote-address nil) 527 ;; (remote-port nil) 528 (client-stream nil) 529 (irc-connection nil) 530 (close-on-main t) 531 (socket nil) 532 (network-stream nil) 533 (outgoing-external-format *default-outgoing-external-format*) 534 (hooks nil)) 535 (let* ((output-stream (flexi-streams:make-flexi-stream 536 network-stream 537 :element-type 'character 538 :external-format (external-format-fixup 539 outgoing-external-format))) 540 (connection (make-instance 'dcc-chat-connection 541 :remote-user remote-user 542 :client-stream client-stream 543 :output-stream output-stream 544 :irc-connection irc-connection 545 :close-on-main close-on-main 546 :socket socket 547 :network-stream network-stream))) 548 (dolist (hook hooks) 549 (add-hook connection (car hook) (cdar hook))) 550 connection)) 551 552 (defmethod read-message ((connection dcc-chat-connection)) 553 (when (connectedp connection) 554 (let* ((msg-string (read-protocol-line connection)) 555 (message (create-dcc-message msg-string))) 556 (setf (connection message) connection) 557 (when *debug-p* 558 (format *debug-stream* "~A" (describe message)) 559 (force-output *debug-stream*)) 560 (dcc-message-event connection message) 561 message))) ; needed because of the "loop while" in read-message-loop 562 563 (defmethod read-message-loop ((connection dcc-chat-connection)) 564 ;; no special setup 565 (call-next-method) 566 ;; now, make sure the connection was closed and cleaned up properly... 567 ;; it *was* the last message, after all... 568 ;;##TODO, maybe we need some kind of 'auto-clean' slot to indicate 569 ;; this is the desired behaviour? 570 ) 571 500 572 501 573 ;; … … 969 1041 (force-output stream))) 970 1042 971 972 (defmethod apply-to-hooks ( (message irc-message))1043 ;; applies to both irc- and dcc-messages 1044 (defmethod apply-to-hooks (message) 973 1045 "Applies any applicable hooks to `message'. 974 1046
Note: See TracChangeset
for help on using the changeset viewer.