XGConnection

Inherits from:
Declared In:

Overview

An XGConnection object represents the connection between an Xgrid client and an Xgrid controller.

Discussion

The XGConnection class is created by an Xgrid client using the name or address of a controller. The connection can be in one of four states, and a collection of constants is declared which are used describe which state a connection is in. An authenticator can be set on the connector, which allows the connection to be authenticated. A delegate may be set on the connection, and will receive callbacks when connection events occur, prior to the notification of key-value observers.



Methods

-authenticator

Returns the authenticator of the receiver.

-close

Starts closing the connection from the client to the controller.

-delegate

Returns the delegate of the receiver.

-error

Returns the error of the receiver.

-hostname

Returns the hostname the receiver was initialized with, or nil if the receiver wasn't initialized with a hostname.

-initWithHostname:portnumber:

Initializes a XGConnection object with a hostname and portnumber.

-initWithNetService:

Initializes a XGConnection object with a NSNetService.

-isClosed

Returns YES iff the connection state is Closed.

-isOpened

Returns YES iff the connection state is Open.

-name

Returns the name of the connection. This may be the name of the netService or the hostname, depending on which the receiver was initialized with.

-netService

Returns the NSNetService the receiver was initialized with, or nil if the receiver wasn't initialized with an NSNetService.

-open

Starts opening the connection from the client to the controller.

-portnumber

Returns the portnumber the receiver was initialized with, or the default portnumber if the receiver was initialized with a 0 portnumber, or 0 if the receiver wasn't initialized with a portnumber.

-setAuthenticator:

Sets the authenticator of the receiver.

-setDelegate:

Sets the delegate of the receiver.

-state

Returns the state of the receiver.


authenticator


Returns the authenticator of the receiver.

- (XGAuthenticator *)authenticator; 
Return Value

The authenticator of the receiver.


close


Starts closing the connection from the client to the controller.

- (void)close; 
Discussion

This method may only be called when the connection is in the Opening or Open states.


delegate


Returns the delegate of the receiver.

- (id)delegate; 
Return Value

The delegate of the receiver.


error


Returns the error of the receiver.

- (NSError *)error; 
Return Value

The error of the receiver.

Discussion

The error is nil during the Opening and Closing states. The error represents success if the connection is in the Open state. If the connection closes due to an error, then this will be set to that error. If the connection closes due to a -close message, then this will be a success error.


hostname


Returns the hostname the receiver was initialized with, or nil if the receiver wasn't initialized with a hostname.

- (NSString *)hostname; 
Return Value

The hostname the receiver connects to.


initWithHostname:portnumber:


Initializes a XGConnection object with a hostname and portnumber.

- (id)initWithHostname:(NSString *)hostname portnumber:(UInt32)portnumber; 
Parameters
hostname

The hostname to connect to. May be a name or address. Must not be nil.

portnumber

The portnumber to connect to. If portnumber is 0 then the default portnumber will be used.


initWithNetService:


Initializes a XGConnection object with a NSNetService.

- (id)initWithNetService:(NSNetService *)netService; 
Parameters
netService

The net service to connect to. Must not be nil.

Return Value

An initialized XGConnection object.


isClosed


Returns YES iff the connection state is Closed.

- (BOOL)isClosed; 


isOpened


Returns YES iff the connection state is Open.

- (BOOL)isOpened; 


name


Returns the name of the connection. This may be the name of the netService or the hostname, depending on which the receiver was initialized with.

- (NSString *)name; 
Return Value

The name of the receiver.


netService


Returns the NSNetService the receiver was initialized with, or nil if the receiver wasn't initialized with an NSNetService.

- (NSNetService *)netService; 
Return Value

The NSNetService the receiver connects to.


open


Starts opening the connection from the client to the controller.

- (void)open; 
Discussion

This method may only be called when the connection is in the Closed state.


portnumber


Returns the portnumber the receiver was initialized with, or the default portnumber if the receiver was initialized with a 0 portnumber, or 0 if the receiver wasn't initialized with a portnumber.

- (UInt32)portnumber; 
Return Value

The portnumber the receiver connects to.


setAuthenticator:


Sets the authenticator of the receiver.

- (void)setAuthenticator:(XGAuthenticator *)authenticator; 
Discussion

The authenticator is retained. The authenticator will be used by the connection if the client or controller requires the connection to be authenticated.


setDelegate:


Sets the delegate of the receiver.

- (void)setDelegate:(id)delegate; 
Parameters
delegate

The delegate.

Discussion

The delegate is not retained. If the delegate implements any of the methods in the XGConnectionDelegate protocol then it will receive callbacks when connection events occur, prior to the notification of key-value observers.


state


Returns the state of the receiver.

- (XGConnectionState)state; 
Return Value

The state of the receiver.

Did this document help you? Yes It's good, but... Not helpful...

 

Last Updated: 2009-08-12