Namespace RailgunServer
A wrapper object for all Railgun server methods. The main method is processRequest(), which is the server's message event handler. The event handler delegates various client requests to the other methods in the namespace.
- Defined in: RailgunServer.js
Method Summary
Method Attributes | Method Name and Description |
---|---|
<static> | RailgunServer.getItem(key) Retrieves a single item from localStorage. |
<static> | RailgunServer.processRequest(event) The Railgun server's message event listener which processes requests made by the Railgun client. |
<static> | RailgunServer.reset() Removes all items from localStorage associated with native list of keys. |
<static> | RailgunServer.retrieve() Retrieves all items from localStorage associated with the native list of keys. |
<static> | RailgunServer.setItem(key, value) Associates a value with a given key in localStorage. |
Field Detail
<static> {Boolean}RailgunServer.isDebug
true
if the server is in debug mode, false
otherwise- Default Value:
- false
<static> {Array}RailgunServer.keys
A list of keys associated with localStorage data.
- Default Value:
- ["friends", "siderailHidden"]
<static> {String}RailgunServer.version
The version of the Railgun server source code.
Method Detail
- <static> RailgunServer.getItem(key)Retrieves a single item from localStorage.
- Parameters:
- {String} key
- the key to query localStorage for
- Returns:
- the JSON.parsed value associated with the given key
- <static> RailgunServer.processRequest(event)The Railgun server's message event listener which processes requests made by the Railgun client. This method reads instructions from the client, delegates the task to an appropriate method, and then sends the server's response back to the client. To make a request, the client must send the server a JSON.stringified request object with instruction, key and value properties:
{ instruction : "setItem", key : "siderailHidden", value : true }
- Parameters:
- {MessageEvent} event
- an event corresponding to a postMessage request made by the client
- <static> RailgunServer.reset()Removes all items from localStorage associated with native list of keys.
- <static> {Object}RailgunServer.retrieve()Retrieves all items from localStorage associated with the native list of keys.
- Returns:
- {Object} a mapping of (key, value) pairs in localStorage
- See:
- RailgunServer.keys
- <static> {Boolean}RailgunServer.setItem(key, value)Associates a value with a given key in localStorage.
- Parameters:
- {String} key
- a key to associate with the given value
- value
- some value of arbitrary type to be stored
- Returns:
- {Boolean}
true
if the operation was successful false
otherwise