Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Voting-Plugin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dennis Willers
Voting-Plugin
Commits
69a5150f
Commit
69a5150f
authored
Aug 23, 2021
by
Dennis Willers
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version 1.0
parent
7ede522d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
46 additions
and
22 deletions
+46
-22
info.toml
info.toml
+2
-1
socket.as
src/conf/socket.as
+2
-0
chat.as
src/features/chat.as
+12
-10
window.as
src/features/window.as
+1
-1
jsonBuilder.as
src/helpFunctions/jsonBuilder.as
+20
-9
jsonRequestHandler.as
src/helpFunctions/jsonRequestHandler.as
+8
-0
main.as
src/main.as
+1
-1
No files found.
info.toml
View file @
69a5150f
...
...
@@ -4,6 +4,7 @@ author = "RoboTec13"
category
=
"Race"
version
=
"1.0"
siteid
=
120
[script]
imports
=
[
"Icons.as"
,
"Formatting.as"
]
imports
=
[
"Icons.as"
,
"Formatting.as"
,
"Permissions.as"
]
src/conf/socket.as
View file @
69a5150f
...
...
@@ -36,6 +36,7 @@ void waitingForResponse() {
}
void
requestSocketServer
(
const
Json
::
Value
&
in
js
)
{
print
(
"JSON REQUEST: "
+
Json
::
Write
(
js
))
;
// Send raw data (as a string) to the server.
if
(
!
sock
.
WriteRaw
(
Json
::
Write
(
js
)))
{
// If this fails, the socket might not be open. Something is wrong!
...
...
@@ -46,6 +47,7 @@ void requestSocketServer(const Json::Value &in js) {
void
handleMessage
(
const
Json
::
Value
&
in
js
)
{
print
(
"JSON RESPONSE: "
+
Json
::
Write
(
js
))
;
if
(
Json
::
Write
(
js
)
!=
"null"
)
{
setVotingInformation
(
js
)
;
}
...
...
src/features/chat.as
View file @
69a5150f
string
currentChatMessage
=
""
;
void
readLastChatMessage
()
{
while
(
true
)
{
if
(
getNetwork
()
!
is
null
)
{
MwFastBuffer
<
wstring
>
chatHistory
=
getNetwork
().
ChatHistoryLines
;
if
(
chatHistory
.
get_Length
()
>
0
)
{
string
chatMessage
=
chatHistory
[
0
]
;
if
(
chatMessage
!=
currentChatMessage
&&
!
hasVoteTimeout
)
{
currentChatMessage
=
chatMessage
;
if
(
checkIfMessageIsByCurrentClient
())
{
sendRequestIfMessageMatchForVoting
()
;
if
(
Permissions
::
InGameChat
())
{
while
(
true
)
{
if
(
getNetwork
()
!
is
null
)
{
MwFastBuffer
<
wstring
>
chatHistory
=
getNetwork
().
ChatHistoryLines
;
if
(
chatHistory
.
Length
>
0
)
{
string
chatMessage
=
chatHistory
[
0
]
;
if
(
chatMessage
!=
currentChatMessage
&&
!
hasVoteTimeout
)
{
currentChatMessage
=
chatMessage
;
if
(
checkIfMessageIsByCurrentClient
())
{
sendRequestIfMessageMatchForVoting
()
;
}
}
}
yield
()
;
}
yield
()
;
}
}
}
...
...
src/features/window.as
View file @
69a5150f
...
...
@@ -182,7 +182,7 @@ void newSelectedVoteByChat(int newSelectedValue, int vote) {
void
selectValue
(
int
newSelectedValue
,
int
vote
,
bool
isPrintVote
)
{
if
(
!
hasVoteTimeout
&&
selectedValue
!=
newSelectedValue
)
{
selectedValue
=
newSelectedValue
;
requestSocketServer
(
jsonBuilderSetVote
(
vote
)
)
;
setVoteInformation
(
vote
)
;
if
(
isPrintVote
)
printVote
(
vote
)
;
startnew
(
setVoteTimeout
)
;
}
...
...
src/helpFunctions/jsonBuilder.as
View file @
69a5150f
Json
::
Value
jsonBuilderSetVote
(
int
vote
)
{
// JSON REQUESTS
Json
:
:
Value
getVotes
()
{
auto
jsonObj
=
Json
::
Object
()
;
jsonObj
[
"vote"
]
=
vote
;
jsonObj
[
"mapId"
]
=
getMapUid
()
;
jsonObj
[
"userId"
]
=
getLogin
()
;
jsonObj
[
"name"
]
=
getNameForUi
()
;
jsonObj
[
"map"
]
=
getMapUid
()
;
jsonObj
[
"http"
]
=
"GET"
;
jsonObj
[
"url"
]
=
"getVotes?map="
+
getMapUid
()
;
return
jsonObj
;
}
Json
:
:
Value
getPlayerVote
()
{
auto
jsonObj
=
Json
::
Object
()
;
jsonObj
[
"map"
]
=
getMapUid
()
;
jsonObj
[
"http"
]
=
"GET"
;
jsonObj
[
"url"
]
=
"getPlayerVote?map="
+
getMapUid
()
+
"&player="
+
getLogin
()
;
return
jsonObj
;
}
Json
:
:
Value
jsonBuilderGetMapInfo
(
)
{
Json
:
:
Value
setVote
(
int
vote
)
{
auto
jsonObj
=
Json
::
Object
()
;
jsonObj
[
"mapId"
]
=
getMapUid
()
;
jsonObj
[
"userId"
]
=
getLogin
()
;
jsonObj
[
"name"
]
=
getNameForUi
()
;
jsonObj
[
"map"
]
=
getMapUid
()
;
jsonObj
[
"http"
]
=
"POST"
;
jsonObj
[
"player"
]
=
getLogin
()
;
jsonObj
[
"vote"
]
=
vote
;
return
jsonObj
;
}
src/helpFunctions/jsonRequestHandler.as
0 → 100644
View file @
69a5150f
void
getMapInitInformation
()
{
requestSocketServer
(
getVotes
())
;
requestSocketServer
(
getPlayerVote
())
;
}
void
setVoteInformation
(
int
vote
)
{
requestSocketServer
(
setVote
(
vote
))
;
}
\ No newline at end of file
src/main.as
View file @
69a5150f
...
...
@@ -31,7 +31,7 @@ void Main()
void
loadMapVoteInfo
()
{
if
(
initSocketConnection
())
{
requestSocketServer
(
jsonBuilderGetMapInfo
()
)
;
getMapInitInformation
(
)
;
resetTimeout
()
;
currentMapUid
=
getMapUid
()
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment