Vvidget Code > API > Mac OS X > Client > State
The Client State is defined by the VC_Client_State
class. An instance of this class can retrieve a graph image from a Vvidget Server without the need for a View instance which means it can act as an adapter to processes (services) that do not know how to display things but can manipulate bytes which would otherwise be intended for display.
Add the State functionality to your project by adding the VvidgetCode framework.
Definition: | /Library/Frameworks/VvidgetCode.framework/Headers/VC_Client_State.h |
Client Framework: | /Library/Frameworks/VvidgetCode.framework |
Shared Frameworks: | /Library/Frameworks/Vvidget_*.framework |
Embedded Frameworks: | /Library/Vvidget/EmbeddedFrameworks/Vvidget_*.framework |
If you use the Embedded Frameworks then you will need to add a build copy phase to your project to copy the Vvidget Frameworks into your application bundle. See Deploy for details. If you use an external server then you need only link to the Client Framework which implements a client interface to another process (the Peer Visual Server).
The following defines each method that is used with an object (instance) of the VC_Client_State type.
- (id)init
This method instantiates a client state. |
- (void)get_VC_input_string_constructor
This method retrieves the receiver's input string constructor which is used by calling code to define the state of the receiver. |
- (void)VC_update_using_host_string:(NSString *)a_string
This method informs the receiver as to the host to query upon in order to retrieve a result from its state. Usually the input string is simply @"localhost" which directs processing to a Vvidget server on the same computer as the instance, but it can be any other IP address of a computer running a Vvidget server. Use like this:
|
- (void)set_VC_image_output_type:(unsigned)a_value
Sets the type of image to return. This value should be 1U. |
- (void)set_VC_image_width:(unsigned)a_value
Sets the width of the returned image. |
- (void)set_VC_image_height:(unsigned)a_value
Sets the height of the returned image. |
- (NSData *)get_VC_query_data
Returns the internal query data structure. See the VC_form_query_data method. |
- (void)VC_update_using_input_string_constructor
Updates the receiver based upon the contents of its input string constructor. Call this right before calling VC_form_query_data. |
- (void)VC_form_query_data
This forms the query that will be sent to the server. |
- (NSData *)VC_output_data_from_query_data:(NSData *)query_data
Returns data (bytes) based upon query_data. Usually query_data is formed by the method VC_form_query_data which updates an internal query data structure so that query_data is [client_state get_VC_query_data]. The calling code owns the result of this method and is responsible for releasing it (it is not autoreleased). If an error in the query occurred then nil is returned. |
- (NSData *)VC_invalidate_connection
Invalidates the connection to the Vvidget server. You can keep the connection open to the Vvidget server, however doing so consumes one of the server's client reference states. There are only about 255 client reference states available to the server so invalidating such a reference is a safe thing to do and help the server out. However, if you intend to use the server a lot then do not call this method. If your process terminates then the connection is invalidated automatically. |
- (void)dealloc
This method deallocates the receiver. |
The following is a complete calling sequence of a input string constructor and makes a line graph state in dictionary form.
client_state = [[VC_Client_State alloc] init];
input_string_constructor = [client_state get_VC_input_string_constructor]; // by reference only
/* Update the input_string_constructor */
[client_state VC_update_using_host_string:@"localhost"];
[client_state set_VC_image_output_type:1U];
[client_state set_VC_image_width:600];
[client_state set_VC_image_height:600];
[client_state VC_update_using_input_string_constructor];
[client_state VC_form_query_data];
image_data = [client_state VC_output_data_from_query_data:[client_state get_VC_query_data]];
[client_state VC_invalidate_connection];
if(image_data != nil)
{
/* Do something with the image_data */
[image_data release];
}
[client_state release];
Please help improve this documentation. If a section is hard to understand, there is a typo, you would like a new section added, or you detect any other improvement that can be made then please email support@vvi.com with your information. |