Browser JavaScript app IRC connection

2.3k views Asked by At

Thanks for any help in advance!

Anyway, I want my JavaScript application to be able to "connect to" or otherwise "communicate with" IRC.

(I need it to run in browser, so no npmjs-dependent solutions, and yes, I have tried Browserify, but a lot of things seem to be un-Browserify-able, so please don't suggest a Browserfiy-related method, unless you're absolutely sure)

It would seem that it is not easy or maybe not possible to "connect" directly to IRC in JavaScript, so I am comfortable with using other, even if more redundant, methods to communicate, including usage of other languages that can be use in-browser, such as Java, or PHP if possible.

I'm open to any suggestions! Thanks so much!

2

There are 2 answers

0
Michel Kuipers Chaosje On

HTML5 introduced stay-alive connections through the WebSocket protocol, which now (HyBi06, WS version 13) is implemented and accepted by almost any device, and very stable. The problem is that IRC does not have a WebSocket communication protocol.

The solution I've built is to create a WebSocket-server that creates a raw connection to the IRC-server for every client and acts as a mediator. Every client runs an IRC-bot I already had developed, which turns messages from the server into events, which means I had to implement all events I wanted to pass on to the Website.

0
oelna On

It is true that IRC per se can't talk to Websockets directly, but thankfully IRC servers, such as UnrealIRCd, have begun adopting Websockets on their end, so that manual tunneling or mediating is in many cases no longer necessary!

As a proof-of-concept I have written a basic browser-only Javascript IRC client, which connects directly to Websocket-capable IRC servers. Demo

The situation is improving, many years after the original question was asked.