Subversion Repositories HomeAutomation

Rev

Rev 974 | Rev 1080 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 974 Rev 1035
Line 296... Line 296...
296
            } else {
296
            } else {
297
                $tcpSsocket->recv($line,$linelength);
297
                $tcpSsocket->recv($line,$linelength);
298
                if ($line eq "") {
298
                if ($line eq "") {
299
                    &tcpServerClientDis;
299
                    &tcpServerClientDis;
300
                } else {
300
                } else {
301
                    $line =~ s/\n.*//gm;    #remove newline and everything after it
301
                    $line =~ s/\r//gm;  #remove linefeed
302
                    $line =~ s/\r.*//gm;    #remove linefeed and everything after it
302
                    @lines = split(/\n/, $line);
-
 
303
                    foreach $line (@lines) {
303
                    print "Got packet '".$line."' from client ".$tcpSsocket->fileno."\n";
304
                        print "Got packet '".$line."' from client ".$tcpSsocket->fileno."\n";
304
                   
-
 
305
                    if ($line eq "PING") {
305
                        if ($line eq "PING") {
306
                        print "Sending PONG to client ".$tcpSsocket->fileno."\n";
306
                            print "Sending PONG to client ".$tcpSsocket->fileno."\n";
307
                       
307
                       
308
                        $tcpSsocket->send("PONG\n");
308
                            $tcpSsocket->send("PONG\n");
309
                    }
309
                        }
310
                    else
310
                        else
311
                    {
311
                        {
312
                        $rxerror = 0;
312
                            $rxerror = 0;
313
                        testPacket($line, 0, $rxerror);
313
                            testPacket($line, 0, $rxerror);
314
                       
314
                       
315
                        if ($rxerror == 0) {
315
                            if ($rxerror == 0) {
316
                            #Add newline to each packet
316
                                #Add newline to each packet
317
                            $line .= "\n";
317
                                $line .= "\n";
318
                                               
318
                                               
319
                            &tcpServerBroadcastExcept($line, $tcpSsocket);
319
                                &tcpServerBroadcastExcept($line, $tcpSsocket);
-
 
320
                            }
320
                        }
321
                        }
321
                    }
322
                    }
322
                }
323
                }
323
            }
324
            }
324
        }
325
        }