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

chat-engine

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chat-engine - npm Package Compare versions

Comparing version 0.1.14 to 0.2.0

dist/chat-engine.js

2

gulpfile.js

@@ -13,3 +13,3 @@ const gulp = require('gulp');

.bundle()
.pipe(source('ocf.js'))
.pipe(source('chat-engine.js'))
.pipe(gulp.dest('./dist/'));

@@ -16,0 +16,0 @@

{
"author": "Ian Jennings",
"name": "ocf",
"name": "chat-engine",
"version": "0.1.14",
"version": "0.2.0",
"description": "Open Chat Framework",

@@ -13,3 +14,3 @@ "main": "src/index.js",

"type": "git",
"url": "git+https://github.com/pubnub/open-chat-framework.git"
"url": "git+https://github.com/pubnub/chat-engine.git"
},

@@ -24,5 +25,5 @@ "keywords": [

"bugs": {
"url": "https://github.com/pubnub/open-chat-framework/issues"
"url": "https://github.com/pubnub/chat-engine/issues"
},
"homepage": "https://github.com/pubnub/open-chat-framework#readme",
"homepage": "https://github.com/pubnub/chat-engine#readme",
"devDependencies": {

@@ -29,0 +30,0 @@ "browserify": "^13.1.0",

"use strict";
// Allows us to create and bind to events. Everything in OCF is an event
// Allows us to create and bind to events. Everything in ChatEngine is an event
// emitter

@@ -13,3 +13,3 @@ const EventEmitter2 = require('eventemitter2').EventEmitter2;

/**
* Global object used to create an instance of OCF.
* Global object used to create an instance of ChatEngine.
*

@@ -19,13 +19,13 @@ * @class OpenChatFramework

* @param {Object} foo Argument 1
* @param config.pubnub {Object} OCF is based off PubNub. Supply your PubNub config here.
* @param config.pubnub {Object} ChatEngine is based off PubNub. Supply your PubNub config here.
* @param config.globalChannel {String} his is the global channel that all clients are connected to automatically. It's used for global announcements, global presence, etc.
* @return {Object} Returns an instance of OCF
* @return {Object} Returns an instance of ChatEngine
*/
const create = function(pnConfig, globalChannel = 'ocf-global') {
const create = function(pnConfig, globalChannel = 'chat-engine') {
let OCF = false;
let ChatEngine = false;
/**
* Configures an event emitter that other OCF objects inherit. Adds shortcut methods for
* Configures an event emitter that other ChatEngine objects inherit. Adds shortcut methods for
* ```this.on()```, ```this.emit()```, etc.

@@ -101,3 +101,3 @@ *

OCF.pubnub.publish({
ChatEngine.pubnub.publish({
message: m,

@@ -117,7 +117,7 @@ channel: this.channel

OCF.pubnub.addListener({
ChatEngine.pubnub.addListener({
message: this.onMessage
});
OCF.pubnub.subscribe({
ChatEngine.pubnub.subscribe({
channels: [this.channel],

@@ -132,3 +132,3 @@ withPresence: true

/**
* An OCF generic emitter that supports plugins and forwards
* An ChatEngine generic emitter that supports plugins and forwards
* events to a global emitter.

@@ -149,5 +149,5 @@ *

// all events are forwarded to OCF object
// so you can globally bind to events with OCF.on()
OCF._emit(event, data);
// all events are forwarded to ChatEngine object
// so you can globally bind to events with ChatEngine.on()
ChatEngine._emit(event, data);

@@ -175,6 +175,6 @@ // emit the event from the object that created it

// under their namespace
OCF.addChild(this, module.namespace,
ChatEngine.addChild(this, module.namespace,
new module.extends[className]);
this[module.namespace].OCF = OCF;
this[module.namespace].ChatEngine = ChatEngine;

@@ -275,3 +275,3 @@ // if the plugin has a special construct function

OCF.pubnub.history(config, (status, response) => {
ChatEngine.pubnub.history(config, (status, response) => {

@@ -340,3 +340,3 @@ if(response.error) {

OCF.pubnub.addListener({
ChatEngine.pubnub.addListener({
status: this.onStatus,

@@ -347,3 +347,3 @@ message: this.onMessage,

OCF.pubnub.subscribe({
ChatEngine.pubnub.subscribe({
channels: [this.channel],

@@ -355,3 +355,3 @@ withPresence: true

// ask PubNub for information about connected users in this channel
OCF.pubnub.hereNow({
ChatEngine.pubnub.hereNow({
channels: [this.channel],

@@ -378,3 +378,3 @@ includeUUIDs: true,

data: data, // the data supplied from params
sender: OCF.me.uuid, // my own uuid
sender: ChatEngine.me.uuid, // my own uuid
chat: this, // an instance of this chat

@@ -422,4 +422,4 @@ };

// turn a uuid found in payload.sender to a real user
if(payload.sender && OCF.users[payload.sender]) {
payload.sender = OCF.users[payload.sender];
if(payload.sender && ChatEngine.users[payload.sender]) {
payload.sender = ChatEngine.users[payload.sender];
}

@@ -454,6 +454,6 @@

// so we can reference it from here out
OCF.users[uuid] = OCF.users[uuid] || new User(uuid);
ChatEngine.users[uuid] = ChatEngine.users[uuid] || new User(uuid);
// Add this chatroom to the user's list of chats
OCF.users[uuid].addChat(this, state);
ChatEngine.users[uuid].addChat(this, state);

@@ -470,3 +470,3 @@ // trigger the join event over this chatroom

this.trigger('$ocf.online', {
user: OCF.users[uuid]
user: ChatEngine.users[uuid]
});

@@ -477,6 +477,6 @@

// store this user in the chatroom
this.users[uuid] = OCF.users[uuid];
this.users[uuid] = ChatEngine.users[uuid];
// return the instance of this user
return OCF.users[uuid];
return ChatEngine.users[uuid];

@@ -496,3 +496,3 @@ }

// ensure the user exists within the global space
OCF.users[uuid] = OCF.users[uuid] || new User(uuid);
ChatEngine.users[uuid] = ChatEngine.users[uuid] || new User(uuid);

@@ -529,3 +529,3 @@ // if we don't know about this user

OCF.pubnub.unsubscribe({
ChatEngine.pubnub.unsubscribe({
channels: [this.channel]

@@ -651,3 +651,3 @@ });

OCF.pubnub.setState(
ChatEngine.pubnub.setState(
{

@@ -675,3 +675,3 @@ state: state,

constructor(uuid, state = {}, chat = OCF.globalChat) {
constructor(uuid, state = {}, chat = ChatEngine.globalChat) {

@@ -713,3 +713,3 @@ super();

this.feed = new Chat(
[OCF.globalChat.channel, uuid, 'feed'].join('.'));
[ChatEngine.globalChat.channel, uuid, 'feed'].join('.'));

@@ -725,8 +725,8 @@ /**

this.direct = new Chat(
[OCF.globalChat.channel, uuid, 'direct'].join('.'));
[ChatEngine.globalChat.channel, uuid, 'direct'].join('.'));
// if the user does not exist at all and we get enough
// information to build the user
if(!OCF.users[uuid]) {
OCF.users[uuid] = this;
if(!ChatEngine.users[uuid]) {
ChatEngine.users[uuid] = this;
}

@@ -745,3 +745,3 @@

*/
state(chat = OCF.globalChat) {
state(chat = ChatEngine.globalChat) {
return this.states[chat.channel] || {};

@@ -757,3 +757,3 @@ }

*/
update(state, chat = OCF.globalChat) {
update(state, chat = ChatEngine.globalChat) {
let chatState = this.state(chat) || {};

@@ -793,3 +793,3 @@ this.states[chat.channel] = Object.assign(chatState, state);

* Has the ability to update it's state on the network. An instance of
* {{#crossLink "Me"}}{{/crossLink}} is returned by the ```OCF.connect()```
* {{#crossLink "Me"}}{{/crossLink}} is returned by the ```ChatEngine.connect()```
* method.

@@ -825,5 +825,5 @@ *

* @param {Chat} chat An instance of the {{#crossLink "Chat"}}{{/crossLink}} where state will be updated.
* Defaults to ```OCF.globalChat```.
* Defaults to ```ChatEngine.globalChat```.
*/
update(state, chat = OCF.globalChat) {
update(state, chat = ChatEngine.globalChat) {

@@ -843,20 +843,20 @@ // run the root update function

*
* @class OCF
* @class ChatEngine
*/
const init = function() {
// Create the root OCF object
OCF = new RootEmitter;
// Create the root ChatEngine object
ChatEngine = new RootEmitter;
// create a global list of known users
OCF.users = {};
ChatEngine.users = {};
// define our global chatroom all users join by default
OCF.globalChat = false;
ChatEngine.globalChat = false;
// define the user that this client represents
OCF.me = false;
ChatEngine.me = false;
// store a reference to PubNub
OCF.pubnub = false;
ChatEngine.pubnub = false;

@@ -871,3 +871,3 @@ /**

*/
OCF.connect = function(uuid, state = {}) {
ChatEngine.connect = function(uuid, state = {}) {

@@ -896,3 +896,3 @@ // this creates a user known as Me and

// client can access globalChat through OCF.globalChat
// client can access globalChat through ChatEngine.globalChat

@@ -902,7 +902,7 @@ };

// our exported classes
OCF.Chat = Chat;
OCF.User = User;
ChatEngine.Chat = Chat;
ChatEngine.User = User;
// add an object as a subobject under a namespoace
OCF.addChild = (ob, childName, childOb) => {
ChatEngine.addChild = (ob, childName, childOb) => {

@@ -919,7 +919,7 @@ // assign the new child object as a property of parent under the

return OCF;
return ChatEngine;
}
// return an instance of OCF
// return an instance of ChatEngine
return init();

@@ -929,3 +929,3 @@

// export the OCF api
// export the ChatEngine api
module.exports = {

@@ -932,0 +932,0 @@ plugin: {}, // leave a spot for plugins to exist

@@ -1,1 +0,1 @@

window.OpenChatFramework = window.OpenChatFramework || require('./index.js');
window.ChatEngineCore = window.ChatEngineCore || require('./index.js');

@@ -131,4 +131,2 @@ "use strict";

console.log(historychat2)
historychat2.once("$history.message", (message) => {

@@ -135,0 +133,0 @@ assert.isOk(message);

{
"name": "OpenChatFramework",
"name": "ChatEngine",
"version": "0.0.1",

@@ -4,0 +4,0 @@ "options": {

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