Advertisement
Guest User

Untitled

a guest
May 4th, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.23 KB | None | 0 0
  1.  
  2.  
  3. package Local;
  4.  
  5. use DXVars;
  6. use DXDebug;
  7. use DXUtil;
  8. use Redis;
  9. use JSON;
  10.  
  11. # DON'T REMOVE THIS LINE
  12. use strict;
  13.  
  14. # declare any global variables you use in here
  15. use vars qw{$redis};
  16.  
  17. # called at initialisation time
  18. sub init
  19. {
  20.     $redis = Redis->new(server => '127.0.0.1:6379', reconnect => 60);
  21.     #$redis->incr("tobi");
  22. }
  23.  
  24.  
  25.  
  26. # called after the spot has been stored but before it is broadcast,
  27. # you can do funky routing here that is non-standard. 0 carries on
  28. # after this, 1 stops dead and no routing is done (this could mean
  29. # that YOU have done some routing or other instead
  30. #
  31. # Parameters:-
  32. # $self      - the DXChannel object
  33. # $freq      - frequency
  34. # $spotted   - the spotted callsign
  35. # $d         - the date in unix time format
  36. # $text      - the text of the spot
  37. # $spotter   - who spotted it
  38. # $orignode  - the originating node
  39. #
  40. sub spot
  41. {
  42.         my ($self, $freq, $spotted, $d, $text, $spotter, $orignode) = @_;
  43.  
  44.         my %redis_spot = ('spotter'=>$spotter, 'dx'=>$spotted, 'frequency'=>$freq, 'timestamp'=>$d,
  45.                          'comment'=>$text, 'orignode'=>$orignode);
  46.  
  47.         my $json = encode_json \%redis_spot;
  48.  
  49.         $redis->publish("dxspider_spot", $json);
  50.         return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement