ElectroServer 5 Client: Cocoa-Touch
EsEngine Class Reference
Inheritance diagram for EsEngine:
EsEventDispatcher

Instance Methods

(id) - init
 
(void) - connect
 After this class is configured with available connections via the servers property or the addServer method, invoking this method will attempt to connect to ElectroServer. More...
 
(void) - connectToServer:
 
(void) - connectToServer:withAvailableConnection:
 
(EsConnection *) - connectionWithId:
 All connections that are attempted are locally assigned an id. More...
 
(void) - addServer:
 Adds a Server instance to the list of available servers. More...
 
(void) - removeServer:
 Removes a server from the list of available servers. More...
 
(void) - close
 Closes all active connections resulting in EsConnectionClosedEvent events for each connection. More...
 
(void) - sendMessage:
 
(void) - sendMessage:onConnection:
 Sends a message to the server. More...
 
(EsServer *) - serverWithId:
 Gets a Server instance by id. More...
 
(void) - setServers:
 Configures this class with a list of servers that are available. More...
 
(NSArray *) - servers
 
(BOOL) - connected
 
(NSArray *) - connectionsToAttempt
 
(int) - connectionAttemptIndex
 
(NSArray *) - activeConnections
 
(void) - setEncryptionEnabled:
 Enables or disables message encryption for all active connections. More...
 
(void) - setEncryptionEnabled:connection:
 Enables or disables encryption for the specified Connection. More...
 
(BOOL) - encryptionEnabled
 Returns the state of encryption for all active connections. More...
 
(BOOL) - encryptionEnabled:
 Returns the state of encryption for the specified connection. More...
 
(void) - attemptNextConnection
 
(EsConnection *) - newConnection:
 
(void) - pruneConnectionsToAttempt
 
(void) - processMessage:connection:
 
(void) - preProcessMessage:connection:server:
 
(void) - cleanConnectionListeners:
 
(void) - checkMessageOrder:connection:
 
- Instance Methods inherited from EsEventDispatcher
(void) - addEventListenerWithTarget:action:eventIdentifier:priority:
 
(void) - addEventListenerWithTarget:action:eventIdentifier:
 
(void) - removeEventListenerWithTarget:action:eventIdentifier:
 
(void) - dispatchEvent:
 

Properties

BOOL ignoreUnknownMessages
 

Method Documentation

- (NSArray *) activeConnections
- (void) addServer: (EsServer*)  server

Adds a Server instance to the list of available servers.

Servers should only be added through this method or by setting a new array of servers via the 'servers' property.

Parameters
Serverinstance to add.
- (void) attemptNextConnection
- (void) checkMessageOrder: (EsMessage*)  message
connection: (EsConnection*)  connection 
- (void) cleanConnectionListeners: (EsConnection*)  con
- (void) close

Closes all active connections resulting in EsConnectionClosedEvent events for each connection.

- (void) connect

After this class is configured with available connections via the servers property or the addServer method, invoking this method will attempt to connect to ElectroServer.

The connections attempted varies based on parameters. The most common usage is to not pass in any parameters. In this usage (no paramters) connection attempts are made by cycling through all possible connections until one is established. If the server parameter is non-null and the availableConnection parameter is null, then connections attempts are made by cycling through all possible connections associated only with the server specified. If the server paramteer is non-null and the availableconnection parameter is non-null then a connection is attempted only with the availableConnection specified. This can be used to establish additional connections.

Every attempted connection results in a ConnectionAttemptResponse event. When a connection finally succeeds or if all connection attempts fail a ConnectionResponse event is fired.

Parameters
OptionalServer instance. This needs to have already been added to this class via the servers property or addServer method.
OptionalAvailableConnection instance. If non-null then the 'server' parameter must be non-null and this instance must have been added to it.
- (BOOL) connected
- (int) connectionAttemptIndex
- (NSArray *) connectionsToAttempt
- (EsConnection *) connectionWithId: (int)  connectionId

All connections that are attempted are locally assigned an id.

This method returns the Connection instance associated with the id passed in.

Parameters
Idof the Connection you want to retrieve
Returns
Connection instance
- (void) connectToServer: (EsServer*)  server
- (void) connectToServer: (EsServer*)  server
withAvailableConnection: (EsAvailableConnection*)  availableConnection 
- (BOOL) encryptionEnabled

Returns the state of encryption for all active connections.

If encryption is enabled on all connections this returns true. If it is not enabled on any connection this returns false.

Returns
- (BOOL) encryptionEnabled: (EsConnection*)  connection

Returns the state of encryption for the specified connection.

Returns
- (id) init
- (EsConnection *) newConnection: (EsAvailableConnection*)  availableConnection
- (void) preProcessMessage: (EsMessage*)  message
connection: (EsConnection*)  connection
server: (EsServer*)  server 
- (void) processMessage: (EsMessage*)  message
connection: (EsConnection*)  connection 
- (void) pruneConnectionsToAttempt
- (void) removeServer: (EsServer*)  server

Removes a server from the list of available servers.

Parameters
Serverto remove
- (void) sendMessage: (EsMessage*)  message
- (void) sendMessage: (EsMessage*)  message
onConnection: (EsConnection*)  connection 

Sends a message to the server.

This is the only way to communicate with the server. If no connection is specified then the default connection is used. The default connection is the first connection established.

Parameters
Themessage to send to the server.
Theoptional connection to use for sending to the server.
- (NSArray *) servers
- (EsServer *) serverWithId: (NSString*)  serverId

Gets a Server instance by id.

The server must have been previously added via the addServer method or by setting an array of servers using the 'servers' property.

Parameters
Idof the Server instance to return
Returns
Server instance
- (void) setEncryptionEnabled: (BOOL)  encryptionEnabled

Enables or disables message encryption for all active connections.

The first time encryption is enabled for a connection a key exchange will take place which may take several seconds. Encryption will be automatically enabled once the key exchange completes. When encryption is successfully enabled or disabled for a connection a EsEncryptionStateChangeEvent will be dispatched.

Parameters
encryptionEnabled
- (void) setEncryptionEnabled: (BOOL)  encryptionEnabled
connection: (EsConnection*)  connection 

Enables or disables encryption for the specified Connection.

See setEncryptionEnabled(boolean) for further details.

Parameters
encryptionEnabled
con
- (void) setServers: (NSArray*)  servers

Configures this class with a list of servers that are available.

The servers array should not be modified directly. Use the addServer and removeServer methods, or set the entire array of servers using this property.

Property Documentation

- (BOOL) ignoreUnknownMessages
readwriteatomic