'Perl'에 해당되는 글 1

  1. 2013.04.20 [Perl Advent Calendar] Mojolicious, HTML5, WebSocket을 이용한 비동기 채팅

[Perl Advent Calendar] Mojolicious, HTML5, WebSocket을 이용한 비동기 채팅

- 2011 스무번째 날: Mojolicious, HTML5, WebSocket을 이용한 비동기 채팅

- Mojolicious 설치
> cpan Mojolicious
> mojo generate app Chat //
> tree
> morbo chat/script/chat
http://127.0.0.1:3000/

- lib/Chat.pm에 라우팅 추가

- lib/Chat/ChatControl.pm 작성
- View 작성
templates/ChatControl/chatAction.html.ep
templates/layouts/chatLayout.html.ep

- 그런데 서버가 응답을 주지 않는다.
Control까지는 진행되는데 View를 찾지 못한다.
한참동안 이것저것 해보다 log 디렉토리가 있다는 것을 보고 로그를 확인해 봤다.
[Sat Apr 20 15:24:43 2013] [debug] Routing to controller "Chat::ChatControl" and action "chatAction".
[Sat Apr 20 15:24:43 2013] [debug] Template "chat_control/chatAction.html.ep" not found.
[Sat Apr 20 15:24:43 2013] [debug] Template "chat_control/chatAction.html.ep" not found.
[Sat Apr 20 15:24:43 2013] [debug] Nothing has been rendered, expecting delayed response.
[Sat Apr 20 15:24:47 2013] [debug] Inactivity timeout.
(진작 로그를 확인했어야 한다.)

- [수정] chatAction.html.eptemplates/chat_control/에 만든다.

- 페이지는 보이는데 제대로 기능이 동작하지 않는다.
[Sat Apr 20 18:44:35 2013] [debug] Routing to controller "Chat::Control" and action "wsAction".
[Sat Apr 20 18:44:35 2013] [error] Can't locate object method "send_message" via package "Mojo::Transaction::WebSocket" at D:/resources/reps/perl_workspace/chat/script/../lib/Chat/Control.pm line 20.

[Sat Apr 20 18:44:35 2013] [debug] Template "exception.development.html.ep" not found.
[Sat Apr 20 18:44:35 2013] [debug] Template "exception.html.ep" not found.
[Sat Apr 20 18:44:35 2013] [debug] Rendering inline template.
[Sat Apr 20 18:44:35 2013] [debug] Rendering inline template.
[Sat Apr 20 18:44:35 2013] [debug] 500 Internal Server Error (0.032355s, 30.907/s).

send_message 메서드가 없다고?
찾아보니 send 라는 메서드가 있다. 수정!

자알 된다.