RemoteSession
Extends:
A remote context Session to another peer.
Example:
import { RemoteSession } from 'remote-context';
const session = new RemoteSession(objectStream, context);
Constructor Summary
Public Constructor | ||
public |
constructor(objectStream: Stream, context: Context, opts: options) Create a session from an object stream. |
Member Summary
Public Members | ||
public get |
Get the remote context |
|
public get |
True if the remote peer should see stack errors. |
Method Summary
Public Methods | ||
public |
assign(value: *): ReferenceAction Assign a remote or local reference to the given value and return the matching Action. |
|
public |
Delete a local reference from the local-context. |
|
public |
destroy(err: *) |
|
public |
Dispatch a value for the remote peer session. |
|
public |
Check if the given value exists on the local-context. |
|
public |
Get a local reference value from the local-context. |
|
public |
isWritable(value: *): boolean Check if the given value is writable. |
|
public |
set(reference: Reference, value: *): RemoteSession Set a local reference to the local-context. |
Inherited Summary
From class Session | ||
public get |
True if the session is no longer readable. |
|
public get |
True if the session is open. |
|
public get |
The number of requests sent and waiting for response. |
|
public |
Destroy this session and it's stream. |
|
public |
dispatch(value: *): * Convert the given value to a value that can be send ove to the other peer. |
|
public |
End this session stream. |
|
public |
Fetch an arbitrary value. |
|
public |
Request from the other peer to fetch the given action and send back it's response value. |
|
public |
Send an action for execution to the other peer. |
|
public |
Return session constructor name. |
Public Constructors
public constructor(objectStream: Stream, context: Context, opts: options) source
Create a session from an object stream.
Override:
Session#constructorParams:
Name | Type | Attribute | Description |
objectStream | Stream | an actions object stream |
|
context | Context | The main context |
|
opts | options |
|
Session options with extensions |
opts.writable | boolean |
|
True if this context is writable to the remote peer |
opts.showStack | boolean |
|
True if errors on this context should include full stack (The stack will be send to the remote peer as a string) |
Public Members
Public Methods
public assign(value: *): ReferenceAction source
Assign a remote or local reference to the given value and return the matching Action. First check if the given value exists on the remote context and if so, return it's reference. Otherwise assign a new reference for the given value on the local context.
Params:
Name | Type | Attribute | Description |
value | * |
public delete(reference: Reference): boolean source
Delete a local reference from the local-context.
Params:
Name | Type | Attribute | Description |
reference | Reference | The local reference |
public destroy(err: *) source
Destroy this session and it's stream.
Override:
Session#destroyParams:
Name | Type | Attribute | Description |
err | * |
public dispatch(value: *): Action | null | number | boolean | string source
Dispatch a value for the remote peer session. Objects and functions will convert to actions, other primitive values such as string or numbers will remain as-is.
Override:
Session#dispatchParams:
Name | Type | Attribute | Description |
value | * |
public exists(value: *): boolean source
Check if the given value exists on the local-context.
Params:
Name | Type | Attribute | Description |
value | * | The given value |
public get(reference: Reference): * source
Get a local reference value from the local-context.
Params:
Name | Type | Attribute | Description |
reference | Reference | The local reference |
Return:
* |
public isWritable(value: *): boolean source
Check if the given value is writable. A value is writable if the local-context own it (ie. the value created elusively for this peer) or if the context is writable and the main-context own it. Environment values are always readonly unless there are on the context.
Params:
Name | Type | Attribute | Description |
value | * | The given value |
public set(reference: Reference, value: *): RemoteSession source
Set a local reference to the local-context.
Params:
Name | Type | Attribute | Description |
reference | Reference | The local reference |
|
value | * | The local value |