program finalizat
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
export let operationCodes = {
|
||||
// General Operations
|
||||
HEARTBEAT: 'HEARTBEAT',
|
||||
ALIVE: 'ALIVE',
|
||||
SET_PUBLIC_KEY: 'SET_PUBLIC_KEY',
|
||||
@@ -9,20 +10,23 @@ export let operationCodes = {
|
||||
END: 'END',
|
||||
UNKNOWN_COMMAND: 'UNKNOWN_COMMAND',
|
||||
|
||||
// Auth Operations
|
||||
LOGIN: 'LOGIN',
|
||||
SIGN_UP: 'SIGN_UP',
|
||||
RESET_PASSWORD: 'RESET_PASSWORD',
|
||||
|
||||
FIND_BY_EMAIL: 'FIND_BY_EMAIL',
|
||||
MODIFY_USER: 'MODIFY_USER',
|
||||
|
||||
GET_DEPARTMENTS: 'GET_DEPARTMENTS',
|
||||
CREATE_DEPARTMENT: 'CREATE_DEPARTMENT',
|
||||
MODIFY_DEPARTMENT: 'MODIFY_DEPARTMENT',
|
||||
DELETE_DEPARTMENT: 'DELETE_DEPARTMENT',
|
||||
|
||||
GET_USERS: 'GET_USERS',
|
||||
DELETE_USER: 'DELETE_USER',
|
||||
FIND_KEY_BY_USER_ID: 'FIND_KEY_BY_USER_ID',
|
||||
FIND_BY_EMAIL: 'FIND_BY_EMAIL',
|
||||
MODIFY_USER: 'MODIFY_USER',
|
||||
DELETE_USER: 'DELETE_USER',
|
||||
SEND_ANNOUNCEMENT: 'SEND_ANNOUNCEMENT',
|
||||
|
||||
GET_USER_INFORMATION: 'GET_USER_INFORMATION',
|
||||
CLEAR_BACKUP: 'CLEAR_BACKUP',
|
||||
|
||||
@@ -12,19 +12,16 @@ export abstract class OperationBase implements OperationPlugin {
|
||||
|
||||
// Default handler for OK operation
|
||||
public static handleOk(parsedMessage: ParsedMessage): ParsedMessage {
|
||||
console.log('OK operation received');
|
||||
return parsedMessage; // Typically, you would just acknowledge with OK, returning as-is
|
||||
}
|
||||
|
||||
// Default handler for ERR operation
|
||||
public static handleErr(parsedMessage: ParsedMessage): ParsedMessage {
|
||||
console.log('ERR operation received: ', parsedMessage.metaInfo?.message || 'No error details provided');
|
||||
return parsedMessage; // Typically, you would log the error and return
|
||||
}
|
||||
|
||||
// Default handler for END operation
|
||||
public static handleEnd(parsedMessage: ParsedMessage): ParsedMessage {
|
||||
console.log('END operation received');
|
||||
return {
|
||||
operationCode: OperationBase.operationCodes.END,
|
||||
metaInfo: { message: 'Connection ended.' },
|
||||
|
||||
@@ -137,8 +137,6 @@ export class TcpClientCommunicator extends SocketCommunicatorBase {
|
||||
messageToProcess = this.decryptWithRsa(incomingMessage);
|
||||
}
|
||||
|
||||
console.log(`\n\nComplete Message:\n${messageToProcess}\n\n`);
|
||||
|
||||
const result = this.operationHandler.handleOperation(messageToProcess);
|
||||
|
||||
if(result.operationCode === operationCodes.SET_AES_KEY){
|
||||
|
||||
@@ -80,9 +80,6 @@ export class TcpClient {
|
||||
|
||||
// Check if the message is received (based on if lastResult is available)
|
||||
isMessageReceived(): boolean {
|
||||
console.log('Is message received?');
|
||||
console.log(this.lastResult);
|
||||
console.log(this.lastResult !== null);
|
||||
return this.lastResult !== null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user