GithubHelp home page GithubHelp logo

clifg / movienight Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zorchenhimer/movienight

0.0 0.0 2.0 1.74 MB

Single instance video streaming server with integrated chat.

License: MIT License

Makefile 1.04% Go 81.40% HTML 4.59% JavaScript 6.51% CSS 6.07% Dockerfile 0.30% Shell 0.10%

movienight's People

Contributors

abridgewater avatar clifg avatar crossworth avatar dunn avatar joeyak avatar lukasklinger avatar meguminnet avatar michaelthomasmpt avatar zorchenhimer avatar

Watchers

 avatar

Forkers

pmredding

movienight's Issues

Add a new config flag to allow duplicate messages

Sometimes that might be nice to limit, but we should be able to turn it off.

			// Limit the rate of duplicate messages.  Ignore mods and admins.
			// Only checks the last message.
			if strings.TrimSpace(strings.ToLower(msg)) == cl.lastMsg &&
				time.Now().Before(cl.nextDuplicate) &&
				cl.CmdLevel == common.CmdlUser {
				err := cl.SendChatData(common.NewChatMessage("", "",
					common.ParseEmotes("You already sent that PeepoSus"),
					common.CmdlUser,
					common.MsgCommandResponse))
				if err != nil {
					common.LogErrorf("Unable to send slowdown for chat: %v", err)
				}
				return
			}

In chatclient.go

Handle disconnects more gracefully

This is especially important for mobile clients. When someone locks their phone or navigates from the mobile browser, the websocket gets closed, which drops them from the chat. If possible, we should keep them "in" the chat for a period of time and when they come back, reconnect with the same name and play the messages they missed.

Some notes:

  • Can we tell the difference between closing the browser window and locking/navigating away? In the former we would want to log out. In the latter we'd like not to.
  • Here's the library used in the code for websockets: github.com/gorilla/websocket
  • The code that handles the connection is in handlers.go, func is wsHandler()
  • When we detect a "nav away" type of situation, we should keep the client in the chat and mark it as "away" and have a buffer of messages to send to it when they reconnect. We should have a reasonable buffer here, and make it FIFO -- maybe just store the most recent 50 messages that they've missed?
  • We need to time out an away user after some time, maybe an hour?
  • Should we show the user as away in the /users list? That would be nice
  • How do we know when someone reconnects as the same user? Trusting that the name matches isn't great. We could do a name + IP match. Or we could have a handshake on fresh client connect where we send a small token to the client and it needs to send it. We'll only accept a "reconnect" if the client name matches and it has the token
  • This will require some web-side work and I have no idea how to do that yet

We can definitely break this down though and not do the buffering just so we can test the drop/reconnect functionality. Buffering some messages should be relatively easy to add after that.

Investigate video player configuration

Looks like flvjs has some config settings we can check out to see if we can get better performance. Here's a small change I found in someone else's fork that we could experiment with (from video.js):
var videoElement = document.getElementById("videoElement");
var flvPlayer = flvjs.createPlayer({
type: "flv",
url: "/live",
isLive: true,
}, {
enableStashBuffer: false,
});
flvPlayer.attachMediaElement(videoElement);
flvPlayer.load();

Highlight all usernames, not just your own

Also look into if we should only highlight if it's @username instead.

Apparently everyone has the same colors across all chats, so there must already be a user/color map somewhere that we can use for this

Broadcasting ChatData type of common.DTChat causes deadlock

Calling Broadcast() when messages of type common.DTChat are in the queue causes a deadlock due to the call of GetNames() in replaceColorizedName. One example of falling into this case is when reloading the player for all users because it queues a message to cr.queue.

Reloading player:

cl.belongsTo.AddCmdMsg(common.CmdRefreshPlayer, nil)

Broadcast function:

		case msg := <-cr.queue:
			cr.clientsMtx.Lock()
			for _, client := range cr.clients {
				go send(msg, client)
			}
			cr.clientsMtx.Unlock()
		case msg := <-cr.modqueue:
			cr.clientsMtx.Lock()
			for _, client := range cr.clients {
				if client.CmdLevel >= common.CmdlMod {
					go send(msg, client)
				}
			}

Make server messages customizable

And then we can make bachelor/whatever themed messages.

Like instead of You cannot change someone else's color. PeepoSus it should pull from a config file and we would use something like You can't change someone else's color. Stay in your lane.

Trying to mod another user deadlocks

  1. Become an admin using the admin password
  2. Try "/mod " for another user in the chat

This is almost certainly a deadlock because we're trying to read the list of names in the chat.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.