Hybrid Bridge
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Events | List of all members
HybridBridge.HybridMessagingHandler Class Reference

A class for event driven communicate with Javascript side More...

Inheritance diagram for HybridBridge.HybridMessagingHandler:
HybridBridge.IBridgeHandler

Classes

class  ProxyClass
 The class to be reflected on Javascript side More...
 

Public Member Functions

 HybridMessagingHandler (string jsVariableName="HybridMessaging")
 Creates a new instance of this class More...
 
virtual object InterceptRequest (string method, Dictionary< string, object > parameters, out bool hasResult)
 Handles the passed request and returns the result More...
 
virtual bool ShouldInterceptRequest (string handler, string method)
 Checks the request and returns true if this request can be handled by this handler More...
 
virtual void Initialize (BridgeController bridge)
 Initialize the handler and generates the needed Javascript code More...
 
virtual void Dispose ()
 The method to dispose this class More...
 
virtual void Send (string messageString)
 Sends a message to the Javascript side More...
 
virtual TResult Send< TResult > (string messageString)
 Sends a message to the Javascript side and waits for the response More...
 
virtual void Send< TArgument > (string messageString, TArgument argument)
 Sends a message to the Javascript side More...
 
virtual TResult Send< TResult, TArgument > (string messageString, TArgument argument)
 Sends a message to the Javascript side and waits for the response More...
 
virtual bool Subscribe (string messageString, Action callback)
 Registers a callback method for the specified message string More...
 
virtual bool Subscribe< TArgument > (string messageString, Action< TArgument > callback)
 Registers a callback method for the specified message string More...
 
virtual bool Subscribe< TResult, TArgument > (string messageString, Func< TArgument, TResult > callback)
 Registers a callback method for the specified message string More...
 
virtual bool Subscribe< TResult > (string messageString, Func< TResult > callback)
 Registers a callback method for the specified message string More...
 
virtual bool Unsubscribe (string messageString, Action callback)
 Unregisters a callback method for the specified message string More...
 
virtual bool Unsubscribe< TArgument > (string messageString, Action< TArgument > callback)
 Unregisters a callback method for the specified message string More...
 
virtual bool Unsubscribe< TResult, TArgument > (string messageString, Func< TArgument, TResult > callback)
 Unregisters a callback method for the specified message string More...
 
virtual bool Unsubscribe< TResult > (string messageString, Func< TResult > callback)
 Unregisters a callback method for the specified message string More...
 

Protected Member Functions

virtual void Dispose (bool disposing)
 The method to dispose this class More...
 
virtual object OnPushJavascript (IBridgeHandler sender, PushJavascriptEventArgs eventArgs)
 Raises the PushJavascript event using provided arguments More...
 
virtual bool Subscribe (string messageString, Delegate callback)
 Registers an callback method for the specified message string More...
 
virtual bool Unsubscribe (string messageString, Delegate callback)
 Unregisters a callback method for the specified message string More...
 
virtual object OnNewMessage (string messageString, object arguments)
 The method to be called when a new message received from the Javascript side More...
 

Protected Attributes

readonly object Lock = new object()
 A static object to be used as thread lock when working with other static fields More...
 
readonly Dictionary< string, List< Delegate > > Subscriptions = new Dictionary<string, List<Delegate>>()
 A list of all registered delegates More...
 
bool Disposed
 Indicates if the class already disposed More...
 
ClassBridge< ProxyClassHybridMessagingBridge
 An instance of the ClassBridge class for ProxyClass to be used as the communication bridge More...
 
ProxyClass HybridMessagingProxy
 An instance of the ProxyClass to be used for communication More...
 

Events

PushJavascriptEvent PushJavascript
 Event that gets raised when handler needs to push some Javascript code More...
 
- Events inherited from HybridBridge.IBridgeHandler
PushJavascriptEvent PushJavascript
 Event that gets raised when handler needs to push some Javascript code More...
 

Detailed Description

A class for event driven communicate with Javascript side

Definition at line 13 of file HybridMessagingHandler.cs.

Constructor & Destructor Documentation

HybridBridge.HybridMessagingHandler.HybridMessagingHandler ( string  jsVariableName = "HybridMessaging")

Creates a new instance of this class

Parameters
jsVariableNameThe name of the variable to be used from the Javascript side to access the HybridMessaging object

Definition at line 48 of file HybridMessagingHandler.cs.

Member Function Documentation

virtual void HybridBridge.HybridMessagingHandler.Dispose ( )
virtual

The method to dispose this class

Definition at line 158 of file HybridMessagingHandler.cs.

virtual void HybridBridge.HybridMessagingHandler.Dispose ( bool  disposing)
protectedvirtual

The method to dispose this class

