-
Notifications
You must be signed in to change notification settings - Fork 0
Network
Victor edited this page May 12, 2024
·
2 revisions
Serves as a HTTP Server (WebServer class in Squeak/Smalltalk) and works closely together with LQPollRepo to manage objects over the network. The LQRemotePollRepoServer contains the following methods:
-
onRequest: req
: checks if the incoming request is a POST or GET request. -
httpPost/httpGet
: both methods get called withinonRequest
depending on the type of the incoming request. -
isAddAnswerSetRequest: req
: checks the message field of the incoming POST request foraddAnswerSet
. -
isGroupGetRequest: req
: checks the message field of the incoming GET request forgetGroup
. -
isPollGetRequest: req
: true if no message field exists -
httpPostAddAnswerSet: req
: extracts the necessary data from the POST request and passes that data to the addAnswerSet method. -
addAnswerSet: anAnswerSet FromUser: aUser ToPoll: aPoll
: checks for sufficient authentication and adds the answer set (implementation in LQPoll). -
httpGetPoll: req
: extracts the id from the GET request and checks for existence and sufficient authentication. If the poll exists it gets included in the response in STON format. -
httpGetGroup: req
: same ashttpGetPoll
but for a group id -
pollWithId: id
: extracts the poll from the LQPollRepo -
request: req isAuthenticatedFor: poll
: on polls which require authentication this method checks for a valid user token -
unauthorizedResponseCode
: 401 -
send401Response: request
: builds and sends the response -
initialize
: registers the service under the '/' route
Singleton client for the LQRemotePollRepoServer. The singleton manages the user's token. The following methods are implemented:
-
url/url:
: getter and setter forurl
instance var -
addAnswerSet: anAnswerSet ToPoll: aPollId
: sends a POST request to the server containing the answer set in STON format -
at: key ifAbsent: aBlock
: sends request to the server -
groupAt: key
: requests a group given a key from the server requestToken
-
serverAt: key
: sends GET request to server given a poll id shouldAskPasswordForResponse: aWebResponse
-
urlForGroupRequestForPollWithId/urlForPollWithId/urlForPostingAnswerSet
: return the corresponding url with the given parameters
Registers a networkService by using the current ServiceRegsitry
LQAntiCheat checks whether or not an answerSet is allowed to be added to a poll. It ensures that group-based answer-exclusion is enforced by the server and that multiple answers cannot be added to a poll.
Special error class to determinate errors that occured on the remote server.