Showing
4 changed files
with
42 additions
and
25 deletions
... | @@ -3,15 +3,6 @@ const search=require('./search'); | ... | @@ -3,15 +3,6 @@ const search=require('./search'); |
3 | const machineRead = require('./machineRead'); | 3 | const machineRead = require('./machineRead'); |
4 | 4 | ||
5 | 5 | ||
6 | -let timer = ( ) => { | ||
7 | - try { | ||
8 | - throw new Error( "TIMEOUT ERROR" ); | ||
9 | - } catch ( err ) { | ||
10 | - res.json( { "return_code" : -1, "error_code" : err.message } ); | ||
11 | - res.status( 504 ); //Gateway Timeout | ||
12 | - return false; | ||
13 | - } | ||
14 | -} | ||
15 | 6 | ||
16 | /** | 7 | /** |
17 | * @param req - request | 8 | * @param req - request |
... | @@ -23,7 +14,15 @@ const cliConnection = async ( req, res ) => { | ... | @@ -23,7 +14,15 @@ const cliConnection = async ( req, res ) => { |
23 | analyzeData = {}, | 14 | analyzeData = {}, |
24 | searchData = []; | 15 | searchData = []; |
25 | 16 | ||
26 | - setTimeout(timer , 10000 ); | 17 | + let timer = setTimeout( ()=>{ |
18 | + try { | ||
19 | + throw new Error( "TIMEOUT ERROR" ); | ||
20 | + } catch ( err ) { | ||
21 | + res.json( { "return_code" : -1, "error_code" : err.message } ); | ||
22 | + res.status( 504 ); //Gateway Timeout | ||
23 | + return false; | ||
24 | + } | ||
25 | + }, 10000 ); | ||
27 | 26 | ||
28 | try { | 27 | try { |
29 | clientData = req.body.data; | 28 | clientData = req.body.data; | ... | ... |
1 | { | 1 | { |
2 | "devToolsPort": 19002, | 2 | "devToolsPort": 19002, |
3 | "expoServerPort": 19000, | 3 | "expoServerPort": 19000, |
4 | - "packagerPort": null, | 4 | + "packagerPort": 19001, |
5 | - "packagerPid": null, | 5 | + "packagerPid": 30416, |
6 | "expoServerNgrokUrl": "https://ru-c66.bluejoy.searchguide.exp.direct", | 6 | "expoServerNgrokUrl": "https://ru-c66.bluejoy.searchguide.exp.direct", |
7 | "packagerNgrokUrl": "https://packager.ru-c66.bluejoy.searchguide.exp.direct", | 7 | "packagerNgrokUrl": "https://packager.ru-c66.bluejoy.searchguide.exp.direct", |
8 | - "ngrokPid": 14692 | 8 | + "ngrokPid": 9812 |
9 | } | 9 | } | ... | ... |
... | @@ -5,8 +5,9 @@ import { SERVER_URL } from 'react-native-dotenv'; | ... | @@ -5,8 +5,9 @@ import { SERVER_URL } from 'react-native-dotenv'; |
5 | export const sendSearch = async (searchText) => { | 5 | export const sendSearch = async (searchText) => { |
6 | return new Promise((resolve,reject) => { | 6 | return new Promise((resolve,reject) => { |
7 | if(searchText=== "" || searchText.length > 30 ){ | 7 | if(searchText=== "" || searchText.length > 30 ){ |
8 | - resolve({ "return_code" : -1, "error_code": "검색 단어를 확인해 주세요!" }); | 8 | + resolve({ "return_code" : -1, "error_code": "검색 단어를 입력해주세요." }); |
9 | - } else{ | 9 | + } |
10 | + else{ | ||
10 | axios( | 11 | axios( |
11 | { | 12 | { |
12 | headers: { | 13 | headers: { |
... | @@ -24,14 +25,12 @@ export const sendSearch = async (searchText) => { | ... | @@ -24,14 +25,12 @@ export const sendSearch = async (searchText) => { |
24 | ) | 25 | ) |
25 | .then((response)=>{ | 26 | .then((response)=>{ |
26 | resolve(filter(response.data)) | 27 | resolve(filter(response.data)) |
27 | - clearTimeout(timer); | 28 | + |
28 | }) | 29 | }) |
29 | .catch(error => { | 30 | .catch(error => { |
30 | - clearTimeout(timer); | 31 | + |
31 | throw new Error(error); | 32 | throw new Error(error); |
32 | }); | 33 | }); |
33 | } | 34 | } |
34 | - let timer = setTimeout( () => { | ||
35 | - throw new Error( "time out" );} ,10000) | ||
36 | }) | 35 | }) |
37 | } | 36 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -9,6 +9,7 @@ const SUCCESS = 'search/SUCCESS'; | ... | @@ -9,6 +9,7 @@ const SUCCESS = 'search/SUCCESS'; |
9 | const FAILURE = 'search/FAILURE'; | 9 | const FAILURE = 'search/FAILURE'; |
10 | const START = 'search/START'; | 10 | const START = 'search/START'; |
11 | 11 | ||
12 | + | ||
12 | export const change = (text) => ({ | 13 | export const change = (text) => ({ |
13 | type: CHANGE, | 14 | type: CHANGE, |
14 | text, | 15 | text, |
... | @@ -22,24 +23,42 @@ export const load = () => async (dispatch) =>{ | ... | @@ -22,24 +23,42 @@ export const load = () => async (dispatch) =>{ |
22 | 23 | ||
23 | export const submit = (text) => async (dispatch) => { | 24 | export const submit = (text) => async (dispatch) => { |
24 | dispatch( {type:START}); | 25 | dispatch( {type:START}); |
26 | + | ||
27 | + const timer =setTimeout( () => { | ||
28 | + Alert.alert( | ||
29 | + '오류가 발생했습니다.', | ||
30 | + '서버 연결 에러 (시간 초과)', | ||
31 | + [ | ||
32 | + {text: '확인', onPress: () => {}}, | ||
33 | + ], | ||
34 | + ); | ||
35 | + dispatch({ type:FAILURE }) | ||
36 | + },10000); | ||
37 | + | ||
25 | try{ | 38 | try{ |
26 | //const response = await readTest() | 39 | //const response = await readTest() |
27 | const response = await sendSearch(text.nativeEvent.text); | 40 | const response = await sendSearch(text.nativeEvent.text); |
41 | + | ||
42 | + // 에러시 error throw | ||
43 | + if(response.return_code == -1){throw new Error(response.error_code)}; | ||
44 | + | ||
28 | let tempScore = scoring(response.return_data); | 45 | let tempScore = scoring(response.return_data); |
29 | await sqlite.insert(tempScore.full); | 46 | await sqlite.insert(tempScore.full); |
30 | let past = await sqlite.select(); | 47 | let past = await sqlite.select(); |
31 | past = past.map( elem => elem.score ); | 48 | past = past.map( elem => elem.score ); |
32 | - //dispatch( { type:SUCCESS, result:response } | 49 | + |
33 | dispatch( { type:SUCCESS, result:response, past: past, score:tempScore}) | 50 | dispatch( { type:SUCCESS, result:response, past: past, score:tempScore}) |
51 | + | ||
52 | + clearTimeout(timer); | ||
34 | } | 53 | } |
35 | catch(err){ | 54 | catch(err){ |
36 | - console.log(err); | 55 | + Alert.alert( |
37 | - /* Alert.alert( | 56 | + '오류가 발생했습니다.', |
38 | - 'error', | 57 | + err.message, |
39 | [ | 58 | [ |
40 | {text: '확인', onPress: () => {}}, | 59 | {text: '확인', onPress: () => {}}, |
41 | ], | 60 | ], |
42 | - ) */ | 61 | + ); |
43 | dispatch({ type:FAILURE }) | 62 | dispatch({ type:FAILURE }) |
44 | } | 63 | } |
45 | } | 64 | } |
... | @@ -54,7 +73,7 @@ const initialState = { | ... | @@ -54,7 +73,7 @@ const initialState = { |
54 | }, | 73 | }, |
55 | score : {}, | 74 | score : {}, |
56 | isLoading: false, | 75 | isLoading: false, |
57 | - pastScore: [10,10,10,10,10,10], | 76 | + pastScore: [0,0,0,0,0,0], |
58 | }; | 77 | }; |
59 | 78 | ||
60 | export default ToggleLoading = (state = initialState, action) => { | 79 | export default ToggleLoading = (state = initialState, action) => { | ... | ... |
-
Please register or login to post a comment