Definition at line 175 of file HybridMessagingHandler.cs.

virtual void HybridBridge.HybridMessagingHandler.Initialize ( BridgeController  bridge)
virtual

Initialize the handler and generates the needed Javascript code

Parameters
bridgeThe BridgeController object requesting initialization

Implements HybridBridge.IBridgeHandler.

Definition at line 83 of file HybridMessagingHandler.cs.

virtual object HybridBridge.HybridMessagingHandler.InterceptRequest ( string  method,
Dictionary< string, object >  parameters,
out bool  hasResult 
)
virtual

Handles the passed request and returns the result

Parameters
methodThe method name to handle
parametersThe method parameters
hasResultA boolean value indicting if the handling process resulted in a value
Returns
Returns the value that created from the handling of the request

Implements HybridBridge.IBridgeHandler.

Definition at line 63 of file HybridMessagingHandler.cs.

virtual object HybridBridge.HybridMessagingHandler.OnNewMessage ( string  messageString,
object  arguments 
)
protectedvirtual

The method to be called when a new message received from the Javascript side

Parameters
messageStringThe message identification string, or string.Empty to match all
argumentsThe message arguments, or null
Returns
Returns the response of the last subscriber

Definition at line 443 of file HybridMessagingHandler.cs.

virtual object HybridBridge.HybridMessagingHandler.OnPushJavascript ( IBridgeHandler  sender,
PushJavascriptEventArgs  eventArgs 
)
protectedvirtual

Raises the PushJavascript event using provided arguments

Parameters
senderThe IBridgeHandler instance that raised the event
eventArgsThe arguments to be used to raise PushJavascript event
Returns
Returns the result of raising PushJavascript event

Definition at line 202 of file HybridMessagingHandler.cs.

virtual void HybridBridge.HybridMessagingHandler.Send ( string  messageString)
virtual

Sends a message to the Javascript side

Parameters
messageStringMessage identification, or string.Empty to send to all subscribers

Definition at line 211 of file HybridMessagingHandler.cs.

virtual void HybridBridge.HybridMessagingHandler.Send< TArgument > ( string  messageString,
TArgument  argument 
)
virtual

Sends a message to the Javascript side

Parameters
messageStringMessage identification, or string.Empty to send to all subscribers
argumentThe argument to be send to the message subscriber
Template Parameters
TArgumentThe type of the argument to send

Definition at line 242 of file HybridMessagingHandler.cs.

virtual TResult HybridBridge.HybridMessagingHandler.Send< TResult > ( string  messageString)
virtual

Sends a message to the Javascript side and waits for the response

Parameters
messageStringMessage identification, or string.Empty to send to all subscribers
Template Parameters
TResultThe type of the expected result
Returns
Returns the response of the last subscriber

Definition at line 223 of file HybridMessagingHandler.cs.

virtual TResult HybridBridge.HybridMessagingHandler.Send< TResult, TArgument > ( string  messageString,
TArgument  argument 
)
virtual

Sends a message to the Javascript side and waits for the response

Parameters
messageStringMessage identification, or string.Empty to send to all subscribers
argumentThe argument to be send to the message subscriber
Template Parameters
TResultThe type of the expected result
TArgumentThe type of the argument to send
Returns
Returns the response of the last subscriber

Definition at line 255 of file HybridMessagingHandler.cs.

virtual bool HybridBridge.HybridMessagingHandler.ShouldInterceptRequest ( string  handler,
string  method 
)
virtual

Checks the request and returns true if this request can be handled by this handler

Parameters
handlerThe name of requested handler
methodThe method name to handle
Returns
true, if this handler can handle this request, false otherwise

Implements HybridBridge.IBridgeHandler.

Definition at line 74 of file HybridMessagingHandler.cs.

virtual bool HybridBridge.HybridMessagingHandler.Subscribe ( string  messageString,
Delegate  callback 
)
protectedvirtual

Registers an callback method for the specified message string

Parameters
messageStringThe message identification string to subscribe to
callbackThe callback function to be called for the message
Returns
if the callback registered successfully, otherwise

Definition at line 274 of file HybridMessagingHandler.cs.

virtual bool HybridBridge.HybridMessagingHandler.Subscribe ( string  messageString,
Action  callback 
)
virtual

Registers a callback method for the specified message string

Parameters
messageStringThe message identification string to subscribe to
callbackThe callback function to be called for the message
Returns
if the callback registered successfully, otherwise

Definition at line 339 of file HybridMessagingHandler.cs.

virtual bool HybridBridge.HybridMessagingHandler.Subscribe< TArgument > ( string  messageString,
Action< TArgument >  callback 
)
virtual

Registers a callback method for the specified message string

