summaryrefslogtreecommitdiff
path: root/wsm.go (follow)
Commit message (Collapse)AuthorAgeFilesLines
* *.go: Update commentsRunxi Yu2024-10-091-2/+3
|
* *.go: Use sync.Map instead of map[int]*courseT for coursesRunxi Yu2024-10-091-17/+36
| | | | I'm not sure whether this is actually better than locking.
* {courses,wsc,wsm}.go: map[courseGroupT](bool->struct{})Runxi Yu2024-10-081-4/+4
| | | | | This makes it use slightly less memory. Approximately courseGroupT bits per connection!
* *.go: Further wrap errorsRunxi Yu2024-10-081-11/+24
|
* {courses,wsm,wsp}.go: Make course.Selected atomicRunxi Yu2024-10-071-1/+7
|
* {config,wsm}.go, cca.scfg.example: Configurable immediate propagationRunxi Yu2024-10-061-6/+9
|
* *.go: Limit to approximately 80 characters per lineRunxi Yu2024-10-061-19/+84
|
* wsm.go: "R" on multiple choices in group rather than closing connectionRunxi Yu2024-10-061-4/+5
|
* wsm.go: Check course group constraint first when choosingRunxi Yu2024-10-061-13/+15
|
* {courses,wsc,wsm,wsp}.go: Send course number immediately on user interactionRunxi Yu2024-10-061-3/+16
|
* *: Overhaul structure again and embed everythingRunxi Yu2024-10-061-0/+224
| | | | | | | | - Remove sub-Makefiles; recursive make is annoying - Just use one top-level Makefile that builds everything - Embed templates and minified static resources into the binary - Embed all compiled documentation into the binary and serve - Embed all source into the binary and serve
* *.go: Move to backendRunxi Yu2024-10-051-224/+0
| | | | And adjust Makefiles, admin handbook, and lint.sh accordingly.
* {courses,wsm}.go: Use in-memory structure to fetch cgroup, not SQLRunxi Yu2024-10-051-9/+12
|
* wsm.go: Omit comparison to bool constantRunxi Yu2024-10-051-1/+1
|
* wsm.go: Report error when course doesn't existRunxi Yu2024-10-051-0/+8
| | | | | Luckily we encounter a database error before we have the chance to dereference a null pointer. But it's still good practice to check.
* {courses,sem,ws,wsm}.go: Second step towards an efficient state propagatorRunxi Yu2024-10-051-1/+1
| | | | References: https://todo.sr.ht/~runxiyu/cca/7
* {courses,wsm}.go: Add getCourseByIDRunxi Yu2024-10-051-10/+2
| | | | This also deduplicates some code.
* {courses,wsm}.go: Add (*courseT).decrementSelectedAndPropagateRunxi Yu2024-10-051-24/+4
| | | | This is being done quite a few times, so let's make it a function.
* {courses,ws,wsm}.go: Update userCourseGroups during choose/unchooseRunxi Yu2024-10-051-2/+30
|
* {ws,wsm}.go: Handle context cancellationsRunxi Yu2024-10-031-0/+20
|
* {main,ws,wsm}.go: Attempt to cancel old sessionsRunxi Yu2024-10-031-15/+15
| | | | | | | | | | | | | | | | | | | When beginning to handle a WebSocket connection, we shall create a new context, with the request context as its parent. We use the new context for everything from now on, except for reporting error messages, which is handled by creating a reportError function in a closure in makeReportError and passing it along to command-handling functions. Note that if one user attempts to rapidly launch WebSocket connections, there might still be a race condition where the old connection hasn't been completely established yet (i.e. an entry hasn't been added to cancelPool) and the new connection isn't able to cancel the old connection. I'm a bit tired to think of a solution now but it could probably be solved by moving the cancellation registration and cancelling sooner during the initial handshake. Note that more parts of the event loop needs to select from ctx.Done (from newCtx) for this to work reliably.
* wsm.go, main.js: Use M for number, N for deselectRunxi Yu2024-10-021-3/+3
| | | | | | | Previously both commands used N, and deselection wasn't really implemented on the JavaScript side. It worked and didn't throw an exception but it's technically wrong and the user could see an empty number field for a split second.
* {auth,db,wsm}.go: Make 23505 (uniqueness violation) a constantRunxi Yu2024-10-011-1/+1
|
* wsm.go, main.js: Display the user's selected courses on first runv0.1.0Runxi Yu2024-10-011-2/+18
| | | | | It's done in the WebSocket routines rather than in the template maker because it's relatively easier to write the logic this way.
* {ws,wsm}.go: Split message handlers into their own functionsRunxi Yu2024-10-011-0/+177