Skip to content

Commit

Permalink
rename ActionheroClient to ActionheroWebsocketClient
Browse files Browse the repository at this point in the history
  • Loading branch information
evantahler committed Sep 30, 2017
1 parent cdc621c commit c9225f1
Show file tree
Hide file tree
Showing 95 changed files with 225 additions and 225 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ cache/*
coverage/*
node_modules/*
locales/test-env-*
public/javascript/actionheroClient.js
public/javascript/actionheroClient.min.js
public/javascript/ActionheroWebsocketClient.js
public/javascript/ActionheroWebsocketClient.min.js

#JSDoc
docs/out
Expand Down
2 changes: 1 addition & 1 deletion bin/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"standard": {
"ignore": [
"public/javascript/actionheroClient.*"
"public/javascript/ActionheroWebsocketClient.*"
],
"globals": [
"describe",
Expand Down
42 changes: 21 additions & 21 deletions client/actionheroClient.js → client/actionheroWebsocketClient.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var ActionheroClient = function (options, client) {
var ActionheroWebsocketClient = function (options, client) {
var self = this

self.callbacks = {}
Expand All @@ -21,20 +21,20 @@ var ActionheroClient = function (options, client) {
if (typeof Primus === 'undefined') {
var util = require('util')
var EventEmitter = require('events').EventEmitter
util.inherits(ActionheroClient, EventEmitter)
util.inherits(ActionheroWebsocketClient, EventEmitter)
} else {
ActionheroClient.prototype = new Primus.EventEmitter()
ActionheroWebsocketClient.prototype = new Primus.EventEmitter()
}

ActionheroClient.prototype.defaults = function () {
ActionheroWebsocketClient.prototype.defaults = function () {
%%DEFAULTS%%
}

// //////////////
// CONNECTION //
// //////////////

ActionheroClient.prototype.connect = function (callback) {
ActionheroWebsocketClient.prototype.connect = function (callback) {
var self = this
self.messageCount = 0

Expand Down Expand Up @@ -103,7 +103,7 @@ ActionheroClient.prototype.connect = function (callback) {
})
}

ActionheroClient.prototype.configure = function (callback) {
ActionheroWebsocketClient.prototype.configure = function (callback) {
var self = this

self.rooms.forEach(function (room) {
Expand All @@ -122,7 +122,7 @@ ActionheroClient.prototype.configure = function (callback) {
// MESSAGING //
// /////////////

ActionheroClient.prototype.send = function (args, callback) {
ActionheroWebsocketClient.prototype.send = function (args, callback) {
// primus will buffer messages when not connected
var self = this
self.messageCount++
Expand All @@ -132,7 +132,7 @@ ActionheroClient.prototype.send = function (args, callback) {
self.client.write(args)
}

ActionheroClient.prototype.handleMessage = function (message) {
ActionheroWebsocketClient.prototype.handleMessage = function (message) {
var self = this
self.emit('message', message)
if (message.context === 'response') {
Expand All @@ -156,7 +156,7 @@ ActionheroClient.prototype.handleMessage = function (message) {
// ACTIONS //
// ///////////

ActionheroClient.prototype.action = function (action, params, callback) {
ActionheroWebsocketClient.prototype.action = function (action, params, callback) {
if (!callback && typeof params === 'function') {
callback = params
params = null
Expand All @@ -171,7 +171,7 @@ ActionheroClient.prototype.action = function (action, params, callback) {
}
}

ActionheroClient.prototype.actionWeb = function (params, callback) {
ActionheroWebsocketClient.prototype.actionWeb = function (params, callback) {
var xmlhttp = new XMLHttpRequest()
xmlhttp.onreadystatechange = function () {
var response
Expand Down Expand Up @@ -204,31 +204,31 @@ ActionheroClient.prototype.actionWeb = function (params, callback) {
xmlhttp.send(JSON.stringify(params))
}

ActionheroClient.prototype.actionWebSocket = function (params, callback) {
ActionheroWebsocketClient.prototype.actionWebSocket = function (params, callback) {
this.send({event: 'action', params: params}, callback)
}

// ////////////
// COMMANDS //
// ////////////

ActionheroClient.prototype.say = function (room, message, callback) {
ActionheroWebsocketClient.prototype.say = function (room, message, callback) {
this.send({event: 'say', room: room, message: message}, callback)
}

ActionheroClient.prototype.file = function (file, callback) {
ActionheroWebsocketClient.prototype.file = function (file, callback) {
this.send({event: 'file', file: file}, callback)
}

ActionheroClient.prototype.detailsView = function (callback) {
ActionheroWebsocketClient.prototype.detailsView = function (callback) {
this.send({event: 'detailsView'}, callback)
}

ActionheroClient.prototype.roomView = function (room, callback) {
ActionheroWebsocketClient.prototype.roomView = function (room, callback) {
this.send({event: 'roomView', room: room}, callback)
}

ActionheroClient.prototype.roomAdd = function (room, callback) {
ActionheroWebsocketClient.prototype.roomAdd = function (room, callback) {
var self = this
self.send({event: 'roomAdd', room: room}, function (data) {
self.configure(function () {
Expand All @@ -237,7 +237,7 @@ ActionheroClient.prototype.roomAdd = function (room, callback) {
})
}

ActionheroClient.prototype.roomLeave = function (room, callback) {
ActionheroWebsocketClient.prototype.roomLeave = function (room, callback) {
var self = this
var index = self.rooms.indexOf(room)
if (index > -1) { self.rooms.splice(index, 1) }
Expand All @@ -248,16 +248,16 @@ ActionheroClient.prototype.roomLeave = function (room, callback) {
})
}

ActionheroClient.prototype.documentation = function (callback) {
ActionheroWebsocketClient.prototype.documentation = function (callback) {
this.send({event: 'documentation'}, callback)
}

ActionheroClient.prototype.disconnect = function () {
ActionheroWebsocketClient.prototype.disconnect = function () {
this.state = 'disconnected'
this.client.end()
this.emit('disconnected')
}

// depricated lowercase name
var actionheroClient = ActionheroClient;
actionheroClient;
var ActionheroWebsocketClient = ActionheroWebsocketClient;
ActionheroWebsocketClient;
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* Note that this class is not written using ES6 convestions so that it will function properly in the browser.
* Defaults will be built from the options you set in `api.config.servers.websocket`
*
* @class ActionHero.ActionHeroClient
* @class ActionHero.ActionheroWebsocketClient
*
* @tutorial websocket
* @example
// <script type="text/javascript" src="/public/javascript/actionheroClient.min.js"></script>
// <script type="text/javascript" src="/public/javascript/ActionheroWebsocketClient.min.js"></script>

var client = new ActionheroClient();
var client = new ActionheroWebsocketClient();

client.on('connected', function(){ console.log('connected!') })
client.on('disconnected', function(){ console.log('disconnected :(') })
Expand All @@ -34,25 +34,25 @@ client.connect(function(error, details){

/**
* @function connect
* @memberof ActionHero.ActionHeroClient
* @memberof ActionHero.ActionheroWebsocketClient
* @param {Function} callback When the connection is connected, will reurn (`error`, `details`), where details is the same as calling `client.detailsView()`.
* @description Connect to the ActionHero server. Will emit `welcome` when connected, and return the callback. Will aslo set `this.state`, `this.rooms`, `this.fingerprint`, and `this.id`. Clients will automatically try to reconect, unless prevented with `client.disconnect()`
* @see ActionHero.ActionHeroClient.detailsView
* @see ActionHero.ActionHeroClient.disconnect
* @see ActionHero.ActionheroWebsocketClient.detailsView
* @see ActionHero.ActionheroWebsocketClient.disconnect
*/

/**
* @function configure
* @memberof ActionHero.ActionHeroClient
* @memberof ActionHero.ActionheroWebsocketClient
* @param {Function} callback Will reurn (`error`, `details`), where details is the same as calling `client.detailsView()`.
* @description Will set `this.state`, `this.rooms`, `this.fingerprint`, and `this.id`. You should only need this method if you are having connection errors.
* @see ActionHero.ActionHeroClient.detailsView
* @see ActionHero.ActionheroWebsocketClient.detailsView
*/


/**
* @function action
* @memberof ActionHero.ActionHeroClient
* @memberof ActionHero.ActionheroWebsocketClient
* @param {string} action The name of the action to run.
* @param {Object} params (optional) (default: {}). Any params to pass to the action.
* @param {Function} callback Will reurn (`data`) (no error!). The client will emit `error` if there is a connection error, otherwise any errors from the action will be contained within `data.error`.
Expand All @@ -73,17 +73,17 @@ client.action('cacheTest', {key: 'key', value: 'value'}, function (data) {

/**
* @function say
* @memberof ActionHero.ActionHeroClient
* @memberof ActionHero.ActionheroWebsocketClient
* @param {string} room The room to chat in. Client must be a member of room already via `client.roomAdd()`
* @param {Object|string} message The message to send. Can be a string, Object, or Array.
* @param {Function} callback Will reurn (`data`), where `data.OK` will exist.
* @description Say a message to a chatRoom the connection is a member of.
* @see ActionHero.ActionHeroClient.roomAdd
* @see ActionHero.ActionheroWebsocketClient.roomAdd
*/

/**
* @function file
* @memberof ActionHero.ActionHeroClient
* @memberof ActionHero.ActionheroWebsocketClient
* @param {string} file The file requeted. The file should look like a the path from a browser, ie: `/public/name/of/file.jpg`
* @param {Function} callback Will reurn (`data`), where the file's contents and medadata will be included. Likley a large payload.
* @description Request a public file from the server.
Expand All @@ -102,50 +102,50 @@ client.file('/public/simple.html', function(data) {

/**
* @function detailsView
* @memberof ActionHero.ActionHeroClient
* @memberof ActionHero.ActionheroWebsocketClient
* @param {Function} callback Will reurn (`data`), where data contains the connections details (fingerprint, connection time, etc)
* @description View the server's details about this connection.
*/

/**
* @function documentation
* @memberof ActionHero.ActionHeroClient
* @memberof ActionHero.ActionheroWebsocketClient
* @param {Function} callback Will reurn (`data`), where data conatins the results of `api.documentation.documentation`, details of all documented actions on the server.
* @description View details of this server's actions.
*/

/**
* @function disconnect
* @memberof ActionHero.ActionHeroClient
* @memberof ActionHero.ActionheroWebsocketClient
* @param {Function} callback
* @description Close the client connection. Will prevent any re-connects from attempting.
* @see ActionHero.ActionHeroClient.connect
* @see ActionHero.ActionheroWebsocketClient.connect
*/

/**
* @function roomView
* @memberof ActionHero.ActionHeroClient
* @memberof ActionHero.ActionheroWebsocketClient
* @param {string} room The room to inspect. Client must be a member of room already via `client.roomAdd()`
* @param {Function} callback Will reurn (`data`), where data contains a list of other members in the room.
* @description View the other members of a room.
* @see ActionHero.ActionHeroClient.roomAdd
* @see ActionHero.ActionHeroClient.roomLeave
* @see ActionHero.ActionheroWebsocketClient.roomAdd
* @see ActionHero.ActionheroWebsocketClient.roomLeave
*/

/**
* @function roomAdd
* @memberof ActionHero.ActionHeroClient
* @memberof ActionHero.ActionheroWebsocketClient
* @param {string} room The room to join.
* @param {Function} callback Will reurn (`data`), where data contains errors and success.
* @description Join an existing chat room. You may not be able to join this room (based on connection properties or other configuration on the server, so check for `data.error`). Once in the room, you will recive all say messages from the room as events.
* @see ActionHero.ActionHeroClient.roomLeave
* @see ActionHero.ActionheroWebsocketClient.roomLeave
*/

