diff --git a/File/Log/Log.inc b/File/Log/Log.inc index 9a86f5a..fb1235e 100644 --- a/File/Log/Log.inc +++ b/File/Log/Log.inc @@ -17,4 +17,5 @@ getScoresCountSignal LogString 10, '===================================', 10, 'G currentPointsSignal LogString 10, 'Current Points = ' addNewScoreSignal LogString 10, '===================================', 10, 'Add new score', 10 getUserScoreSignal LogString 10, '===================================', 10, 'Get user scores', 10 -getBestScoreSignal LogString 10, '===================================', 10, 'Get best scores', 10 \ No newline at end of file +getBestScoreSignal LogString 10, '===================================', 10, 'Get best scores', 10 +errorSignal LogString 10, '===================================', 10, 'ERROR FROM SERVER!', 10 \ No newline at end of file diff --git a/Server/SendRequest/Methods/Player.asm b/Server/SendRequest/Methods/Player.asm index 0a5bde8..b8a39fe 100644 --- a/Server/SendRequest/Methods/Player.asm +++ b/Server/SendRequest/Methods/Player.asm @@ -13,6 +13,8 @@ proc Server.Methods.Player.IsExist uses eax ebx stdcall Log.Console, sendString, sendString.size stdcall Log.Console, playerJSON.loginStart, sizeof.PlayerJSON stdcall Server.SendRequest.GetIsPlayerExist, playerJSON.loginStart, sizeof.PlayerJSON, idResponseBuffer, [idResponseBufferLength] + cmp eax, -1 + je .serverError stdcall Log.Console, serverAnswer, serverAnswer.size mov ebx, eax stdcall File.IniFile.StrLen, eax @@ -35,6 +37,9 @@ proc Server.Methods.Player.IsExist uses eax ebx jmp .exit @@: mov eax, 1 + jmp .exit + .serverError: + stdcall Log.Console, errorSignal, errorSignal.size .exit: stdcall ClearBuffer, [jsonLink] ret @@ -67,6 +72,8 @@ proc Server.Methods.Player.AddNewPlayer stdcall Log.Console, sendString, sendString.size stdcall Log.Console, playerJSON.loginStart, sizeof.PlayerJSON stdcall Server.SendRequest.PostAddPlayers, playerJSON.loginStart, sizeof.PlayerJSON, idResponseBuffer, [idResponseBufferLength] + cmp eax, -1 + je .serverError stdcall Log.Console, serverAnswer, serverAnswer.size mov ebx, eax stdcall File.IniFile.StrLen, eax @@ -106,6 +113,9 @@ proc Server.Methods.Player.AddNewPlayer mov [str_error], str_nullerror stdcall Server.ErrorPayloadUpdate ; null error stdcall Page.ChangePage, LoadingPage + jmp .exit + .serverError: + stdcall Log.Console, errorSignal, errorSignal.size .exit: stdcall ClearBuffer, [jsonLink] ret @@ -124,6 +134,8 @@ proc Server.Methods.Player.ScoresCount stdcall Log.Console, sendString, sendString.size stdcall Log.Console, idJSON.idStart, sizeof.IdJSON stdcall Server.SendRequest.GetUserScoresCount, idJSON.idStart, sizeof.IdJSON, idResponseBuffer, [idResponseBufferLength] + cmp eax, -1 + je .serverError stdcall Log.Console, serverAnswer, serverAnswer.size mov ebx, eax stdcall File.IniFile.StrLen, eax @@ -143,6 +155,9 @@ proc Server.Methods.Player.ScoresCount jmp .exit @@: stdcall Server.JSON.GetScoresCount, [jsonLink] + jmp .exit + .serverError: + stdcall Log.Console, errorSignal, errorSignal.size .exit: stdcall ClearBuffer, [jsonLink] ret diff --git a/Server/SendRequest/Methods/Score.asm b/Server/SendRequest/Methods/Score.asm index b77f008..d3886dc 100644 --- a/Server/SendRequest/Methods/Score.asm +++ b/Server/SendRequest/Methods/Score.asm @@ -13,12 +13,17 @@ proc Server.Methods.Score.Add stdcall Log.Console, sendString, sendString.size stdcall Log.Console, scoreJSON.pointsStart, sizeof.ScoreJSON stdcall Server.SendRequest.PostAddScores, scoreJSON.pointsStart, sizeof.ScoreJSON, idResponseBuffer, [idResponseBufferLength] + cmp eax, -1 + je .serverError stdcall Log.Console, serverAnswer, serverAnswer.size mov ebx, eax stdcall File.IniFile.StrLen, eax stdcall Log.Console, ebx, eax xchg eax, ebx mov [jsonLink], eax + jmp .exit + .serverError: + stdcall Log.Console, errorSignal, errorSignal.size .exit: stdcall ClearBuffer, [jsonLink] ret @@ -37,6 +42,8 @@ proc Server.Methods.Score.UserScores stdcall Log.Console, sendString, sendString.size stdcall Log.Console, idJSON.idStart, sizeof.IdJSON stdcall Server.SendRequest.GetAllUserScores, idJSON.idStart, sizeof.IdJSON, scoresUserRespBuffer, [scoresUserRespBufferLength] + cmp eax, -1 + je .serverError stdcall Log.Console, serverAnswer, serverAnswer.size mov ebx, eax stdcall File.IniFile.StrLen, eax @@ -59,6 +66,9 @@ proc Server.Methods.Score.UserScores @@: stdcall Server.JSON.ParseUserScore, [jsonLink], [UserScores] mov [UserScoresLen], eax + jmp .exit + .serverError: + stdcall Log.Console, errorSignal, errorSignal.size .exit: stdcall ClearBuffer, [jsonLink] ret @@ -71,6 +81,8 @@ proc Server.Methods.Score.BestScores stdcall Log.Console, getBestScoreSignal, getBestScoreSignal.size stdcall Log.Console, sendString, sendString.size stdcall Server.SendRequest.GetBestScores, 0, 0, scoresGlobRespBuffer, [scoresGlobRespBufferLength] + cmp eax, -1 + je .serverError stdcall Log.Console, serverAnswer, serverAnswer.size mov ebx, eax stdcall File.IniFile.StrLen, eax @@ -92,6 +104,9 @@ proc Server.Methods.Score.BestScores @@: stdcall Server.JSON.ParseBestScore, [jsonLink], [BestScores] mov [BestScoresLen], eax + jmp .exit + .serverError: + stdcall Log.Console, errorSignal, errorSignal.size .exit: stdcall ClearBuffer, [jsonLink] ret diff --git a/Server/SendRequest/REST/GET.asm b/Server/SendRequest/REST/GET.asm index eb95910..831426c 100644 --- a/Server/SendRequest/REST/GET.asm +++ b/Server/SendRequest/REST/GET.asm @@ -34,26 +34,26 @@ proc Server.SendRequest.GET,\ mov eax, [buffer] mov [result], eax - ;invoke MessageBox, 0, eax, ErrorTitle, MB_OK jmp .exit .error: - invoke GetLastError - invoke MessageBox, 0, ErrorMessage, ErrorTitle, MB_OK + mov [result], -1 + invoke GetLastError + ;invoke MessageBox, 0, ErrorMessage, ErrorTitle, MB_OK .exit: - cmp [hRequest], 0 - jz .skipRequest - invoke WinHttpCloseHandle, [hRequest] + cmp [hRequest], 0 + jz .skipRequest + invoke WinHttpCloseHandle, [hRequest] .skipRequest: - cmp [hConnect], 0 - jz .skipConnect - invoke WinHttpCloseHandle, [hConnect] + cmp [hConnect], 0 + jz .skipConnect + invoke WinHttpCloseHandle, [hConnect] .skipConnect: - cmp [hSession], 0 - jz .skipSession - invoke WinHttpCloseHandle, [hSession] + cmp [hSession], 0 + jz .skipSession + invoke WinHttpCloseHandle, [hSession] .skipSession: mov eax, [result] ret diff --git a/Server/SendRequest/REST/POST.asm b/Server/SendRequest/REST/POST.asm index 5ee0ade..aab4748 100644 --- a/Server/SendRequest/REST/POST.asm +++ b/Server/SendRequest/REST/POST.asm @@ -34,26 +34,26 @@ proc Server.SendRequest.POST,\ mov eax, [buffer] mov [result], eax - ;invoke MessageBox, 0, eax, ErrorTitle, MB_OK jmp .exit .error: - invoke GetLastError - invoke MessageBox, 0, ErrorMessage, ErrorTitle, MB_OK + mov [result], -1 + invoke GetLastError + ;invoke MessageBox, 0, ErrorMessage, ErrorTitle, MB_OK .exit: - cmp [hRequest], 0 - jz .skipRequest - invoke WinHttpCloseHandle, [hRequest] + cmp [hRequest], 0 + jz .skipRequest + invoke WinHttpCloseHandle, [hRequest] .skipRequest: - cmp [hConnect], 0 - jz .skipConnect - invoke WinHttpCloseHandle, [hConnect] + cmp [hConnect], 0 + jz .skipConnect + invoke WinHttpCloseHandle, [hConnect] .skipConnect: - cmp [hSession], 0 - jz .skipSession - invoke WinHttpCloseHandle, [hSession] + cmp [hSession], 0 + jz .skipSession + invoke WinHttpCloseHandle, [hSession] .skipSession: mov eax, [result] ret