lib/client: add Client.cm
This contains the current connection case-mapping, parsed from the CASEMAPPING ISUPPORT token.
This commit is contained in:
parent
3110a9e2df
commit
615e746ec5
2 changed files with 22 additions and 1 deletions
|
@ -47,6 +47,7 @@ export default class Client extends EventTarget {
|
||||||
autoReconnect = true;
|
autoReconnect = true;
|
||||||
reconnectTimeoutID = null;
|
reconnectTimeoutID = null;
|
||||||
pendingHistory = Promise.resolve(null);
|
pendingHistory = Promise.resolve(null);
|
||||||
|
cm = irc.CaseMapping.RFC1459;
|
||||||
|
|
||||||
constructor(params) {
|
constructor(params) {
|
||||||
super();
|
super();
|
||||||
|
@ -166,7 +167,18 @@ export default class Client extends EventTarget {
|
||||||
break;
|
break;
|
||||||
case irc.RPL_ISUPPORT:
|
case irc.RPL_ISUPPORT:
|
||||||
var tokens = msg.params.slice(1, -1);
|
var tokens = msg.params.slice(1, -1);
|
||||||
irc.parseISUPPORT(tokens, this.isupport);
|
var changed = irc.parseISUPPORT(tokens, this.isupport);
|
||||||
|
if (changed.indexOf("CASEMAPPING") >= 0) {
|
||||||
|
this.setCaseMapping(this.isupport.get("CASEMAPPING"));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case irc.RPL_ENDOFMOTD:
|
||||||
|
case irc.ERR_NOMOTD:
|
||||||
|
// These messages are used to indicate the end of the ISUPPORT list
|
||||||
|
if (!this.isupport.has("CASEMAPPING")) {
|
||||||
|
// Server didn't send any CASEMAPPING token, assume RFC 1459
|
||||||
|
this.setCaseMapping("rfc1459");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "CAP":
|
case "CAP":
|
||||||
this.handleCap(msg);
|
this.handleCap(msg);
|
||||||
|
@ -378,6 +390,14 @@ export default class Client extends EventTarget {
|
||||||
console.debug("Sent:", msg);
|
console.debug("Sent:", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setCaseMapping(name) {
|
||||||
|
this.cm = irc.CaseMapping.byName(name);
|
||||||
|
if (!this.cm) {
|
||||||
|
console.error("Unsupported case-mapping '" + name + "', falling back to RFC 1459");
|
||||||
|
this.cm = irc.CaseMapping.RFC1459;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Execute a command that expects a response. `done` is called with message
|
/* Execute a command that expects a response. `done` is called with message
|
||||||
* events until it returns a truthy value. */
|
* events until it returns a truthy value. */
|
||||||
roundtrip(msg, done) {
|
roundtrip(msg, done) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ export const RPL_TOPICWHOTIME = "333";
|
||||||
export const RPL_WHOREPLY = "352";
|
export const RPL_WHOREPLY = "352";
|
||||||
export const RPL_NAMREPLY = "353";
|
export const RPL_NAMREPLY = "353";
|
||||||
export const RPL_ENDOFNAMES = "366";
|
export const RPL_ENDOFNAMES = "366";
|
||||||
|
export const RPL_ENDOFMOTD = "376";
|
||||||
export const ERR_NOMOTD = "422";
|
export const ERR_NOMOTD = "422";
|
||||||
export const ERR_ERRONEUSNICKNAME = "432";
|
export const ERR_ERRONEUSNICKNAME = "432";
|
||||||
export const ERR_NICKNAMEINUSE = "433";
|
export const ERR_NICKNAMEINUSE = "433";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue