jbnc icon indicating copy to clipboard operation
jbnc copied to clipboard

Is it useful to convert the jbnc code into a class?

Open Madriix opened this issue 1 year ago • 8 comments

Hi,

Do you know if it would be useful for me to try converting the jbnc code into a class,

class jBNC {
  constructor() {
    // Track IRC (Server) Connections
    this.connections = {};
  }

  init(){
  }

  doServer() {
  }

  clientReconnect(socket) {
  }

  clientConnect(socket) {
  }


}

new jBNC();

or is it pointless ?

Madriix avatar Apr 17 '24 22:04 Madriix

I'd say generally it's always good to use classes because it makes code more manageable. Helps to debug issues as well.

It would make sense to further breakdown (e.g., Client class, PreClient class, IRCConnection class, BNC class, etc. imho) ;o

realrasengan avatar Apr 17 '24 23:04 realrasengan

Oh, I see, it would definitely make a good thing. It takes hours, constantly editing.

Madriix avatar Apr 17 '24 23:04 Madriix

@realrasengan I've adapted the code to be within classes : https://github.com/Madriix/jbnctest It has been tested locally on my PC with Node.js, and it seems to work well. However, I haven't tested it with a second user using a different nickname. I'll need to try that. If it works, I'll deploy it on the site for a few minutes or hours initially. If there are no issues, I'll leave it online until a problem arises.

Madriix avatar Apr 18 '24 15:04 Madriix

That's really cool! :)

realrasengan avatar Apr 18 '24 16:04 realrasengan

@realrasengan I deployed it to production, but it was immediately shut down. I reverted to the previous version. There's an issue where all users are still sending messages twice (from their end), but the recipient only receives them once. I can't seem to pinpoint the problem.

Madriix avatar Apr 18 '24 16:04 Madriix

The issue no longer occurs when modifying it like this : https://github.com/Madriix/jbnctest/commit/5cb44655367475b2132a4dcf30c918abb7786900

EDIT: I restored, I just replaced this with socket: https://github.com/Madriix/jbnctest/commit/815123dfdd47a5d9aeaa1d8e26eaa5012b3490b5

Madriix avatar Apr 18 '24 17:04 Madriix

@realrasengan The JBNC classes have been running smoothly via Putty since 7:00 PM. It's almost midnight, with 205 users connected and the bouncetimeout set to 60 minutes, and it still hasn't crashed. Should I send a pull request?

Madriix avatar Apr 18 '24 21:04 Madriix

Sounds good to me!

realrasengan avatar Apr 18 '24 22:04 realrasengan