Minecraft-Console-Client icon indicating copy to clipboard operation
Minecraft-Console-Client copied to clipboard

Web acces

Open J0113 opened this issue 8 years ago • 11 comments

As the title said a simple password protected web acces can be really cool!

J0113 avatar May 30 '16 13:05 J0113

That's a good idea! However I don't have enough time myself to work on GUIs, but maybe someone else would be interested?

ORelio avatar Jun 01 '16 07:06 ORelio

Although this is a 4 years old issue, I want to say that WebUI is definitely an interesting idea and I am already working a bit on it! image

ReinforceZwei avatar Dec 05 '20 12:12 ReinforceZwei

Looks nice! I don't have much time to work on MCC lately, but your work is amazing! 😉

ORelio avatar Dec 05 '20 13:12 ORelio

I am using https://github.com/sta/websocket-sharp to create WebSocket server for communicating with the web client. What is the best way to add the project reference to MCC? Currently I am referencing to the .dll file directly but it will break on other's machine since they don't have the file.

<Reference Include="websocket-sharp">
      <HintPath>..\..\websocket-sharp\websocket-sharp\bin\Release\websocket-sharp.dll</HintPath>
</Reference>

Do I add the .dll to MCC's project folder or get the that project from NuGet?

ReinforceZwei avatar Dec 05 '20 14:12 ReinforceZwei

This will likely not work on .NET 4.0 but I'm not sure how to reference the DLL only if the user wants to enable the WebUI 🤔

ORelio avatar Dec 05 '20 17:12 ORelio

I was able to embed the .dll file to a resource file and load it only if the webUI is enabled. This way the .dll is embedded in MinecraftClient.exe and user doesn't need to download any extra file if they want to use the webUI.

About the development direction of the WebUI, do we integrate it into MCC for gaining full control from the webUI or just limit the scope to ChatBot API only? Which approach should we choose? Currently I am using the ChatBot API only.

ReinforceZwei avatar Dec 06 '20 12:12 ReinforceZwei

As long as the WebUI has proper authentication and is fully optional, you can upgrade it to provide full remote control, that seems cool. You can also do a separate executable that runs MCC like the example GUI in the project. Both approaches are valid anyway.

ORelio avatar Dec 06 '20 13:12 ORelio

I tried my best to make a working basic "remote shell" for sending and receiving messages. Honestly I am not very good at designing UI. Also I haven't considered the thread safe issue. image

Now I am lacking of ideas what features is great to be added in the WebUI.

ReinforceZwei avatar Dec 07 '20 10:12 ReinforceZwei

Pretty neat 👍 For thread safety just look at the built-in SendText() method in McClient.cs and look how it uses a lock. If you use this method or the one in ChatBot API you already are thread-safe.

ORelio avatar Dec 07 '20 17:12 ORelio

The problem is not about the SendText() but command execution. McClient.cs is not fully thread safe and some command could crash the client. For example the /entity command. (Translation: Collection was modified; enumeration operation may not execute.) image

I am trying my best to fix them by adding locks.

On the other hand, I am thinking maybe I could introduce a "multi-instance" mode for MCC with web interface, which allows user to login to multiple server and manage them from web interface with single MCC running. I have already made a bare bone poc and it was working fine on local server. I guess that would require a huge change to the whole project if we take this idea. What is your view?

ReinforceZwei avatar Dec 08 '20 07:12 ReinforceZwei

You could theoretically do it by creating multiple McClient instances, although I never tried. Regarding thread safety, the CommandPrompt() method runs in a separate thread so maybe you could look at it 🤔

ORelio avatar Dec 08 '20 16:12 ORelio