Phaser. Net

new Net(game)

Phaser.Net handles browser URL related tasks such as checking host names, domain names and query string manipulation.

Name Type Description
game Phaser.Game

A reference to the currently running game.

Source code: net/Net.js (Line 14)

Public Methods

checkDomainName(domain) → {boolean}

Compares the given domain name against the hostname of the browser containing the game.
If the domain name is found it returns true.
You can specify a part of a domain, for example 'google' would match '', '', etc.
Do not include 'http://' at the start.

Name Type Description
domain string
boolean -

true if the given domain fragment can be found in the window.location.hostname

Source code: net/Net.js (Line 38)

decodeURI(value) → {string}

Takes a Uniform Resource Identifier (URI) component (previously created by encodeURIComponent or by a similar routine) and
decodes it, replacing \ with spaces in the return. Used internally by the Net classes.

Name Type Description
value string

The URI component to be decoded.

string -

The decoded value.

Source code: net/Net.js (Line 152)

getHostName() → {string}

Returns the hostname given by the browser.

string -
Source code: net/Net.js (Line 22)

getQueryString(parameter) → {string | object}

Returns the Query String as an object.
If you specify a parameter it will return just the value of that parameter, should it exist.

Name Type Argument Default Description
parameter string <optional>

If specified this will return just the value for that key.

string | object -

An object containing the key value pairs found in the query string or just the value if a parameter was given.

Source code: net/Net.js (Line 116)

updateQueryString(key, value, redirect, url) → {string}

Updates a value on the Query String and returns it in full.
If the value doesn't already exist it is set.
If the value exists it is replaced with the new value given. If you don't provide a new value it is removed from the query string.
Optionally you can redirect to the new url, or just return it as a string.

Name Type Description
key string

The querystring key to update.

value string

The new value to be set. If it already exists it will be replaced.

redirect boolean

If true the browser will issue a redirect to the url with the new querystring.

url string

The URL to modify. If none is given it uses window.location.href.

string -

If redirect is false then the modified url and query string is returned.

Source code: net/Net.js (Line 52)


comments powered by Disqus