MessageParser.pm.svn-base
上传用户:market2
上传日期:2018-11-18
资源大小:18786k
文件大小:0k
源码类别:
外挂编程
开发平台:
Windows_Unix
- package Bus::MessageParser;
- use strict;
- use bytes;
- no encoding 'utf8';
- use Bus::Messages qw(unserialize);
- sub new {
- my ($class) = @_;
- my %self = (buffer => '');
- return bless %self, $class;
- }
- sub add {
- my $self = $_[0];
- $self->{buffer} .= $_[1];
- }
- sub readNext {
- my ($self, $ID) = @_;
- my $processed;
- my $args = unserialize($self->{buffer}, $ID, $processed);
- if ($args) {
- substr($self->{buffer}, 0, $processed, '');
- }
- return $args;
- }
- 1;