@@ -2,22 +2,23 @@ import {DeviceEventEmitter} from 'react-native';
22
33export class Queue {
44
5- constructor ( connection , queue_condig , args ) {
5+ constructor ( connection , queue_config , args ) {
66
77 this . callbacks = { } ;
88 this . rabbitmqconnection = connection . rabbitmqconnection ;
99
10- this . name = queue_condig . name ;
11- this . queue_condig = queue_condig ;
10+ this . name = queue_config . name ;
11+ this . queue_config = queue_config ;
1212 this . arguments = args || { } ;
1313
1414 this . message_buffer = [ ] ;
15- this . message_buffer_delay = ( queue_condig . buffer_delay ? queue_condig . buffer_delay : 1000 ) ;
15+ this . message_buffer_delay = ( queue_config . buffer_delay ? queue_config . buffer_delay : 1000 ) ;
1616 this . message_buffer_timeout = null ;
17-
17+
1818 DeviceEventEmitter . addListener ( 'RabbitMqQueueEvent' , this . handleEvent ) ;
19-
19+
2020 this . rabbitmqconnection . addQueue ( queue_condig , this . arguments ) ;
21+
2122 }
2223
2324 handleEvent = ( event ) => {
@@ -41,7 +42,7 @@ export class Queue {
4142 clearTimeout ( this . message_buffer_timeout ) ;
4243
4344 this . message_buffer_timeout = setTimeout ( ( ) => {
44-
45+
4546 if ( this . message_buffer . length > 0 ) {
4647 if ( this . callbacks . hasOwnProperty ( 'messages' ) ) {
4748 this . callbacks [ 'messages' ] ( this . message_buffer ) ;
@@ -60,26 +61,26 @@ export class Queue {
6061
6162 on ( event , callback ) {
6263 this . callbacks [ event ] = callback ;
63- }
64+ }
6465
6566 removeon ( event ) {
6667 delete this . callbacks [ event ] ;
67- }
68+ }
6869
6970 bind ( exchange , routing_key = '' ) {
70- this . rabbitmqconnection . bindQueue ( exchange . name , this . name , routing_key ) ;
71+ this . rabbitmqconnection . bindQueue ( exchange . name , this . name , routing_key ) ;
7172 }
7273
7374 unbind ( exchange , routing_key = '' ) {
74- this . rabbitmqconnection . unbindQueue ( exchange . name , this . name , routing_key ) ;
75+ this . rabbitmqconnection . unbindQueue ( exchange . name , this . name , routing_key ) ;
7576 }
7677
7778 delete ( ) {
7879 if ( this . name != '' ) {
79- this . rabbitmqconnection . removeQueue ( this . name ) ;
80- }
80+ this . rabbitmqconnection . removeQueue ( this . name ) ;
81+ }
8182 }
82-
83+
8384 close ( ) {
8485 DeviceEventEmitter . removeListener ( 'RabbitMqQueueEvent' , this . handleEvent ) ;
8586 clearTimeout ( this . message_buffer_timeout ) ;
@@ -89,9 +90,9 @@ export class Queue {
8990 basicAck ( delivery_tag ) {
9091
9192 this . rabbitmqconnection . basicAck ( this . name , delivery_tag ) ;
92-
93+
9394 }
9495
9596}
9697
97- export default Queue ;
98+ export default Queue ;
0 commit comments