Constructor
(export) new NetworkingEngine(onProgressUpdatedopt)
NetworkingEngine wraps all networking operations. This accepts plugins that
handle the actual request. A plugin is registered using registerScheme.
Each scheme has at most one plugin to handle the request.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
onProgressUpdated |
function(number, number)= |
<optional> |
Called when a progress event is triggered. Passed the duration, in milliseconds, that the request took, and the number of bytes transferred. |
- Implements:
- Extends:
- Source:
Extends
Classes
Members
(static) defaultRetryParameters
Gets a copy of the default retry parameters.
- Source:
(export, static) PluginPriority :number
Priority level for network scheme plugins.
If multiple plugins are provided for the same scheme, only the
highest-priority one is used.
Type:
- number
Properties:
Name | Value | Type | Description |
---|---|---|---|
FALLBACK |
1 | number | |
PREFERRED |
2 | number | |
APPLICATION |
3 | number |
- Source:
(export, static) RequestType :number
Request types. Allows a filter to decide which requests to read/alter.
Type:
- number
Properties:
Name | Value | Type | Description |
---|---|---|---|
MANIFEST |
0 | number | |
SEGMENT |
1 | number | |
LICENSE |
2 | number | |
APP |
3 | number | |
TIMING |
4 | number |
- Source:
(private, static, non-null) schemes_ :Object.<string, shaka.net.NetworkingEngine.SchemeObject>
Contains the scheme plugins.
Type:
- Object.<string, shaka.net.NetworkingEngine.SchemeObject>
- Source:
dispatchTarget :EventTarget
The target of all dispatched events. Defaults to |this|.
Type:
- EventTarget
- Inherited From:
- Source:
(private, non-null) listeners_ :shaka.util.MultiMap.<shaka.util.FakeEventTarget.ListenerType>
Type:
- Inherited From:
- Source:
(private, nullable) onProgressUpdated_ :?function(number, number)
Type:
- ?function(number, number)
- Source:
Methods
(private, static) getLocationProtocol_() → {string}
This is here only for testability. We can't mock location in our tests on
all browsers, so instead we mock this.
- Source:
Returns:
The value of location.protocol.
- Type
- string
(static) makeRequest(urisnon-null, retryParams) → {shaka.extern.Request}
Makes a simple network request for the given URIs.
Parameters:
Name | Type | Description |
---|---|---|
uris |
Array.<string> | |
retryParams |
shaka.extern.RetryParameters |
- Source:
Returns:
- Type
- shaka.extern.Request
(export, static) registerScheme(scheme, plugin, priorityopt)
Registers a scheme plugin. This plugin will handle all requests with the
given scheme. If a plugin with the same scheme already exists, it is
replaced, unless the existing plugin is of higher priority.
If no priority is provided, this defaults to the highest priority of
APPLICATION.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
scheme |
string | ||
plugin |
shaka.extern.SchemePlugin | ||
priority |
number |
<optional> |
- Source:
(export, static) unregisterScheme(scheme)
Removes a scheme plugin.
Parameters:
Name | Type | Description |
---|---|---|
scheme |
string |
- Source:
(export) addEventListener(type, listener, optionsopt)
Add an event listener to this object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | The event type to listen for. | |
listener |
shaka.util.FakeEventTarget.ListenerType | The callback or listener object to invoke. | |
options |
AddEventListenerOptions | boolean |
<optional> |
Ignored. |
- Inherited From:
- Source:
(export) clearAllRequestFilters()
Clears all request filters.
- Source:
(export) clearAllResponseFilters()
Clears all response filters.
- Source:
(export) destroy() → (non-null) {Promise}
Request that this object be destroyed, releasing all resources and shutting
down all operations. Returns a Promise which is resolved when destruction
is complete. This Promise should never be rejected.
- Implements:
- Source:
Returns:
- Type
- Promise
(export) dispatchEvent(eventnon-null) → {boolean}
Dispatch an event from this object.
Parameters:
Name | Type | Description |
---|---|---|
event |
Event | The event to be dispatched from this object. |
- Inherited From:
- Source:
Returns:
True if the default action was prevented.
- Type
- boolean
(private) filterRequest_(type, request) → (non-null) {shaka.extern.IAbortableOperation.<undefined>}
Parameters:
Name | Type | Description |
---|---|---|
type |
shaka.net.NetworkingEngine.RequestType | |
request |
shaka.extern.Request |
- Source:
Returns:
- Type
- shaka.extern.IAbortableOperation.<undefined>
(private) filterResponse_(type, responseAndGotProgress) → (non-null) {shaka.extern.IAbortableOperation.<shaka.net.NetworkingEngine.ResponseAndGotProgress>}
Parameters:
Name | Type | Description |
---|---|---|
type |
shaka.net.NetworkingEngine.RequestType | |
responseAndGotProgress |
shaka.net.NetworkingEngine.ResponseAndGotProgress |
- Source:
Returns:
(private) makeRequestWithRetry_(type, request, numBytesRemainingObj) → (non-null) {shaka.extern.IAbortableOperation.<shaka.net.NetworkingEngine.ResponseAndGotProgress>}
Parameters:
Name | Type | Description |
---|---|---|
type |
shaka.net.NetworkingEngine.RequestType | |
request |
shaka.extern.Request | |
numBytesRemainingObj |
shaka.net.NetworkingEngine.NumBytesRemainingClass |
- Source:
Returns:
(export) registerRequestFilter(filter)
Registers a new request filter. All filters are applied in the order they
are registered.
Parameters:
Name | Type | Description |
---|---|---|
filter |
shaka.extern.RequestFilter |
- Source:
(export) registerResponseFilter(filter)
Registers a new response filter. All filters are applied in the order they
are registered.
Parameters:
Name | Type | Description |
---|---|---|
filter |
shaka.extern.ResponseFilter |
- Source:
(export) removeEventListener(type, listener, optionsopt)
Remove an event listener from this object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | The event type for which you wish to remove a listener. | |
listener |
shaka.util.FakeEventTarget.ListenerType | The callback or listener object to remove. | |
options |
EventListenerOptions | boolean |
<optional> |
Ignored. |
- Inherited From:
- Source:
(export) request(type, request) → (non-null) {shaka.net.NetworkingEngine.PendingRequest}
Makes a network request and returns the resulting data.
Parameters:
Name | Type | Description |
---|---|---|
type |
shaka.net.NetworkingEngine.RequestType | |
request |
shaka.extern.Request |
- Source:
Returns:
(private) send_(type, request, backoffnon-null, index, lastErrornullable, numBytesRemainingObjopt) → (non-null) {shaka.extern.IAbortableOperation.<shaka.net.NetworkingEngine.ResponseAndGotProgress>}
Sends the given request to the correct plugin and retry using Backoff.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
shaka.net.NetworkingEngine.RequestType | ||
request |
shaka.extern.Request | ||
backoff |
shaka.net.Backoff | ||
index |
number | ||
lastError |
shaka.util.Error |
<nullable> |
|
numBytesRemainingObj |
shaka.net.NetworkingEngine.NumBytesRemainingClass |
<optional> |
- Source:
Returns:
(export) unregisterRequestFilter(filter)
Removes a request filter.
Parameters:
Name | Type | Description |
---|---|---|
filter |
shaka.extern.RequestFilter |
- Source:
(export) unregisterResponseFilter(filter)
Removes a response filter.
Parameters:
Name | Type | Description |
---|---|---|
filter |
shaka.extern.ResponseFilter |
- Source:
Type Definitions
ResponseAndGotProgress
Defines a response wrapper object, including the response object and whether
progress event is fired by the scheme plugin.
Type:
- {response: shaka.extern.Response, gotProgress: boolean}
Properties:
Name | Type | Description |
---|---|---|
response |
shaka.extern.Response | |
gotProgress |
boolean |
- Source:
SchemeObject
Type:
- {plugin: shaka.extern.SchemePlugin, priority: number}
Properties:
Name | Type | Description |
---|---|---|
plugin |
shaka.extern.SchemePlugin | The associated plugin. |
priority |
number | The plugin's priority. |
- Source:
Events
RetryEvent
Fired when the networking engine receives a recoverable error
and retries.
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | 'retry' | |
error |
shaka.util.Error |
<nullable> |
The error that caused the retry. If it was a non-Shaka error, this is set to null. |
- Source: