• R/O
  • HTTP
  • SSH
  • HTTPS

keitairc: Commit

keitaircメインレポジトリ


Commit MetaInfo

Révision702f6033e155c4e2fa8ac6772326595fb1558004 (tree)
l'heure2010-12-01 01:26:20
AuteurISHIKAWA Mutsumi <ishikawa@hanz...>
CommiterISHIKAWA Mutsumi

Message de Log

adapt POE::Filter::HTTPD::Keitairc change (websocket client message handling)

Change Summary

Modification

--- a/keitairc
+++ b/keitairc
@@ -116,24 +116,29 @@ $poe_kernel->run();
116116 exit 0;
117117
118118 ################################################################
119-sub http_request{
119+sub http_request {
120120 my ($kernel, $heap, $request) = @_[KERNEL, HEAP, ARG0];
121121
122122 # Filter::HTTPD sometimes generates HTTP::Response objects.
123123 # They indicate (and contain the response for) errors that occur
124124 # while parsing the client's HTTP request. It's easiest to send
125125 # the responses as they are and finish up.
126- if($request->isa('HTTP::Response')){
126+ my $req_type = ref($request);
127+ if($req_type eq 'HTTP::Response') {
127128 $heap->{client}->put($request);
128129 $log->log_error($request->as_string());
129- }elsif(my $response = dispatch($request, $heap)){
130+ $kernel->yield('shutdown');
131+ } elsif($req_type eq 'HTTP::Request') {
132+ my $response = dispatch($request, $heap);
130133 if ($response ne '__STREAMING__') {
131134 $heap->{client}->put($response);
132135 $log->log_access($heap->{'remote_ip'}, $request, $response);
136+ $kernel->yield('shutdown');
133137 }
138+ } else {
139+ # FIXME:: should handle websocket message
140+ warn $request;
134141 }
135-
136- $kernel->yield('shutdown');
137142 }
138143
139144 sub on_error {
@@ -141,7 +146,7 @@ sub on_error {
141146 $ib->remove_stream($_[ARG3]);
142147 }
143148 ################################################################
144-sub dispatch{
149+sub dispatch {
145150 my ($request, $heap) = @_;
146151 my $uri = $request->uri();
147152 my $ci = new Keitairc::ClientInfo($request);
@@ -174,7 +179,7 @@ sub dispatch{
174179 # plugin にすべきだけど とりあえず
175180 if($uri =~ m|^/(S[a-zA-Z]{10})/push/(.*)$|) {
176181 if (1 || $sm->verify({session_id => $1, user_agent => $ci->user_agent()})) {
177- return action_streaming($request, $2, $heap);
182+ return action_start_streaming($request, $2, $heap);
178183 } else {
179184 return action_401($request);
180185 }
@@ -432,7 +437,7 @@ sub parse_websocket_key {
432437 return $digits / $spaces;
433438 }
434439
435-sub action_streaming {
440+sub action_start_streaming {
436441 my ($request, $cid, $heap) = @_;
437442 my $ci = new Keitairc::ClientInfo($request);
438443
@@ -449,7 +454,7 @@ sub action_streaming {
449454 $heap->{client}->flush();
450455
451456 $heap->{client}->set_output_filter(POE::Filter::Stream->new());
452- $heap->{client}->set_input_filter(POE::Filter::Stream->new());
457+
453458 $ib->add_stream($cid, $heap->{client});
454459
455460 return '__STREAMING__';
Afficher sur ancien navigateur de dépôt.