00001 #ifndef __NET_DLL_H__
00002 #define __NET_DLL_H__
00003
00004
00005
00006
00007 #include <CHM/CHMdataType.h>
00008 #include <CHM/CHMminCInclude.h>
00009
00010 #ifdef WIN32
00011 # define CHM_STD_CALL __stdcall
00012 #else
00013 # define CHM_STD_CALL
00014 #endif
00015
00016
00017 typedef void* NETserverHandle;
00018 typedef void* NETconnectionHandle;
00019 typedef void* NETuserHandle;
00020
00021 typedef void (CHM_STD_CALL *NETserverOnErrorCallback)
00022 (
00023 NETuserHandle UserHandle,
00024 NETserverHandle ServerHandle,
00025 int ErrorId,
00026 const char* pErrorMessage
00027 );
00028
00029 typedef void (CHM_STD_CALL *NETserverOnNewConnectionCallback)
00030 (
00031 NETuserHandle UserHandle,
00032 NETserverHandle ServerHandle,
00033 NETconnectionHandle TransportId,
00034 NETuserHandle* pConnectionUserHAndle
00035 );
00036
00037 typedef void (CHM_STD_CALL *NETserverOnCloseCallback)
00038 (
00039 NETuserHandle UserHandle,
00040 NETserverHandle ServerHandle
00041 );
00042
00043 typedef void (CHM_STD_CALL *NETtransportOnConnectCallback)
00044 (
00045 NETuserHandle UserHandle,
00046 NETconnectionHandle TransportId
00047 );
00048
00049 typedef void (CHM_STD_CALL *NETtransportOnMessageCallback)
00050 (
00051 NETuserHandle UserHandle,
00052 NETuserHandle ServerUserHandle,
00053 NETconnectionHandle TransportId,
00054 const char* pMessage
00055 );
00056
00057 typedef void (CHM_STD_CALL *NETtransportOnMessageSentCallback)
00058 (
00059 NETuserHandle UserHandle,
00060 NETuserHandle ServerUserHandle,
00061 NETconnectionHandle TransportId,
00062 const char* pMessage
00063 );
00064
00065 typedef void (CHM_STD_CALL *NETtransportOnCloseCallback)
00066 (
00067 NETuserHandle UserHandle,
00068 NETuserHandle ServerUserHandle,
00069 NETconnectionHandle TransportId
00070 );
00071
00072 typedef void (CHM_STD_CALL *NETtransportOnErrorCallback)
00073 (
00074 NETuserHandle UserHandle,
00075 NETuserHandle ServerUserHandle,
00076 NETconnectionHandle TransportId,
00077 int ErrorId,
00078 const char* pErrorMessage
00079 );
00080
00081 CHM_DLL_FUNC(NETstop)();
00082 CHM_DLL_FUNC(NETwait)();
00083
00084 CHM_DLL_FUNC(NETserverCreate)
00085 (
00086 NETuserHandle UserHandle,
00087 NETserverHandle* pServerHandle
00088 );
00089
00090 CHM_DLL_FUNC(NETserverDestroy)
00091 (
00092 NETserverHandle ServerHandle,
00093 NETuserHandle* pUserHandle
00094 );
00095
00096 CHM_DLL_FUNC(NETserverListen)
00097 (
00098 NETserverHandle ServerHandle,
00099 CHMuint16 Port
00100 );
00101
00102 CHM_DLL_FUNC(NETserverStopListening)( NETserverHandle ServerHandle );
00103
00104 CHM_DLL_FUNC(NETserverCloseAllConnections)( NETserverHandle ServerHandle );
00105
00106
00107 CHM_DLL_FUNC(NETtransportCreate)
00108 (
00109 NETuserHandle UserHandle,
00110 NETconnectionHandle* pConnectionHandle
00111 );
00112
00113 CHM_DLL_FUNC(NETtransportDestroy)
00114 (
00115 NETconnectionHandle ConnectionHandle,
00116 NETuserHandle* pUserHandle
00117 );
00118
00119 CHM_DLL_FUNC(NETtransportConnect)
00120 (
00121 NETconnectionHandle TransportId,
00122 const char* pHost,
00123 CHMuint16 Port
00124 );
00125
00126 CHM_DLL_FUNC(NETtransportSendMessage)
00127 (
00128 NETconnectionHandle TransportId,
00129 const char* pMessage
00130 );
00131
00132 CHM_DLL_FUNC(NETtransportGetIpAddress)
00133 (
00134 NETconnectionHandle TransportId,
00135 CHMuint32* pIpAddress
00136 );
00137
00138 CHM_DLL_FUNC(NETtransportIsConnected)
00139 (
00140 NETconnectionHandle TransportId,
00141 CHMuint32* pIsConnected
00142 );
00143
00144 CHM_DLL_FUNC(NETtransportGetIpAddressString)
00145 (
00146 NETconnectionHandle TransportId,
00147 const char** ppIpAddress
00148 );
00149
00150 CHM_DLL_FUNC(NETtransportGetHostName)
00151 (
00152 NETconnectionHandle TransportId,
00153 const char** ppHostName
00154 );
00155
00156 CHM_DLL_FUNC(NETtransportCloseConnection)( NETconnectionHandle TransportId );
00157
00158 CHM_DLL_FUNC(NETtransportHardCloseConnection)( NETconnectionHandle TransportId );
00159
00160 CHM_DLL_FUNC(NETsetServerOnErrorCallback)
00161 (
00162 NETserverOnErrorCallback Callback
00163 );
00164
00165 CHM_DLL_FUNC(NETsetServerOnNewConnectionCallback)
00166 (
00167 NETserverOnNewConnectionCallback Callback
00168 );
00169
00170 CHM_DLL_FUNC(NETsetTransportOnConnectCallback)
00171 (
00172 NETtransportOnConnectCallback Callback
00173 );
00174
00175 CHM_DLL_FUNC(NETsetTransportOnCloseCallback)
00176 (
00177 NETtransportOnCloseCallback Callback
00178 );
00179
00180 CHM_DLL_FUNC(NETsetTransportOnMessageCallback)
00181 (
00182 NETtransportOnMessageCallback Callback
00183 );
00184
00185 CHM_DLL_FUNC(NETsetTransportOnMessageSentCallback)
00186 (
00187 NETtransportOnMessageSentCallback Callback
00188 );
00189
00190 CHM_DLL_FUNC(NETsetTransportOnErrorCallback)
00191 (
00192 NETtransportOnErrorCallback Callback
00193 );
00194
00195 #endif // end of defensive include