Commit Graph

37 Commits

Author SHA1 Message Date
Zorchenhimer fdbf39f00c Add some logging
Functions added:
- LogErrorf()
- LogErrorln()
- LogChatf()
- LogChatln()
- LogInfof()
- LogInfoln()
- LogDebugf()
- LogDebugln()
- LogDevf()
- LogDevln()

New settings configure the logging: LogLevel and LogFile.  LogLevel can
be set to one of: error, chat, info, or debug and will default to
error.  LogFile is an optional file to write to.  Providing a file will
not prevent output in the console.

LogDevf() and LogDevln() only compile when the "dev" flag passed to
build.  This will cause Travis-CI to fail the build if it finds any
calls to either function.
2019-03-24 18:58:59 -04:00
joeyak cd34480bba Change auth level checking to be on command level
The server sends new auth level to user when modded
closes #60
2019-03-24 17:27:04 -04:00
joeyak 5c87d70d3e Change unlock to be consistant with the message break if 2019-03-24 17:12:04 -04:00
Zorchenhimer 60f3ade2ee Fix clientsMtx lock without unlock in Broadcast()
Reorganize the lock/unlock pairs to be more consistent and to fix a
case with an uneven lock/unlock.
2019-03-24 16:38:42 -04:00
Zorchenhimer 2f252d5ae8 Strip @ prefix on names in commands
Names can be passed to commands with @ prefixed to them.

When forcing a color change on another user the @ explicitly defines
the name, instead of simply being stripped off.  This will allow the
a user named "red" to have their color changed: `/color @red blue`

A bunch of the color command code has changed with this to make things
less ambiguous and to add some other checks.  `/color red #FF0000` and
`/color @red red` will change the color of the user "red" to the color
red while `/color red red`will return with an error.  Note that the
color an name arguments can be in any order.

Resolves #64
2019-03-24 15:16:01 -04:00
Zorchenhimer 87f8839a33 Only send Chat and Event messages to temp clients
These should be the only messages that need to be sent to temp clients
for now.
2019-03-23 23:27:56 -04:00
Zorchenhimer 07589e7099 Don't allow banning admins 2019-03-23 18:09:27 -04:00
Zorchenhimer d734ec110e Remove error'd temp connections
If there's an error writing to a temp connection, remove it from the
chatroom.
2019-03-23 16:54:05 -04:00
Zorchenhimer 6ef0d6f1a5 Add some debugging info to the client connection 2019-03-23 16:10:04 -04:00
Zorchenhimer 62afc2eef9 Fixup ChatRoom.Broadcast()
Use an RW Mutex for chatConnection and use some goroutines when sending
data to clients in Broadcast().  This should prevent blocking on
unresponsive clients.
2019-03-23 14:50:47 -04:00
Zorchenhimer 0036dde265 Fix some typos
BroadCast() -> Broadcast()
startRmptServer() -> startRmtpServer()
2019-03-23 14:46:49 -04:00
joeyak bc983d9ce3 Removing unused variables and increasing queue
The UsernameMaxLength and MinLength constants were removed because common.IsValidUsername checks that.
Changed queue sizes to 1000 because if 25 people are joined and 4 say a message at the same time
it results in 100 messages.
2019-03-21 16:05:14 -04:00
joeyak 355f09bd48 Refactoring of ChatData
The processing of ChatData was changed so ChatData has a DataInterface object, which will be converted to a
ChatDataJSON that will have the DataInterface field converted to a json.RawMessage field. This change allows
greater customizability in the chat messages, since the Data field can still be read and modified.
2019-03-21 08:47:40 -04:00
Zorchenhimer 990060fb31 Fix removing clients from the clients map
ChatRoom.delClient() wasn't updated to use UUID's instead of names.
The calling functions were passing in a name instead of a suid, so
attempting to delete the client silently failed.

Fixes #52
2019-03-20 20:41:11 -04:00
joeyak 1cfa040f7b Added color names as possible arguements for /color
Did some linting fixing too.
Closes #45
2019-03-19 22:56:01 -04:00
Zorchenhimer 49e997c5ff Move some stuff to MovieNight.common
Moved to common/utils.go:
- IsValidName() (function replaces direct calls to regexp.MatchString())
- RandomColor()

Moved to common/emotes.go:
- LoadEmotes()
2019-03-19 17:25:49 -04:00
Zorchenhimer 1c6c23da3e Add /nick command
Using this command will change the current user's nickname in chat.
It has an alias of /name.

