@@ -21,32 +21,30 @@ class ActorSystem {
21
21
ActorSystem . actor = null ;
22
22
ActorSystem . instance = null ;
23
23
24
- if ( process . channel ) {
25
- process . on ( 'message' , message => {
26
- const { command } = message ;
27
- if ( command === 'start' ) {
28
- const { name } = message ;
29
- require ( `./actors/${ name . toLowerCase ( ) } .js` ) ;
30
- const ActorClass = ActorSystem . actor ;
31
- ActorSystem . instance = new ActorClass ( ) ;
32
- return ;
33
- }
34
- if ( command === 'stop' ) {
35
- const { instance } = ActorSystem ;
36
- if ( instance ) instance . exit ( ) ;
37
- return ;
38
- }
39
- if ( command === 'message' ) {
40
- const { instance } = ActorSystem ;
41
- if ( instance ) {
42
- const { data } = message ;
43
- const { name } = ActorSystem . actor ;
44
- instance . message ( data ) . then ( ( ) => {
45
- process . send ( { command : 'ready' , name, pid : process . pid } ) ;
46
- } ) ;
47
- }
24
+ process . on ( 'message' , message => {
25
+ const { command } = message ;
26
+ if ( command === 'start' ) {
27
+ const { name } = message ;
28
+ require ( `./actors/${ name . toLowerCase ( ) } .js` ) ;
29
+ const ActorClass = ActorSystem . actor ;
30
+ ActorSystem . instance = new ActorClass ( ) ;
31
+ return ;
32
+ }
33
+ if ( command === 'stop' ) {
34
+ const { instance } = ActorSystem ;
35
+ if ( instance ) instance . exit ( ) ;
36
+ return ;
37
+ }
38
+ if ( command === 'message' ) {
39
+ const { instance } = ActorSystem ;
40
+ if ( instance ) {
41
+ const { data } = message ;
42
+ const { name } = ActorSystem . actor ;
43
+ instance . message ( data ) . then ( ( ) => {
44
+ process . send ( { command : 'ready' , name, pid : process . pid } ) ;
45
+ } ) ;
48
46
}
49
- } ) ;
50
- }
47
+ }
48
+ } ) ;
51
49
52
50
module . exports = ActorSystem ;
0 commit comments