Improve type hints & re-add missing log message in client.js

This commit is contained in:
Andrew Ferrazzutti 2022-03-21 01:10:31 -04:00
parent ee3daab48d
commit dc02fbe33a

View File

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
import { Long } from "bson" import { Long } from "bson"
import { import {
AuthApiClient, AuthApiClient,
OAuthApiClient, OAuthApiClient,
@ -22,10 +23,10 @@ import {
KnownAuthStatusCode, KnownAuthStatusCode,
util, util,
} from "node-kakao" } from "node-kakao"
/** @typedef {import("node-kakao").OAuthCredential} OAuthCredential */
import chat from "node-kakao/chat" import chat from "node-kakao/chat"
const { KnownChatType } = chat const { KnownChatType } = chat
/** @typedef {import("node-kakao").OAuthCredential} OAuthCredential */
/** @typedef {import("./clientmanager.js").default} ClientManager} */
import { emitLines, promisify } from "./util.js" import { emitLines, promisify } from "./util.js"
@ -82,20 +83,21 @@ class UserClient {
export default class PeerClient { export default class PeerClient {
/** /**
* @param {ClientManager} manager * @param {import("./clientmanager.js").default} manager
* @param {import("net").Socket} socket * @param {import("net").Socket} socket
* @param {number} connID * @param {number} connID
* @param {Map<string, UserClient>} userClients
*/ */
constructor(manager, socket, connID) { constructor(manager, socket, connID) {
this.manager = manager this.manager = manager
this.socket = socket this.socket = socket
this.connID = connID this.connID = connID
this.stopped = false this.stopped = false
this.notificationID = 0 this.notificationID = 0
this.maxCommandID = 0 this.maxCommandID = 0
this.peerID = null this.peerID = null
/** @type {Map<string, UserClient>} */
this.userClients = new Map() this.userClients = new Map()
} }
@ -444,6 +446,7 @@ export default class PeerClient {
this.log("Ignoring old request", req.id) this.log("Ignoring old request", req.id)
return return
} }
this.log("Received request", req.id, "with command", req.command)
this.maxCommandID = req.id this.maxCommandID = req.id
let handler let handler
if (!this.peerID) { if (!this.peerID) {