Starting work on private messaging back-end.
This commit is contained in:
parent
1384b02f4d
commit
d541dce8c4
51
src/app/pm/pmHandler.js
Normal file
51
src/app/pm/pmHandler.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024-2025 Rainbownapkin and the TTN Community
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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/>.*/
|
||||
|
||||
//local includes
|
||||
const config = require("../../../config.json");
|
||||
const csrfUtils = require("../../utils/csrfUtils");
|
||||
const userBanModel = require("../../schemas/user/userBanSchema");
|
||||
|
||||
/**
|
||||
* Class containg global server-side private message relay logic
|
||||
*/
|
||||
class pmHandler{
|
||||
/**
|
||||
* Instantiates object containing global server-side private message relay logic
|
||||
* @param {Socket.io} io - Socket.io server instanced passed down from server.js
|
||||
*/
|
||||
constructor(io){
|
||||
/**
|
||||
* Socket.io server instance passed down from server.js
|
||||
*/
|
||||
this.io = io;
|
||||
|
||||
/**
|
||||
* Socket.io server namespace for handling messaging
|
||||
*/
|
||||
this.namespace = io.of('/pm');
|
||||
|
||||
//Handle connections from private messaging namespace
|
||||
this.namespace.on("connection", this.handleConnection.bind(this) );
|
||||
}
|
||||
|
||||
async handleConnection(socket){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = pmHandler;
|
||||
|
|
@ -33,6 +33,7 @@ const mongoose = require('mongoose');
|
|||
//Define Local Imports
|
||||
//Application
|
||||
const channelManager = require('./app/channel/channelManager');
|
||||
const pmHandler = require('./app/pm/pmHandler');
|
||||
//Util
|
||||
const configCheck = require('./utils/configCheck');
|
||||
const scheduler = require('./utils/scheduler');
|
||||
|
|
@ -196,6 +197,7 @@ scheduler.kickoff();
|
|||
|
||||
//Hand over general-namespace socket.io connections to the channel manager
|
||||
module.exports.channelManager = new channelManager(io)
|
||||
module.exports.pmHandler = new pmHandler(io)
|
||||
|
||||
//Listen Function
|
||||
webServer.listen(port, () => {
|
||||
|
|
|
|||
|
|
@ -68,12 +68,15 @@ class channel{
|
|||
* Handles initial client connection
|
||||
*/
|
||||
connect(){
|
||||
this.socket = io({
|
||||
const clientOptions = {
|
||||
extraHeaders: {
|
||||
//Include CSRF token
|
||||
'x-csrf-token': utils.ajax.getCSRFToken()
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.socket = io(clientOptions);
|
||||
this.pmSocket = io("/pm", clientOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue