Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/aphlict/Aphlict.js
| Show All 19 Lines | |||||
| * - `close` The client disconnected from the server. | * - `close` The client disconnected from the server. | ||||
| * - `error` There was an error. | * - `error` There was an error. | ||||
| * - `receive` Received a message from the server. | * - `receive` Received a message from the server. | ||||
| * | * | ||||
| * You do not have to handle any of them in any specific way. | * You do not have to handle any of them in any specific way. | ||||
| */ | */ | ||||
| JX.install('Aphlict', { | JX.install('Aphlict', { | ||||
| construct : function(id, server, port) { | construct : function(id, server, port, subscriptions) { | ||||
| if (__DEV__) { | if (__DEV__) { | ||||
| if (JX.Aphlict._instance) { | if (JX.Aphlict._instance) { | ||||
| JX.$E('Aphlict object is sort of a singleton..!'); | JX.$E('Aphlict object is sort of a singleton..!'); | ||||
| } | } | ||||
| } | } | ||||
| JX.Aphlict._instance = this; | JX.Aphlict._instance = this; | ||||
| this._server = server; | this._server = server; | ||||
| this._port = port; | this._port = port; | ||||
| this._subscriptions = subscriptions; | |||||
| // Flash puts its "objects" into global scope in an inconsistent way, | // Flash puts its "objects" into global scope in an inconsistent way, | ||||
| // because it was written in like 1816 when globals were awesome and IE4 | // because it was written in like 1816 when globals were awesome and IE4 | ||||
| // didn't support other scopes since global scope is the best anyway. | // didn't support other scopes since global scope is the best anyway. | ||||
| var container = document[id] || window[id]; | var container = document[id] || window[id]; | ||||
| this._flashContainer = container; | this._flashContainer = container; | ||||
| }, | }, | ||||
| members : { | members : { | ||||
| _server : null, | _server : null, | ||||
| _port : null, | _port : null, | ||||
| _subscriptions : null, | |||||
| start : function() { | start : function() { | ||||
| this._flashContainer.connect(this._server, this._port); | this._flashContainer.connect( | ||||
| this._server, | |||||
| this._port, | |||||
| this._subscriptions); | |||||
| } | } | ||||
joshuaspence: Should this be moved into a `this._flashContainer.subscribe` call? Will a client ever need to… | |||||
Not Done Inline ActionsI don't have any plans which would require this. epriestley: I don't have any plans which would require this. | |||||
| }, | }, | ||||
| properties : { | properties : { | ||||
| handler : null | handler : null | ||||
| }, | }, | ||||
| statics : { | statics : { | ||||
| _instance : null, | _instance : null, | ||||
| Show All 13 Lines | |||||
Should this be moved into a this._flashContainer.subscribe call? Will a client ever need to change its subscriptions after being instantiated?