@@ -7,31 +7,11 @@ export const use_cloud_store = defineStore('cloud', {
77 is_connexion_launched : false ,
88 } ) ,
99 getters : {
10- geode_url : ( state ) => {
11- const public_runtime_config = useRuntimeConfig ( ) . public
12- var geode_url = `${ public_runtime_config . GEODE_PROTOCOL } ://${ public_runtime_config . API_URL } :${ public_runtime_config . GEODE_PORT } `
13- if ( process . env . NODE_ENV == 'production' ) {
14- geode_url = geode_url + `/${ state . ID } /geode`
15- }
16- return geode_url
17- } ,
18- viewer_url : ( state ) => {
19- const public_runtime_config = useRuntimeConfig ( ) . public
20- var viewer_url = `${ public_runtime_config . VIEWER_PROTOCOL } ://${ public_runtime_config . API_URL } :${ public_runtime_config . VIEWER_PORT } `
21- if ( process . env . NODE_ENV == 'production' ) {
22- viewer_url = viewer_url + `/${ state . ID } /viewer`
23- }
24- viewer_url = viewer_url + '/ws'
25- return viewer_url
26- } ,
27- is_cloud_running : ( ) => {
28- return use_geode_store ( ) . is_client_created && use_websocket_store ( ) . is_client_created
10+ is_running : ( ) => {
11+ return use_geode_store ( ) . is_running && use_websocket_store ( ) . is_running
2912 } ,
30- cloud_busy : ( ) => {
31- const api_busy = use_geode_store ( ) . api_busy
32- const websocket_busy = use_geode_store ( ) . websocket_busy
33- const cloud_busy = api_busy || websocket_busy
34- return cloud_busy
13+ is_busy : ( ) => {
14+ return use_geode_store ( ) . is_busy || use_websocket_store ( ) . is_busy
3515 }
3616
3717 } ,
@@ -46,8 +26,8 @@ export const use_cloud_store = defineStore('cloud', {
4626 const { data, error } = await useFetch ( `${ this . geode_url } /ping` , { method : 'POST' } )
4727 console . log ( "error" , error )
4828 if ( data . value !== null ) {
49- geode_store . is_client_created = true
50- return this . ping_task ( )
29+ geode_store . is_running = true
30+ return geode_store . ping_task ( )
5131 } else {
5232 return this . create_backend ( )
5333 }
@@ -62,27 +42,12 @@ export const use_cloud_store = defineStore('cloud', {
6242 if ( data . value !== null ) {
6343 this . ID = data . value . ID
6444 localStorage . setItem ( 'ID' , data . value . ID )
65- geode_store . is_client_created = true
66- return this . ping_task ( )
45+ geode_store . is_running = true
46+ return geode_store . ping_task ( )
6747 } else {
6848 console . log ( "error : " , error )
6949 errors_store . server_error = true
7050 }
7151 } ,
72-
73- ping_task ( ) {
74- setInterval ( ( ) => this . do_ping ( ) , 10 * 1000 )
75- } ,
76- async do_ping ( ) {
77- const geode_store = use_geode_store ( )
78- const errors_store = use_errors_store ( )
79- const { data, error } = await useFetch ( `${ this . geode_url } /ping` , { method : 'POST' } )
80- if ( data . value !== null ) {
81- geode_store . is_client_created = true
82- } else {
83- errors_store . server_error = true
84- console . log ( "error : " , error )
85- }
86- }
8752 }
8853} )
0 commit comments