send one message
This commit is contained in:
parent
3a8dcf0619
commit
e38836527f
5 changed files with 184 additions and 0 deletions
36
modules/action/action.cpp
Normal file
36
modules/action/action.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
Action
|
||||
|
||||
Copyright (C) 2019 AleaJactaEst
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#include "action.h"
|
||||
|
||||
void Action::_bind_methods()
|
||||
{
|
||||
BIND_ENUM_CONSTANT(ACTION_POSITION_CODE);
|
||||
BIND_ENUM_CONSTANT(ACTION_GENERIC_CODE);
|
||||
BIND_ENUM_CONSTANT(ACTION_GENERIC_MULTI_PART_CODE);
|
||||
BIND_ENUM_CONSTANT(ACTION_SINT64);
|
||||
BIND_ENUM_CONSTANT(ACTION_SYNC_CODE);
|
||||
BIND_ENUM_CONSTANT(ACTION_DISCONNECTION_CODE);
|
||||
BIND_ENUM_CONSTANT(ACTION_ASSOCIATION_CODE);
|
||||
BIND_ENUM_CONSTANT(ACTION_LOGIN_CODE);
|
||||
BIND_ENUM_CONSTANT(ACTION_TARGET_SLOT_CODE);
|
||||
BIND_ENUM_CONSTANT(ACTION_DUMMY_CODE);
|
||||
BIND_ENUM_CONSTANT(ACTION_NONE);
|
||||
}
|
49
modules/action/action.h
Normal file
49
modules/action/action.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
Header Action
|
||||
|
||||
Copyright (C) 2019 AleaJactaEst
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#include "core/object.h"
|
||||
|
||||
#ifndef ACTION_H
|
||||
#define ACTION_H
|
||||
|
||||
class Action : public Object
|
||||
{
|
||||
GDCLASS(Action, Object)
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
public:
|
||||
enum CODE {
|
||||
ACTION_POSITION_CODE = 0,
|
||||
ACTION_GENERIC_CODE = 1,
|
||||
ACTION_GENERIC_MULTI_PART_CODE = 2,
|
||||
ACTION_SINT64 = 3,
|
||||
ACTION_SYNC_CODE = 10,
|
||||
ACTION_DISCONNECTION_CODE = 11,
|
||||
ACTION_ASSOCIATION_CODE = 12,
|
||||
ACTION_LOGIN_CODE = 13,
|
||||
ACTION_TARGET_SLOT_CODE = 40,
|
||||
ACTION_DUMMY_CODE = 99,
|
||||
ACTION_NONE = 999
|
||||
};
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(Action::CODE);
|
||||
|
||||
#endif
|
55
modules/action/action_genericmultipart.cpp
Normal file
55
modules/action/action_genericmultipart.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
Action Generic Multi Part
|
||||
|
||||
Copyright (C) 2019 AleaJactaEst
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#include "action_genericmultipart.h"
|
||||
#include "modules/debug/debug.h"
|
||||
|
||||
void GenericMultiPart::add(uint16_t Part, PoolByteArray PartCont)
|
||||
{
|
||||
if (this->_block.has(Part))
|
||||
{
|
||||
this->_block[Part] = PartCont;
|
||||
return;
|
||||
}
|
||||
this->_block[Part] = PartCont;
|
||||
}
|
||||
|
||||
bool GenericMultiPart::is_complete()
|
||||
{
|
||||
if ( this->_block.size() != this->_size )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
PoolByteArray GenericMultiPart::get_message()
|
||||
{
|
||||
DBG_PRINT("get message " + itos(this->_id));
|
||||
#ifdef DEBUG_ENABLED
|
||||
if ( is_complete() == false )
|
||||
{
|
||||
ERR_PRINT("Missing some block id:" + itos(this->_id) + " " + itos(this->_block.size()) + "/" + itos(this->_size));
|
||||
}
|
||||
#endif
|
||||
int i;
|
||||
PoolByteArray out;
|
||||
for(i = 0; i < this->_size ; ++i)
|
||||
out.append(this->_block[i]);
|
||||
return out;
|
||||
}
|
44
modules/action/action_genericmultipart.h
Normal file
44
modules/action/action_genericmultipart.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
Action Generic Multi Part
|
||||
|
||||
Copyright (C) 2019 AleaJactaEst
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef ACTION_GENERIC_MULTI_PART_H
|
||||
#define ACTION_GENERIC_MULTI_PART_H
|
||||
|
||||
#include "core/object.h"
|
||||
// #include "core/array.h"
|
||||
#include "core/dictionary.h"
|
||||
#include "modules/networkconnection/network_data.h"
|
||||
|
||||
class GenericMultiPart
|
||||
{
|
||||
uint8_t _id;
|
||||
uint16_t _size;
|
||||
Dictionary _block;
|
||||
public:
|
||||
GenericMultiPart(uint8_t Number, uint16_t NbBlock) {_id = Number; _size = NbBlock;}
|
||||
~GenericMultiPart() {}
|
||||
|
||||
void add(uint16_t Part, PoolByteArray PartCont);
|
||||
bool is_complete();
|
||||
|
||||
PoolByteArray get_message();
|
||||
};
|
||||
|
||||
#endif
|
0
modules/impulse/impulse_phrase_send.cpp
Normal file
0
modules/impulse/impulse_phrase_send.cpp
Normal file
Loading…
Reference in a new issue