[openamq-dev] MS C# using Windows dll with exports.
Bo Kohut
bo.kohut at gmail.com
Fri Apr 25 21:35:13 CEST 2008
All,
Just saw a request come through for .Net working code. Several weeks ago my
free time was consumed to another direction but here is what I got to work.
I am building the project producing the dlls with exports that Martin
provided in another response (There may have been minor tweaks to get his
project compiling? Can't clearly recall.) Here is the .Net code, I hope you
are aware of the basics to get this working, if you add to it please share.
!!!!! This is only PARTIALLY functioning, it is a stating point. This
code gpf's when closing the connection but does connect (Argh I spent days
on getting structures correct). Do recall my goal was to reuse the already
existing C client code that imatrix coded and manages.
**********************************************************************************************
amq_safe.cs
**********************************************************************************************
using System;
using System.Runtime.InteropServices;
using System.Text;
//
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconstructssample.asp
// http://www.codersource.net/csharp_unsafe_code.html
// http://www.codeproject.com/KB/cs/unsafe.aspx
//http://msdn2.microsoft.com/en-us/library/aa288474(VS.71).aspx
namespace Amq_Safe
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct S_strc_icl_longstr_t
{
public uint object_tag;
public uint cur_size;
public uint max_size;
public byte pbData;
};
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct S_strc_icl_shortstr_t
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string sData;
};
//public unsafe struct S_strc_icl_shortstr_t
//{
// public fixed char sData[128];
//};
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct S_strc_icl_rwlock_t
{
public uint object_tag;
public uint pstrc_apr_thread_rwlock_t;
public uint pstrc_apr_pool_t;
};
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct S_strc_amq_client_connection_t
{
public S_strc_icl_rwlock_t rwlock; // Read Write lock
public ushort object_tag; // Object validity
marker
public ushort pthread; // Thread for this
connection (Structure NOT defined here)
public ushort pmethod_queue; // Replies from
protocol agent (Structure NOT defined here)
public ushort channel_nbr; // Top channel opened
so far
public bool silent; // Don't print errors
public bool alive; // Connection is alive?
public bool interrupt; // Application was
interrupted?
public bool shutdown; // We were shutdown
public int timeout; // Connection timeout,
msecs
public IntPtr error_text; // Last error cause
public byte version_major; // protocol major
version
public byte version_minor; // protocol major
version
public ushort channel_max; // proposed maximum
channels
public uint frame_max; // proposed maximum
frame size
public ushort heartbeat; // desired heartbeat
delay
public S_strc_icl_shortstr_t known_hosts; // list of known hosts
public S_strc_icl_shortstr_t host; // server to connect to
public ushort reply_code; // reply code from
server
public S_strc_icl_shortstr_t reply_text; // localised reply text
public ushort class_id; // failing method class
public ushort method_id; // failing method ID
public S_strc_icl_shortstr_t server_host;
public S_strc_icl_shortstr_t server_name;
public S_strc_icl_shortstr_t server_product;// Reported by server
public S_strc_icl_shortstr_t server_version;
public S_strc_icl_shortstr_t server_platform;
public S_strc_icl_shortstr_t server_copyright;
public S_strc_icl_shortstr_t server_information;
public S_strc_icl_shortstr_t server_instance;
};
/*
struct _smt_thread_t {
#if (defined (BASE_THREADSAFE))
icl_rwlock_t * rwlock;
#endif
volatile int links; // Number of links to
the item
volatile qbyte zombie; // Object destroyed
but not freed
#if defined (DEBUG) || defined (BASE_HISTORY) || defined
(BASE_HISTORY_SMT_THREAD)
// Possession history, for tracing
volatile qbyte history_last;
char *history_file [SMT_THREAD_HISTORY_LENGTH];
int history_line [SMT_THREAD_HISTORY_LENGTH];
char *history_type [SMT_THREAD_HISTORY_LENGTH];
int history_links [SMT_THREAD_HISTORY_LENGTH];
#endif
dbyteobject_tag; // Object validity marker
volatile smt_thread_by_status_t *by_status_head;
volatile smt_thread_t *by_status_prev;
volatile smt_thread_t *by_status_next;
volatile smt_thread_queue_t *queue_head;
volatile smt_thread_t *queue_prev;
volatile smt_thread_t *queue_next;
volatile smt_thread_list_t *list_head;
volatile smt_thread_t *list_prev;
volatile smt_thread_t *list_next;
smt_os_thread_t *os_thread; // OS thread running this
thread
smt_thread_p_fn *manager; // Agent manager
function
smt_thread_fn *catcher; // Agent error catch
function
smt_thread_fn *destructor; // Agent error catch
function
smt_thread_id_t id; // Thread ID
smt_priority_t priority; // Thread priority
smt_poll_tag_t poll_tag; // Poll tag at last thread
service
smt_place_t place; // Current location in
dialog
smt_module_t module; // Index in module list
smt_method_t *method; // Last method received
smt_event_t _next_event; // Next
event
smt_event_t _exception_event; // Exception
event
Bool _exception_raised; // Did an exception
occur?
Bool animate; // Animation
enabled?
Bool shutting_down; // Thread is shutting
down
Bool shutdown_request; // Request thread to shut
down
smt_signal_by_thread_t *signal_list; // Signal registered with
thread
volatile Bool signal_raised; // Set when a signal was
sent
smt_event_t signal_event; // Event to send on signal
volatile qbyte status; // Thread status
int schedule; // Scheduler for this
thread
void *context; // Thread-specific
data
int result; // Result of last
operation
int error; // System error number on
error
smt_socket_request_t *monitor; // Monitor socket
request
qbyte pending_count; // No. io/timer op'ns
pending
smt_method_queue_t *reply_queue; // Queued replies for
thread
smt_method_list_t *reply_list; // Local sorted list of
replies
volatile qbyte reply_backlog; // Local count of reply
backlog
smt_position_list_t *position_stack; // Stack of dialog
positions
smt_thread_t *watched_thread; // Thread we are watching
smt_thread_t *watching_thread; // Thread watching us
smt_timer_request_by_thread_t *timer_request_list; // List of
timer requests
smt_socket_request_by_thread_t *socket_request_list; // List of
socket requests
smt_socket_request_t *write_request; // To optimise on polling
const char **event_name; // Event names for
debugging
icl_trace_t *trace;
#if (defined (BASE_STATS) || defined (BASE_STATS_SMT_THREAD))
icl_stats_t *method_same_os_thread_stat,
*method_other_os_thread_stat;
#endif
};
*/
/*
struct _smt_method_queue_t {
volatile int links; // Number of links to
the item
volatile qbyte zombie; // Object destroyed
but not freed
#if defined (DEBUG) || defined (BASE_HISTORY) || defined
(BASE_HISTORY_SMT_METHOD_QUEUE)
// Possession history, for tracing
volatile qbyte history_last;
char *history_file [SMT_METHOD_QUEUE_HISTORY_LENGTH];
int history_line [SMT_METHOD_QUEUE_HISTORY_LENGTH];
char *history_type [SMT_METHOD_QUEUE_HISTORY_LENGTH];
int history_links [SMT_METHOD_QUEUE_HISTORY_LENGTH];
#endif
dbyte object_tag; // Object validity marker
#if defined (BASE_THREADSAFE) && defined (BASE_LOCKFREE)
apr_pool_t *pool;
apr_threadkey_t *key; // For thread-local
data
volatile llsc_t *head, *tail;
icl_lfcontext_list_t *contexts; // One context
per OS thread
#else
volatile smt_method_t *head, *tail;
# if defined (BASE_THREADSAFE)
icl_mutex_t * mutex;
# endif
#endif
volatile qbyte count;
smt_method_queue_notify_fn *notify; //
Callback on insert & destroy
void *data; // For notify
functions
#if (defined (BASE_THREADSAFE))
icl_mutex_t *sync_mutex; // Synchronisation
mutex
icl_cond_t *sync_cond; // Synchronisation
cond'n variable
volatile qbyte sync_wait_cnt; // Number of threads
waiting
#else
Bool sync; // Is this a synchronising
thread?
#endif
};
*/
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct S_strc_amq_client_session_t
{
public S_strc_icl_rwlock_t rwlock; // Read Write lock
public ushort object_tag; // Object validity
marker
//public byte pconnection; // Parent connection
object
//public byte pmethod_queue; // Replies from
protocol agent
public ushort pconnection; // Parent connection
object
public ushort pmethod_queue; // Replies from
protocol agent
//public IntPtr pconnection; // Parent connection
object
//public IntPtr pmethod_queue; // Replies from
protocol agent
public bool silent;
public bool alive;
public volatile int flow_stopped;
public IntPtr error_text;
public bool active;
}
/*
struct _amq_client_session_t {
#if (defined (BASE_THREADSAFE))
icl_rwlock_t * rwlock;
#endif
dbyte object_tag; // Object validity marker
amq_client_connection_t *connection; // Parent
connection object
smt_method_queue_t *method_queue; // Replies from
protocol agent
dbyte channel_nbr; // Session channel number
Bool silent; // Don't print errors
Bool alive; // Is the session alive?
volatile qbyte flow_stopped; // Is flow of
messages from server stopped?
char *error_text; // Last error cause
Bool
active; // start/stop content frames
dbyte
reply_code; // reply code from server
icl_shortstr_t
reply_text; // localised reply text
dbyte
class_id; // failing method class
dbyte
method_id; // failing method ID
dbyte
ticket; // access ticket granted by server
icl_shortstr_t
queue; // queue name
qbyte
message_count; // number of messages in queue
qbyte
consumer_count; // number of consumers
icl_shortstr_t
consumer_tag; // consumer tag
icl_shortstr_t
exchange; // exchange name
icl_shortstr_t
routing_key; // Message routing key
int64_t
delivery_tag; // server-assigned delivery tag
Bool
redelivered; // message is being redelivered
icl_shortstr_t
sender_id; // Sender id
icl_shortstr_t
identifier; // staging identifier
int64_t
content_size; // message content size
int64_t
staged_size; // already staged amount
// Handling for stream messages
amq_content_stream_list_t
*arrived_stream_list; // stream messages
amq_content_stream_list_t
*returned_stream_list; // Returned stream messages
// Handling for tunnel messages
amq_content_tunnel_list_t
*arrived_tunnel_list; // tunnel messages
amq_content_tunnel_list_t
*returned_tunnel_list; // Returned tunnel messages
// Handling for basic messages
amq_content_basic_list_t
*arrived_basic_list; // basic messages
amq_content_basic_list_t
*returned_basic_list; // Returned basic messages
// Handling for file messages
amq_content_file_list_t
*arrived_file_list; // file messages
amq_content_file_list_t
*returned_file_list; // Returned file messages
};
*/
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct S_strc_amq_content_basic_t
{
public volatile int links; // Number of
links to the item
public volatile int zombie; // Object
destroyed but not freed
/*
#if defined (DEBUG) || defined (BASE_HISTORY) || defined
(BASE_HISTORY_AMQ_CONTENT_BASIC)
// Possession history, for tracing
volatile qbyte history_last;
char *history_file [AMQ_CONTENT_BASIC_HISTORY_LENGTH];
int history_line [AMQ_CONTENT_BASIC_HISTORY_LENGTH];
char *history_type [AMQ_CONTENT_BASIC_HISTORY_LENGTH];
int history_links [AMQ_CONTENT_BASIC_HISTORY_LENGTH];
#endif
dbyte object_tag; // Object validity marker
dbyte class_id, // Content class
weight; // Content weight
ipr_bucket_list_t *bucket_list; // List of message
buckets
int64_t body_size, // Size of content body data
body_expect; // Expected size of body
data
byte *body_data; // Body set by application
icl_mem_free_fn *free_fn; // Function to free
appl_body
icl_shortstr_t exchange, // Exchange specified
by publish
routing_key, // Routing key
specified by publish
producer_id; // Connection
identifier of producer
// Used internally by servers processing the content
Bool immediate, // Immediate delivery wanted
returned; // Content was returned
// Content properties
icl_shortstr_t content_type; // MIME content type
icl_shortstr_t content_encoding; // MIME content
encoding
icl_longstr_t * headers; // Message header
field table
byte delivery_mode; // Non-persistent (1) or
persistent (2)
byte priority; // The message priority, 0 to 9
icl_shortstr_t correlation_id; // The application
correlation identifier
icl_shortstr_t reply_to; // The destination to
reply to
icl_shortstr_t expiration; // Message expiration
specification
icl_shortstr_t message_id; // The application
message identifier
int64_t timestamp; // The message timestamp
icl_shortstr_t type; // The message type
name
icl_shortstr_t user_id; // The creating user
id
icl_shortstr_t app_id; // The creating
application id
icl_shortstr_t sender_id; // Identifier of
connection sending the message
*/
};
class AmqSafe
{
//********************************************************************************
[DllImport("oamqclistd.dll", EntryPoint = "icl_system_initialise",
ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static private extern void fn_icl_system_initialise(int argc, ref
IntPtr argv);
public void AmqInitialise(int ArgCount, ref IntPtr Args)
{
fn_icl_system_initialise(ArgCount, ref Args);
return;
}
//********************************************************************************
[DllImport("oamqclistd.dll", EntryPoint = "icl_system_terminate",
ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static private extern void fn_icl_system_terminate();
public void AmqTerminate()
{
fn_icl_system_terminate();
return;
}
//********************************************************************************
[DllImport("oamqclistd.dll", EntryPoint =
"amq_client_connection_auth_plain", ExactSpelling = true, CallingConvention
= CallingConvention.Cdecl)]
static private extern IntPtr
fn_amq_client_connection_auth_plain(string pszUserName, string pszPassword);
public IntPtr AmqAuthPlain(string sShapeFile, string sAccess)
{
IntPtr ptrTemp = IntPtr.Zero;
ptrTemp = fn_amq_client_connection_auth_plain(sShapeFile,
sAccess);
return ptrTemp;
}
//********************************************************************************
[DllImport("oamqclistd.dll", EntryPoint = "icl_longstr_destroy_",
ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static private extern void fn_icl_longstr_destroy(ref IntPtr
ptr_strc_icl_longstr_t, string sFile, int iLength);
public void LongStrDestroy(ref IntPtr pStructLongStr)
{
fn_icl_longstr_destroy(ref pStructLongStr, "", 0);
return;
}
//********************************************************************************
[DllImport("oamqclistd.dll", EntryPoint =
"amq_client_connection_new_", ExactSpelling = true, CallingConvention =
CallingConvention.Cdecl)]
static private extern IntPtr fn_amq_client_connection_new(string
sFile, int iLength, string pszHost, string pszVirtualHost, ref
S_strc_icl_longstr_t strc_icl_longstr_t, string pszInstance, int piTrace,
int piTimeout);
public IntPtr AmqClientConnectionCreate(string sHost, string
sVirtualHost, ref S_strc_icl_longstr_t StructAuthData, string pszInstance,
int iTrace, int iTimeout)
{
IntPtr ptrTemp = IntPtr.Zero;
ptrTemp = fn_amq_client_connection_new("", 0, sHost,
sVirtualHost, ref StructAuthData, pszInstance, iTrace, iTimeout);
return ptrTemp;
}
//********************************************************************************
[DllImport("oamqclistd.dll", EntryPoint =
"amq_client_connection_destroy_", ExactSpelling = true, CallingConvention =
CallingConvention.Cdecl)]
static private extern void fn_amq_client_connection_destroy(string
sFile, int iLength, ref IntPtr ptr_strc_amq_client_connection_t);
public void AmqClientConnectionDestroy(ref IntPtr
ptrStructClientConn)
{
fn_amq_client_connection_destroy("", 0, ref
ptrStructClientConn);
return;
}
//********************************************************************************
[DllImport("oamqclistd.dll", EntryPoint = "amq_client_session_new_",
ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static private extern IntPtr fn_amq_client_session_new(string sFile,
int iLength, ref S_strc_amq_client_connection_t strc_amq_client_connection);
public IntPtr AmqClientSessionCreate(ref
S_strc_amq_client_connection_t StructConnection)
{
IntPtr ptrTemp = IntPtr.Zero;
ptrTemp = fn_amq_client_session_new("", 0, ref
StructConnection);
return ptrTemp;
}
//********************************************************************************
[DllImport("oamqclistd.dll", EntryPoint =
"amq_client_session_destroy_", ExactSpelling = true, CallingConvention =
CallingConvention.Cdecl)]
static private extern void fn_amq_client_session_destroy(string
sFile, int iLength, ref IntPtr ptr_strc_amq_client_session_t);
public void AmqClientSessionDestroy(ref IntPtr ptrStructSession)
{
fn_amq_client_session_destroy("", 0, ref ptrStructSession);
return;
}
//********************************************************************************
[DllImport("oamqclistd.dll", EntryPoint = "amq_content_basic_new_",
ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static private extern IntPtr fn_amq_content_basic_new(string sFile,
int iLength);
public IntPtr AmqContentBasicCreate()
{
IntPtr ptrTemp = IntPtr.Zero;
ptrTemp = fn_amq_content_basic_new("", 0);
return ptrTemp;
}
//********************************************************************************
[DllImport("oamqclistd.dll", EntryPoint =
"amq_content_basic_destroy_", ExactSpelling = true, CallingConvention =
CallingConvention.Cdecl)]
static private extern void fn_amq_content_basic_destroy(ref IntPtr
strc_amq_content_basic_t, string sFile, int iLength);
public void AmqContentBasicDestroy(ref IntPtr pStructLongStr)
{
fn_amq_content_basic_destroy(ref pStructLongStr, "", 0);
return;
}
//********************************************************************************
//[DllImport("oamqclistd.dll", EntryPoint =
"amq_content_basic_set_body", ExactSpelling = true, CallingConvention =
CallingConvention.Cdecl)]
//static private extern int fn_amq_content_basic_set_body(ref
S_strc_amq_content_basic_t strc_amq_content_basic_t, IntPtr ptrData, int
iLength, ref IntPtr ptrFreeFunc);
//public void AmqContentBasicSetBody(ref IntPtr pStructLongStr)
//{
// fn_amq_content_basic_set_body();
// return;
//}
//********************************************************************************
//[DllImport("oamqclistd.dll", EntryPoint =
"amq_content_basic_set_message_id", ExactSpelling = true, CallingConvention
= CallingConvention.Cdecl)]
//static private extern int fn_amq_content_basic_set_message_id(ref
S_strc_amq_content_basic_t strc_amq_content_basic_t, string sMsgId, ref
IntPtr argv);
//public void AmqContentBasicSetMsgId(ref IntPtr pStructLongStr)
//{
// fn_amq_content_basic_set_body();
// return;
//}
//********************************************************************************
}
}
**********************************************************************************************
**********************************************************************************************
wrapper.cs
**********************************************************************************************
using System;
using System.Runtime.InteropServices;
using System.Text;
using Amq_Safe;
namespace wrappertest
{
class wrapperclass
{
static void Main(string[] args)
{
Call_Amq_Safe();
}
static void Call_Amq_Safe()
{
Console.WriteLine("");
Console.WriteLine("Call_Amq_Safe");
AmqSafe oAmqSafe = new AmqSafe();
Console.WriteLine("");
Console.WriteLine("Attempting AmqInitialise");
IntPtr pArgs = IntPtr.Zero;
oAmqSafe.AmqInitialise(0, ref pArgs);
Console.WriteLine("Succeeded AmqInitialise");
Console.WriteLine("");
Console.WriteLine("Attempting AmqAuthPlain");
IntPtr ptrAuthData = IntPtr.Zero;
ptrAuthData = oAmqSafe.AmqAuthPlain("guest", "guest");
Console.WriteLine("Succeeded AmqAuthPlain");
Console.WriteLine("pointer ptrAuthData: " +
ptrAuthData.ToInt32().ToString());
Console.WriteLine("");
Console.WriteLine("Marshalling authdata structure");
S_strc_icl_longstr_t strcAuthData;
strcAuthData =
(S_strc_icl_longstr_t)Marshal.PtrToStructure(ptrAuthData,
typeof(S_strc_icl_longstr_t));
Console.WriteLine("");
Console.WriteLine("Object: " + strcAuthData.object_tag);
Console.WriteLine("Cur Size: " + strcAuthData.cur_size);
Console.WriteLine("Max Size: " + strcAuthData.max_size);
Console.WriteLine("");
Console.WriteLine("Attempting AmqClientConnectionCreate");
IntPtr ptrClientConn = IntPtr.Zero;
ptrClientConn = oAmqSafe.AmqClientConnectionCreate("localhost",
"/", ref strcAuthData, "amq_client", 0, 30000);
Console.WriteLine("Succeeded AmqClientConnectionCreate");
Console.WriteLine("Clean up Auth structure");
if (ptrAuthData != IntPtr.Zero)
{
Console.WriteLine("ptrAuthData pointer exists");
Console.WriteLine("pointer ptrAuthData: " +
ptrAuthData.ToInt32().ToString());
Console.WriteLine("");
Console.WriteLine("Attempting LongStrDestroy");
oAmqSafe.LongStrDestroy(ref ptrAuthData);
Console.WriteLine("Succeeded LongStrDestroy");
if (ptrAuthData == IntPtr.Zero)
{
Console.WriteLine("ptrAuthData pointer destroyed");
}
else
{
Console.WriteLine("Unable to destroy ptrAuthData
pointer");
}
}
else
{
Console.WriteLine("Null ptrAuthData pointer");
}
Console.WriteLine("");
Console.WriteLine("Test connection pointer");
if (ptrClientConn != IntPtr.Zero)
{
Console.WriteLine("");
Console.WriteLine("Marshalling connection structure");
S_strc_amq_client_connection_t strcConnection;
strcConnection =
(S_strc_amq_client_connection_t)Marshal.PtrToStructure(ptrClientConn,
typeof(S_strc_amq_client_connection_t));
Console.WriteLine("");
Console.WriteLine("Connection structure marshalled");
Console.WriteLine("");
Console.WriteLine("Testing connection 'alive' structure
property.");
Console.WriteLine("");
//Console.WriteLine("strcConnection.rwlock.object_tag: " +
strcConnection.rwlock.object_tag);
//Console.WriteLine("strcConnection.rwlock.pstrc_apr_pool_t:
" + strcConnection.rwlock.pstrc_apr_pool_t.ToString());
//Console.WriteLine("strcConnection.rwlock.pstrc_apr_thread_rwlock_t: " +
strcConnection.rwlock.pstrc_apr_thread_rwlock_t.ToString());
Console.WriteLine("strcConnection.object_tag: " +
strcConnection.object_tag);
//Console.WriteLine("strcConnection.pthread: " +
strcConnection.pthread);
//Console.WriteLine("strcConnection.pmethod_queue: " +
strcConnection.pmethod_queue);
Console.WriteLine("strcConnection.channel_nbr: " +
strcConnection.channel_nbr);
Console.WriteLine("strcConnection.silent: " +
strcConnection.silent);
Console.WriteLine("strcConnection.alive: " +
strcConnection.alive);
Console.WriteLine("strcConnection.interrupt: " +
strcConnection.interrupt);
Console.WriteLine("strcConnection.shutdown: " +
strcConnection.shutdown);
Console.WriteLine("strcConnection.timeout: " +
strcConnection.timeout.ToString());
string error_text =
Marshal.PtrToStringAnsi(strcConnection.error_text);
Console.WriteLine("strcConnection.error_text ptr to string:
" + error_text);
Console.WriteLine("strcConnection.version_major: " +
strcConnection.version_major);
Console.WriteLine("strcConnection.version_minor: " +
strcConnection.version_minor);
Console.WriteLine("strcConnection.channel_max: " +
strcConnection.channel_max);
Console.WriteLine("strcConnection.frame_max: " +
strcConnection.frame_max);
Console.WriteLine("strcConnection.heartbeat: " +
strcConnection.heartbeat);
Console.WriteLine("strcConnection.known_hosts: " +
strcConnection.known_hosts.sData);
Console.WriteLine("strcConnection.host: " +
strcConnection.host.sData);
Console.WriteLine("strcConnection.reply_code: " +
strcConnection.reply_code);
Console.WriteLine("strcConnection.reply_text: " +
strcConnection.reply_text.sData);
Console.WriteLine("strcConnection.class_id: " +
strcConnection.class_id);
Console.WriteLine("strcConnection.method_id: " +
strcConnection.method_id);
Console.WriteLine("strcConnection.server_host: " +
strcConnection.server_host.sData);
Console.WriteLine("strcConnection.server_name: " +
strcConnection.server_name.sData);
Console.WriteLine("strcConnection.server_product: " +
strcConnection.server_product.sData);
Console.WriteLine("strcConnection.server_version: " +
strcConnection.server_version.sData);
Console.WriteLine("strcConnection.server_platform: " +
strcConnection.server_platform.sData);
Console.WriteLine("strcConnection.server_copyright: " +
strcConnection.server_copyright.sData);
Console.WriteLine("strcConnection.server_information: " +
strcConnection.server_information.sData);
Console.WriteLine("strcConnection.server_instance: " +
strcConnection.server_instance.sData);
if (strcConnection.alive)
{
Console.WriteLine("");
Console.WriteLine("Connected to server.");
//Console.WriteLine("");
//Console.WriteLine("Attempting
AmqClientSessionCreate");
//IntPtr ptrSession = IntPtr.Zero;
//ptrSession = oAmqSafe.AmqClientSessionCreate(ref
strcConnection);
//Console.WriteLine("Succeeded AmqClientSessionCreate");
//Console.WriteLine("");
//Console.WriteLine("Test session pointer");
//if (ptrSession != IntPtr.Zero)
//{
// Console.WriteLine("");
// Console.WriteLine("Attempting
AmqContentBasicCreate");
// IntPtr ptrContent = IntPtr.Zero;
// ptrContent = oAmqSafe.AmqContentBasicCreate();
// Console.WriteLine("Succeeded
AmqContentBasicCreate");
// Console.WriteLine("");
// Console.WriteLine("Marshalling content
structure");
// S_strc_amq_content_basic_t strcContent;
// strcContent =
(S_strc_amq_content_basic_t)Marshal.PtrToStructure(ptrContent,
typeof(S_strc_amq_content_basic_t));
// Console.WriteLine("");
// Console.WriteLine("Content structure marshalled");
// //Set body
// //Set Msg Id
// //Session Basic Publish
// Console.WriteLine("");
// Console.WriteLine("Test content pointer");
// if (ptrContent != IntPtr.Zero)
// {
// Console.WriteLine("");
// Console.WriteLine("Attempting
AmqContentBasicDestroy");
// oAmqSafe.AmqContentBasicDestroy(ref
ptrContent);
// Console.WriteLine("Succeeded
AmqContentBasicDestroy");
// }
//}
Console.WriteLine("");
Console.WriteLine("Attempting
AmqClientConnectionDestroy");
oAmqSafe.AmqClientConnectionDestroy(ref ptrClientConn);
Console.WriteLine("Succeeded
AmqClientConnectionDestroy");
}
else
{
Console.WriteLine("");
Console.WriteLine("Could not connect to server.");
}
//IntPtr ptrContentBasic = IntPtr.Zero;
//ptrContentBasic = AmqContentBasicCreate();
//AmqContentBasicDestroy(ptrContentBasic);
}
Console.WriteLine("");
Console.WriteLine("Attempting AmqTerminate");
oAmqSafe.AmqTerminate();
Console.WriteLine("Succeeded AmqTerminate");
}
}
}
**********************************************************************************************
--
Bo Kohut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openamq.org/pipermail/openamq-dev/attachments/20080425/2b067398/attachment-0001.htm
More information about the openamq-dev
mailing list