An admin can force a name change by supplying the current name and a new
name.  If a name has been changed by an admin, that user can no longer
change their name (similar to forced color change).

Resolves #42
2019-03-19 17:13:20 -04:00
Zorchenhimer 7dff29b152 Add user badges
Add badges for admins and mods.  Admins get a red badge, and mods get a
green one.

Normal users do not get a badge.
2019-03-16 18:11:27 -04:00
Zorchenhimer 75946b600b Move clients mutex lock in ChatRoom.Broadcast()
Don't lock the clients map while sleeping in ChatRoom.Broadcast().
2019-03-16 14:09:58 -04:00
Zorchenhimer f18b790c4d Wrap connection reads and writes with a mutex
Wrapping the connection with a mutex prevents the "concurrent write to
websocket connection" panic.  The new functions are ReadData() and
WriteData so as to not collide with ReadJSON() and WriteJSON().
2019-03-16 13:44:18 -04:00
joeyak bc90744798 Move broadcast logic to be self contained in the function 2019-03-15 18:57:50 -04:00
joeyak a717c6ef38 Converting from conn.WriteMessage to conn.WriteJson
This takes away some of the work on the developers side to worry about parsing the object as a json string.
Backend work for issue #7
2019-03-15 17:28:29 -04:00
Zorchenhimer 28d43a726a Add Mod notice messages
These messages are only sent to mods and admins for certain events:
- User gains mod/admin privileges
- User attempts to gain mod/admin privileges unsuccessfully
- Mod/Admin uses the /sv command
- Mod/Admin uses the /playing command
- Mod unmods themselves
- Mod/Admin mods/unmods a user
- Mod/Admin uses the /reloademotes command
- Mod/Admin uses the /reloadplayer command

A separate message queue is used for these messages, and they are only
sent to clients that are either a mod or an admin.  They are sent
with the same call to ChatRoom.Broadcast(), but after all the normal
messages are sent.

Resolves #3
2019-03-15 16:03:31 -04:00
joeyak 678ccab95c Add some backend infrastructure
The server can now send the client objects with data for the client to process.
issue #7
2019-03-15 02:19:16 -04:00
joeyak 6a2cb3f906 Fix some linting errors with error messages 2019-03-14 15:19:36 -04:00
Zorchenhimer 0effbf49b5 Rewrite ChatRoom.Broadcast()
The broadcast code would lock up eventually after a lot of messages.
It was rewritten to simplify and make it a bit more robust.  Chat
should no longer seize up for individual chatters or the entire room
after a lot of messages.
2019-03-14 10:11:14 -04:00
joeyak 2ef3684c14 Some linting fixes for the common package 2019-03-13 21:24:14 -04:00
joeyak 18465c61f5 Make the chatroom send each message individually
closes #24
2019-03-13 21:14:43 -04:00
Zorchenhimer 1cd490b04a Add single-use mod passwords
Single-use moderator passwords can only be generated by an admin with
the /modpass command.  To redeem the password and gain moderator
privileges, a user just needs to call /auth with the password.

The passwords are generated using the same function as the admin
password.  Additionally, generating passwords now uses crypto/rand
instead of math/rand.

Resolves #15
2019-03-13 16:51:07 -04:00
joeyak 5516313c79 Allow chat to be sent before the name is sent to the server
closes #17
2019-03-13 16:47:19 -04:00
Zorchenhimer a555e626af Merge branch 'json-communication'
# Conflicts:
#	chatclient.go
#	chatroom.go
2019-03-13 14:00:13 -04:00
Zorchenhimer bdd4e71261 Flesh out the JSON stuff a bit more
Implement some commands in the wasm client code:
  - /playing (setting and clearing)
  - /refreshplayer
Commands not yet implemented:
  - /purge (command doesn't exist yet on server)
  - /help (doesn't open window)
2019-03-13 13:42:38 -04:00
Zorchenhimer 9c80269943 Start convert to JSON data b/t client and server
Chat and events should work.  Commands do not work yet.  Everything
also needs to be tested and cleaned up a bunch more.
2019-03-13 01:09:24 -04:00
joeyak d16839c597 Changed format tool from gofmt to goimports 2019-03-13 00:25:03 -04:00
joeyak 7ee1c1ffb8 Changing css to go from floats and widths to css grid
close #11
close #23
2019-03-12 18:16:35 -04:00
joeyak 5544ac817f Converted to code to using webassembly 2019-03-11 23:15:42 -04:00
Zorchenhimer 3276295421 Initial commit
So far things work.  Needs lots of improvements.
2019-03-10 11:42:12 -04:00