/**
* @function roomLeave
* @memberof ActionHero.ActionHeroClient
* @memberof ActionHero.ActionheroWebsocketClient
* @param {string} room The room to leave.
* @param {Function} callback Will reurn (`data`), where data contains errors and success.
* @description LEave a chat room you are already a member of. You may not be able to leave this room (based on connection properties or other configuration on the server, so check for `data.error`)
* @see ActionHero.ActionHeroClient.roomAddd
* @see ActionHero.ActionheroWebsocketClient.roomAddd
*/
2 changes: 1 addition & 1 deletion config/servers/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports['default'] = {
// the name of the client-side JS file to render. Both `.js` and `.min.js` versions will be created
// do not include the file exension
// set to `undefined` to not render the client-side JS on boot
clientJsName: 'actionheroClient',
clientJsName: 'ActionheroWebsocketClient',
// should the server signal clients to not reconnect when the server is shutdown/reboot
destroyClientsOnShutdown: false,

Expand Down
2 changes: 1 addition & 1 deletion docs/ActionHero.Action.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<img id="nav-logo" src="https://raw.github.com/actionhero/actionhero/master/public/logo/actionhero-small.png" />
</a>
</div>
<h3>Classes</h3><ul><li><a href="ActionHero.html">ActionHero</a></li><li><a href="ActionHero.Action.html">Action</a></li><li><a href="ActionHero.ActionHeroClient.html">ActionHeroClient</a></li><li><a href="ActionHero.CLI.html">CLI</a></li><li><a href="ActionHero.Connection.html">Connection</a></li><li><a href="ActionHero.Initializer.html">Initializer</a></li><li><a href="ActionHero.Server.html">Server</a></li><li><a href="ActionHero.Task.html">Task</a></li><li><a href="api.specHelper.Connection.html">Connection</a></li></ul><h3>Namespaces</h3><ul><li><a href="api.html">api</a></li><li><a href="api.actions.html">actions</a></li><li><a href="api.cache.html">cache</a></li><li><a href="api.chatRoom.html">chatRoom</a></li><li><a href="api.config.html">config</a></li><li><a href="api.connections.html">connections</a></li><li><a href="api.documentation.html">documentation</a></li><li><a href="api.exceptions.html">exceptions</a></li><li><a href="api.i18n.html">i18n</a></li><li><a href="api.id.html">id</a></li><li><a href="api.params.html">params</a></li><li><a href="api.pids.html">pids</a></li><li><a href="api.redis.html">redis</a></li><li><a href="api.resque.html">resque</a></li><li><a href="api.routes.html">routes</a></li><li><a href="api.servers.html">servers</a></li><li><a href="api.specHelper.html">specHelper</a></li><li><a href="api.staticFile.html">staticFile</a></li><li><a href="api.tasks.html">tasks</a></li><li><a href="api.utils.html">utils</a></li></ul><h3>Tutorials</h3><ul><li><a href="tutorial-actionhero-cluster.html">actionhero-cluster</a></li><li><a href="tutorial-actions.html">actions</a></li><li><a href="tutorial-chat.html">chat</a></li><li><a href="tutorial-cli.html">cli</a></li><li><a href="tutorial-config.html">config</a></li><li><a href="tutorial-development-mode.html">development-mode</a></li><li><a href="tutorial-file-server.html">file-server</a></li><li><a href="tutorial-initializers.html">initializers</a></li><li><a href="tutorial-localization.html">localization</a></li><li><a href="tutorial-logging.html">logging</a></li><li><a href="tutorial-middleware.html">middleware</a></li><li><a href="tutorial-plugins.html">plugins</a></li><li><a href="tutorial-production-notes.html">production-notes</a></li><li><a href="tutorial-running-actionhero.html">running-actionhero</a></li><li><a href="tutorial-servers.html">servers</a></li><li><a href="tutorial-socket.html">socket</a></li><li><a href="tutorial-tasks.html">tasks</a></li><li><a href="tutorial-testing.html">testing</a></li><li><a href="tutorial-upgrade-path.html">upgrade-path</a></li><li><a href="tutorial-web.html">web</a></li><li><a href="tutorial-websocket.html">websocket</a></li></ul>
<h3>Classes</h3><ul><li><a href="ActionHero.html">ActionHero</a></li><li><a href="ActionHero.Action.html">Action</a></li><li><a href="ActionHero.ActionheroWebsocketClient.html">ActionheroWebsocketClient</a></li><li><a href="ActionHero.CLI.html">CLI</a></li><li><a href="ActionHero.Connection.html">Connection</a></li><li><a href="ActionHero.Initializer.html">Initializer</a></li><li><a href="ActionHero.Server.html">Server</a></li><li><a href="ActionHero.Task.html">Task</a></li><li><a href="api.specHelper.Connection.html">Connection</a></li></ul><h3>Namespaces</h3><ul><li><a href="api.html">api</a></li><li><a href="api.actions.html">actions</a></li><li><a href="api.cache.html">cache</a></li><li><a href="api.chatRoom.html">chatRoom</a></li><li><a href="api.config.html">config</a></li><li><a href="api.connections.html">connections</a></li><li><a href="api.documentation.html">documentation</a></li><li><a href="api.exceptions.html">exceptions</a></li><li><a href="api.i18n.html">i18n</a></li><li><a href="api.id.html">id</a></li><li><a href="api.params.html">params</a></li><li><a href="api.pids.html">pids</a></li><li><a href="api.redis.html">redis</a></li><li><a href="api.resque.html">resque</a></li><li><a href="api.routes.html">routes</a></li><li><a href="api.servers.html">servers</a></li><li><a href="api.specHelper.html">specHelper</a></li><li><a href="api.staticFile.html">staticFile</a></li><li><a href="api.tasks.html">tasks</a></li><li><a href="api.utils.html">utils</a></li></ul><h3>Tutorials</h3><ul><li><a href="tutorial-actionhero-cluster.html">actionhero-cluster</a></li><li><a href="tutorial-actions.html">actions</a></li><li><a href="tutorial-chat.html">chat</a></li><li><a href="tutorial-cli.html">cli</a></li><li><a href="tutorial-config.html">config</a></li><li><a href="tutorial-development-mode.html">development-mode</a></li><li><a href="tutorial-file-server.html">file-server</a></li><li><a href="tutorial-initializers.html">initializers</a></li><li><a href="tutorial-localization.html">localization</a></li><li><a href="tutorial-logging.html">logging</a></li><li><a href="tutorial-middleware.html">middleware</a></li><li><a href="tutorial-plugins.html">plugins</a></li><li><a href="tutorial-production-notes.html">production-notes</a></li><li><a href="tutorial-running-actionhero.html">running-actionhero</a></li><li><a href="tutorial-servers.html">servers</a></li><li><a href="tutorial-socket.html">socket</a></li><li><a href="tutorial-tasks.html">tasks</a></li><li><a href="tutorial-testing.html">testing</a></li><li><a href="tutorial-upgrade-path.html">upgrade-path</a></li><li><a href="tutorial-web.html">web</a></li><li><a href="tutorial-websocket.html">websocket</a></li></ul>
</nav>

<div id="main">
Expand Down
Loading

0 comments on commit c9225f1

Please sign in to comment.