Parameters
messageStringThe message identification string to subscribe to
callbackThe callback function to be called for the message
Template Parameters
TArgumentThe type of the message argument
Returns
if the callback registered successfully, otherwise

Definition at line 351 of file HybridMessagingHandler.cs.

virtual bool HybridBridge.HybridMessagingHandler.Subscribe< TResult > ( string  messageString,
Func< TResult >  callback 
)
virtual

Registers a callback method for the specified message string

Parameters
messageStringThe message identification string to subscribe to
callbackThe callback function to be called for the message
Template Parameters
TResultThe type of the callback result
Returns
if the callback registered successfully, otherwise

Definition at line 376 of file HybridMessagingHandler.cs.

virtual bool HybridBridge.HybridMessagingHandler.Subscribe< TResult, TArgument > ( string  messageString,
Func< TArgument, TResult >  callback 
)
virtual

Registers a callback method for the specified message string

Parameters
messageStringThe message identification string to subscribe to
callbackThe callback function to be called for the message
Template Parameters
TResultThe type of the callback result
TArgumentThe type of the message argument
Returns
if the callback registered successfully, otherwise

Definition at line 364 of file HybridMessagingHandler.cs.

virtual bool HybridBridge.HybridMessagingHandler.Unsubscribe ( string  messageString,
Delegate  callback 
)
protectedvirtual

Unregisters a callback method for the specified message string

Parameters
messageStringThe message identification string to unsubscribe from
callbackThe callback function registered for the message
Returns
if the callback unregistered successfully, otherwise

Definition at line 304 of file HybridMessagingHandler.cs.

virtual bool HybridBridge.HybridMessagingHandler.Unsubscribe ( string  messageString,
Action  callback 
)
virtual

Unregisters a callback method for the specified message string

Parameters
messageStringThe message identification string to unsubscribe from
callbackThe callback function registered for the message
Returns
if the callback unregistered successfully, otherwise

Definition at line 389 of file HybridMessagingHandler.cs.

virtual bool HybridBridge.HybridMessagingHandler.Unsubscribe< TArgument > ( string  messageString,
Action< TArgument >  callback 
)
virtual

Unregisters a callback method for the specified message string

Parameters
messageStringThe message identification string to unsubscribe from
callbackThe callback function registered for the message
Template Parameters
TArgumentThe type of the message argument
Returns
if the callback unregistered successfully, otherwise

Definition at line 403 of file HybridMessagingHandler.cs.

virtual bool HybridBridge.HybridMessagingHandler.Unsubscribe< TResult > ( string  messageString,
Func< TResult >  callback 
)
virtual

Unregisters a callback method for the specified message string

Parameters
messageStringThe message identification string to unsubscribe from
callbackThe callback function registered for the message
Template Parameters
TResultThe type of the callback result
Returns
if the callback unregistered successfully, otherwise

Definition at line 432 of file HybridMessagingHandler.cs.

virtual bool HybridBridge.HybridMessagingHandler.Unsubscribe< TResult, TArgument > ( string  messageString,
Func< TArgument, TResult >  callback 
)
virtual

Unregisters a callback method for the specified message string

Parameters
messageStringThe message identification string to unsubscribe from
callbackThe callback function registered for the message
Template Parameters
TResultThe type of the callback result
TArgumentThe type of the message argument
Returns
if the callback unregistered successfully, otherwise

Definition at line 418 of file HybridMessagingHandler.cs.

Member Data Documentation

bool HybridBridge.HybridMessagingHandler.Disposed
protected

Indicates if the class already disposed

Definition at line 28 of file HybridMessagingHandler.cs.

ClassBridge<ProxyClass> HybridBridge.HybridMessagingHandler.HybridMessagingBridge
protected

An instance of the ClassBridge class for ProxyClass to be used as the communication bridge

Definition at line 34 of file HybridMessagingHandler.cs.

ProxyClass HybridBridge.HybridMessagingHandler.HybridMessagingProxy
protected

An instance of the ProxyClass to be used for communication

Definition at line 39 of file HybridMessagingHandler.cs.

readonly object HybridBridge.HybridMessagingHandler.Lock = new object()
protected

A static object to be used as thread lock when working with other static fields

Definition at line 18 of file HybridMessagingHandler.cs.

readonly Dictionary<string, List<Delegate> > HybridBridge.HybridMessagingHandler.Subscriptions = new Dictionary<string, List<Delegate>>()
protected

A list of all registered delegates

Definition at line 23 of file HybridMessagingHandler.cs.

Event Documentation

PushJavascriptEvent HybridBridge.HybridMessagingHandler.PushJavascript

Event that gets raised when handler needs to push some Javascript code

Definition at line 153 of file HybridMessagingHandler.cs.


The documentation for this class was generated from the following file: