
// This file automatically generated by:
//   Apache Etch 1.2.0-incubating (LOCAL-0) / c 1.2.0-incubating (LOCAL-0)
//   Mon Mar 28 14:18:57 CEST 2011
// This file is automatically created and should not be edited!

#include "example_server_impl.h"
#include "example_valufact.h"
#include "etch_url.h"
#include "etch_arrayval.h"
#include "etch_binary_tdo.h"
#include "etch_exception.h"
#include "etch_general.h"
#include "etch_log.h"
#include "etch_map.h"
#include <stdio.h>
#include "examplemixin_interface.h"
#include "examplemixin_valufact.h"
#include "example_remote_client.h"

unsigned short CLASSID_EXAMPLE_SERVER_IMPL;	
	
	
char* EXAMPLE_ETCHSIMP = "SIMP";

/* generated signatures */
int destroy_example_server_implx(void*);
example_server_impl* init_example_server_impl(struct example_remote_client*, etch_object_destructor);


/* - - - - - - - -    
 * instantiation
 * - - - - - - - -   
 */
etch_string* say_hello_impl(void* thisx, etch_string* who);
void * say_hello_oneway_impl(void* thisx, etch_string* who);
etch_string* say_hello_mixin_impl(void* thisx, etch_string* who);
void * say_hello_mixin_oneway_impl(void* thisx, etch_string* who);

/**
 * new_example_server_impl()
 * example_server_impl constructor.
 * add your custom initialization and virtual method overrides here.
 */
example_server_impl* new_example_server_impl(struct example_remote_client* client) 
{
    example_server_impl* pserver  /* allocate object */
        = init_example_server_impl(client, destroy_example_server_implx);	
    i_example_server* pserver_base = pserver->example_server_base;
    ((etch_object*)pserver_base)->class_id = get_dynamic_classid_unique(&CLASSID_EXAMPLE_SERVER_IMPL);

    /* add virtual method overrides, if any, here */
    etchmap_insertxw(pserver_base->virtuals, example_valufact_get_static()->str_example_say_hello, say_hello_impl, FALSE);
    etchmap_insertxw(pserver_base->virtuals, example_valufact_get_static()->str_example_say_hello_oneway, say_hello_oneway_impl, FALSE);
    etchmap_insertxw(pserver_base->virtuals, examplemixin_valufact_get_static()->str_examplemixin_say_hello_mixin, say_hello_mixin_impl, FALSE);
    etchmap_insertxw(pserver_base->virtuals, examplemixin_valufact_get_static()->str_examplemixin_say_hello_mixin_oneway, say_hello_mixin_oneway_impl, FALSE);

    return pserver;
}


/**
 * destroy_example_server_implx()
 * destructor for any user allocated memory.
 * this code is invoked by the private perf_client_impl destructor,
 * via perf_client.destroyex(). add code here to destroy any memory you  
 * may have allocated for your custom perf_client implementation.
 */
int destroy_example_server_implx(void* data)
{
    /*
      example_server_impl* thisx = (example_server_impl*)data;
     */

    return 0;
}

/* - - - - - - - - - - - - - - - - - - -
 * session interface method overrides
 * - - - - - - - - - - - - - - - - - - -
 */

 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 * implementations of example_server messages from server, if any 
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 */

etch_string* say_hello_impl(void* thisx, etch_string* who) {
    etch_string* ret = NULL;
    wchar_t buffer[1024];
    etch_snwprintf(buffer, 1024, L"%s from server", who->v.valw);
    ret = new_stringw(buffer);
    etch_object_destroy(who);
    return ret;
}

void * say_hello_oneway_impl(void* thisx, etch_string* who) {
    example_server_impl* server = NULL;
    etch_string*         res    = NULL;

    printf("Server: oneway received\n");
    etch_object_destroy(who);

    server = (example_server_impl*)thisx;
    res = server->client->say_hello_oneway_client(server->client, new_stringa("Hello"));
    if(res != NULL) {
        etch_object_destroy(res);
    }

    return NULL;
}

etch_string* say_hello_mixin_impl(void* thisx, etch_string* who) {
    etch_string* ret = NULL;
    wchar_t buffer[1024];
    etch_snwprintf(buffer, 1024, L"%s from server", who->v.valw);
    ret = new_stringw(buffer);
    etch_object_destroy(who);
    return ret;
}

void * say_hello_mixin_oneway_impl(void* thisx, etch_string* who) {
    example_server_impl* server = NULL;
    etch_string*         res    = NULL;

    printf("Server-Mixin: oneway received\n");
    etch_object_destroy(who);

    server = (example_server_impl*)thisx;
    res = server->client->say_hello_mixin_oneway_client(server->client, new_stringa("Hello from server"));
    if(res != NULL) {
        etch_object_destroy(res);
    }

    return NULL;
}
