Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@afocommunity/eco.js

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@afocommunity/eco.js - npm Package Compare versions

Comparing version 0.0.1-alpha.1 to 0.0.1-alpha.2

1

lib/Core/Controllers/ChatController.d.ts

@@ -55,2 +55,3 @@ import { IChatMessage, ChatMessage } from "../../structures/Eco/Web/Core/DataTransferObjects/V1/ChatMessage";

sendChat(receiver: string | IUser, sender: string | IUser, text: string): Promise<unknown>;
_parse(input: string): ChatMessage;
}

@@ -70,3 +70,6 @@ "use strict";

}
_parse(input) {
throw 'Not Yet Implemented';
}
}
exports.ChatController = ChatController;

@@ -0,4 +1,8 @@

/// <reference types="node" />
/// <reference types="node" />
import { EventEmitter } from 'stream';
import { ServerInfo } from "../structures/Eco/Shared/Networking/ServerInfo";
import { AdminController, ChatController, CommandController, DataExportController, ElectionController, LawController, LogController, MapController, PluginsController, ProfilingResultsController, RootController, StatsController, UsersController, WorldLayerController } from "./Controllers/index";
import { HttpClient } from "./HttpClient";
import { ChatMessage } from '../structures/Eco/Web/Core/DataTransferObjects/V1/ChatMessage';
type EcoClientOptions = {

@@ -26,2 +30,6 @@ /**

serverVirtualPlayerName?: string;
/**
*
*/
chatInterval?: number;
};

@@ -50,3 +58,8 @@ /**

isReady: Promise<void>;
private _startDate;
protected _startDate: Date;
protected _chatFetched: boolean;
protected _chatReadInterval: NodeJS.Timer;
protected _chatReadIntervalMS: number;
protected _messages: ChatMessage[];
events: EventEmitter;
constructor(options: EcoClientOptions);

@@ -61,3 +74,5 @@ /**

convertDateToDuration(date: Date): number;
setupChatInterval(): void;
checkForNewChats(): Promise<boolean>;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const stream_1 = require("stream");
const index_1 = require("./Controllers/index");

@@ -28,2 +29,7 @@ const HttpClient_1 = require("./HttpClient");

_startDate = new Date(0);
_chatFetched = false;
_chatReadInterval;
_chatReadIntervalMS;
_messages;
events = new stream_1.EventEmitter;
constructor(options) {

@@ -36,2 +42,7 @@ this.serverVirtualPlayerName =

});
Object.defineProperty(this, "_messages", {
enumerable: false,
value: [],
});
this._chatReadIntervalMS = options.chatInterval ?? 8000;
this.isReady = new Promise((async (res) => {

@@ -44,4 +55,6 @@ this.root.info().then((info) => {

});
this.setupChatInterval();
//Finished
res();
this.events.emit('ready');
});

@@ -62,3 +75,26 @@ }).bind(this));

}
setupChatInterval() {
clearInterval(this._chatReadInterval);
this._chatReadInterval = null;
if (this._chatReadIntervalMS == 0)
return;
this._chatReadInterval = setInterval(this.checkForNewChats.bind(this), this._chatReadIntervalMS);
}
async checkForNewChats() {
if (!this._chatFetched) {
const tmessages = await this.chat.getChat();
this._messages.push(...tmessages);
this._chatFetched = true;
}
return this.chat.getChat()
.then(messagesRaw => {
const messages = messagesRaw.slice(this._messages.length);
for (const message of messages) {
this.events.emit('NEW_MESSAGE', message);
this._messages.push(message);
}
return true;
}).catch(() => false);
}
}
exports.default = ECO;

@@ -16,2 +16,3 @@ import ECO from "../../../../../../Core/ECO";

get timestampDate(): Date;
toString(): string;
}

@@ -20,3 +20,11 @@ "use strict";

}
toString() {
try {
return `[${this.timestampDate.toISOString().replace(/[TZ]/g, ' ').trim()}] ${this.Sender}: ${this.Text}`;
}
catch (error) {
return `${this.Sender}: ${this.Text}`;
}
}
}
exports.ChatMessage = ChatMessage;

2

package.json
{
"name": "@afocommunity/eco.js",
"version": "0.0.1-alpha.1",
"version": "0.0.1-alpha.2",
"main": "./lib/index.js",

@@ -5,0 +5,0 @@ "types": "./lib/index.d.ts",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc