Export static symbols when building ws with shared library (#370)
This commit is contained in:
parent
f7eb3688dd
commit
a3d2fa4b7e
@ -99,6 +99,7 @@ set( IXWEBSOCKET_HEADERS
|
|||||||
ixwebsocket/IXWebSocketCloseConstants.h
|
ixwebsocket/IXWebSocketCloseConstants.h
|
||||||
ixwebsocket/IXWebSocketCloseInfo.h
|
ixwebsocket/IXWebSocketCloseInfo.h
|
||||||
ixwebsocket/IXWebSocketErrorInfo.h
|
ixwebsocket/IXWebSocketErrorInfo.h
|
||||||
|
ixwebsocket/IXWebsocketExport.h
|
||||||
ixwebsocket/IXWebSocketHandshake.h
|
ixwebsocket/IXWebSocketHandshake.h
|
||||||
ixwebsocket/IXWebSocketHandshakeKeyGen.h
|
ixwebsocket/IXWebSocketHandshakeKeyGen.h
|
||||||
ixwebsocket/IXWebSocketHttpHeaders.h
|
ixwebsocket/IXWebSocketHttpHeaders.h
|
||||||
@ -173,6 +174,10 @@ else()
|
|||||||
${IXWEBSOCKET_SOURCES}
|
${IXWEBSOCKET_SOURCES}
|
||||||
${IXWEBSOCKET_HEADERS}
|
${IXWEBSOCKET_HEADERS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if( MSVC )
|
||||||
|
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_STATIC_DEFINE)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_TLS)
|
if (USE_TLS)
|
||||||
@ -286,6 +291,7 @@ if (IXWEBSOCKET_INSTALL)
|
|||||||
install(TARGETS ixwebsocket
|
install(TARGETS ixwebsocket
|
||||||
EXPORT ixwebsocket
|
EXPORT ixwebsocket
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ixwebsocket/
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ixwebsocket/
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "IXCancellationRequest.h"
|
#include "IXCancellationRequest.h"
|
||||||
|
#include "IXWebsocketExport.h"
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@ -54,7 +55,7 @@ namespace ix
|
|||||||
std::string _hostname;
|
std::string _hostname;
|
||||||
int _port;
|
int _port;
|
||||||
int64_t _wait;
|
int64_t _wait;
|
||||||
const static int64_t kDefaultWait;
|
IXWEBSOCKET_EXPORT const static int64_t kDefaultWait;
|
||||||
|
|
||||||
struct addrinfo* _res;
|
struct addrinfo* _res;
|
||||||
std::mutex _resMutex;
|
std::mutex _resMutex;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "IXSocket.h"
|
#include "IXSocket.h"
|
||||||
#include "IXSocketTLSOptions.h"
|
#include "IXSocketTLSOptions.h"
|
||||||
#include "IXWebSocketHttpHeaders.h"
|
#include "IXWebSocketHttpHeaders.h"
|
||||||
|
#include "IXWebsocketExport.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
@ -91,12 +92,12 @@ namespace ix
|
|||||||
|
|
||||||
std::string urlEncode(const std::string& value);
|
std::string urlEncode(const std::string& value);
|
||||||
|
|
||||||
const static std::string kPost;
|
IXWEBSOCKET_EXPORT const static std::string kPost;
|
||||||
const static std::string kGet;
|
IXWEBSOCKET_EXPORT const static std::string kGet;
|
||||||
const static std::string kHead;
|
IXWEBSOCKET_EXPORT const static std::string kHead;
|
||||||
const static std::string kDelete;
|
IXWEBSOCKET_EXPORT const static std::string kDelete;
|
||||||
const static std::string kPut;
|
IXWEBSOCKET_EXPORT const static std::string kPut;
|
||||||
const static std::string kPatch;
|
IXWEBSOCKET_EXPORT const static std::string kPatch;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void log(const std::string& msg, HttpRequestArgsPtr args);
|
void log(const std::string& msg, HttpRequestArgsPtr args);
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "IXHttp.h"
|
#include "IXHttp.h"
|
||||||
#include "IXSocketServer.h"
|
#include "IXSocketServer.h"
|
||||||
#include "IXWebSocket.h"
|
#include "IXWebSocket.h"
|
||||||
|
#include "IXWebsocketExport.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@ -46,7 +47,7 @@ namespace ix
|
|||||||
OnConnectionCallback _onConnectionCallback;
|
OnConnectionCallback _onConnectionCallback;
|
||||||
std::atomic<int> _connectedClientsCount;
|
std::atomic<int> _connectedClientsCount;
|
||||||
|
|
||||||
const static int kDefaultTimeoutSecs;
|
IXWEBSOCKET_EXPORT const static int kDefaultTimeoutSecs;
|
||||||
int _timeoutSecs;
|
int _timeoutSecs;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "IXNetSystem.h"
|
#include "IXNetSystem.h"
|
||||||
#include "IXSelectInterrupt.h"
|
#include "IXSelectInterrupt.h"
|
||||||
#include "IXSocketTLSOptions.h"
|
#include "IXSocketTLSOptions.h"
|
||||||
|
#include "IXWebsocketExport.h"
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@ -48,11 +49,11 @@ namespace ix
|
|||||||
// that inherits from ConnectionState but has its own methods.
|
// that inherits from ConnectionState but has its own methods.
|
||||||
void setConnectionStateFactory(const ConnectionStateFactory& connectionStateFactory);
|
void setConnectionStateFactory(const ConnectionStateFactory& connectionStateFactory);
|
||||||
|
|
||||||
const static int kDefaultPort;
|
IXWEBSOCKET_EXPORT const static int kDefaultPort;
|
||||||
const static std::string kDefaultHost;
|
IXWEBSOCKET_EXPORT const static std::string kDefaultHost;
|
||||||
const static int kDefaultTcpBacklog;
|
IXWEBSOCKET_EXPORT const static int kDefaultTcpBacklog;
|
||||||
const static size_t kDefaultMaxConnections;
|
IXWEBSOCKET_EXPORT const static size_t kDefaultMaxConnections;
|
||||||
const static int kDefaultAddressFamily;
|
IXWEBSOCKET_EXPORT const static int kDefaultAddressFamily;
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
std::pair<bool, std::string> listen();
|
std::pair<bool, std::string> listen();
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "IXWebsocketExport.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -13,25 +14,25 @@ namespace ix
|
|||||||
{
|
{
|
||||||
struct WebSocketCloseConstants
|
struct WebSocketCloseConstants
|
||||||
{
|
{
|
||||||
static const uint16_t kNormalClosureCode;
|
IXWEBSOCKET_EXPORT static const uint16_t kNormalClosureCode;
|
||||||
static const uint16_t kInternalErrorCode;
|
IXWEBSOCKET_EXPORT static const uint16_t kInternalErrorCode;
|
||||||
static const uint16_t kAbnormalCloseCode;
|
IXWEBSOCKET_EXPORT static const uint16_t kAbnormalCloseCode;
|
||||||
static const uint16_t kProtocolErrorCode;
|
IXWEBSOCKET_EXPORT static const uint16_t kProtocolErrorCode;
|
||||||
static const uint16_t kNoStatusCodeErrorCode;
|
IXWEBSOCKET_EXPORT static const uint16_t kNoStatusCodeErrorCode;
|
||||||
static const uint16_t kInvalidFramePayloadData;
|
IXWEBSOCKET_EXPORT static const uint16_t kInvalidFramePayloadData;
|
||||||
|
|
||||||
static const std::string kNormalClosureMessage;
|
IXWEBSOCKET_EXPORT static const std::string kNormalClosureMessage;
|
||||||
static const std::string kInternalErrorMessage;
|
IXWEBSOCKET_EXPORT static const std::string kInternalErrorMessage;
|
||||||
static const std::string kAbnormalCloseMessage;
|
IXWEBSOCKET_EXPORT static const std::string kAbnormalCloseMessage;
|
||||||
static const std::string kPingTimeoutMessage;
|
IXWEBSOCKET_EXPORT static const std::string kPingTimeoutMessage;
|
||||||
static const std::string kProtocolErrorMessage;
|
IXWEBSOCKET_EXPORT static const std::string kProtocolErrorMessage;
|
||||||
static const std::string kNoStatusCodeErrorMessage;
|
IXWEBSOCKET_EXPORT static const std::string kNoStatusCodeErrorMessage;
|
||||||
static const std::string kProtocolErrorReservedBitUsed;
|
IXWEBSOCKET_EXPORT static const std::string kProtocolErrorReservedBitUsed;
|
||||||
static const std::string kProtocolErrorPingPayloadOversized;
|
IXWEBSOCKET_EXPORT static const std::string kProtocolErrorPingPayloadOversized;
|
||||||
static const std::string kProtocolErrorCodeControlMessageFragmented;
|
IXWEBSOCKET_EXPORT static const std::string kProtocolErrorCodeControlMessageFragmented;
|
||||||
static const std::string kProtocolErrorCodeDataOpcodeOutOfSequence;
|
IXWEBSOCKET_EXPORT static const std::string kProtocolErrorCodeDataOpcodeOutOfSequence;
|
||||||
static const std::string kProtocolErrorCodeContinuationOpCodeOutOfSequence;
|
IXWEBSOCKET_EXPORT static const std::string kProtocolErrorCodeContinuationOpCodeOutOfSequence;
|
||||||
static const std::string kInvalidFramePayloadDataMessage;
|
IXWEBSOCKET_EXPORT static const std::string kInvalidFramePayloadDataMessage;
|
||||||
static const std::string kInvalidCloseCodeMessage;
|
IXWEBSOCKET_EXPORT static const std::string kInvalidCloseCodeMessage;
|
||||||
};
|
};
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "IXSocketServer.h"
|
#include "IXSocketServer.h"
|
||||||
#include "IXWebSocket.h"
|
#include "IXWebSocket.h"
|
||||||
|
#include "IXWebsocketExport.h"
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -50,7 +51,7 @@ namespace ix
|
|||||||
void makeBroadcastServer();
|
void makeBroadcastServer();
|
||||||
bool listenAndStart();
|
bool listenAndStart();
|
||||||
|
|
||||||
const static int kDefaultHandShakeTimeoutSecs;
|
IXWEBSOCKET_EXPORT const static int kDefaultHandShakeTimeoutSecs;
|
||||||
|
|
||||||
int getHandshakeTimeoutSecs();
|
int getHandshakeTimeoutSecs();
|
||||||
bool isPongEnabled();
|
bool isPongEnabled();
|
||||||
@ -67,7 +68,7 @@ namespace ix
|
|||||||
std::mutex _clientsMutex;
|
std::mutex _clientsMutex;
|
||||||
std::set<std::shared_ptr<WebSocket>> _clients;
|
std::set<std::shared_ptr<WebSocket>> _clients;
|
||||||
|
|
||||||
const static bool kDefaultEnablePong;
|
IXWEBSOCKET_EXPORT const static bool kDefaultEnablePong;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual void handleConnection(std::unique_ptr<Socket> socket,
|
virtual void handleConnection(std::unique_ptr<Socket> socket,
|
||||||
|
33
ixwebsocket/IXWebsocketExport.h
Normal file
33
ixwebsocket/IXWebsocketExport.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef IXWEBSOCKET_EXPORT_H
|
||||||
|
#define IXWEBSOCKET_EXPORT_H
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#ifdef IXWEBSOCKET_STATIC_DEFINE
|
||||||
|
/* Building and using static library */
|
||||||
|
# define IXWEBSOCKET_EXPORT
|
||||||
|
# define IXWEBSOCKET_NO_EXPORT
|
||||||
|
#else
|
||||||
|
# ifndef IXWEBSOCKET_EXPORT
|
||||||
|
# ifdef ixwebsocket_EXPORTS /* Comes from cmake, documented in DEFINE_SYMBOL */
|
||||||
|
/* Building dynamic library */
|
||||||
|
# define IXWEBSOCKET_EXPORT __declspec(dllexport)
|
||||||
|
# else
|
||||||
|
/* Using dynamic library */
|
||||||
|
# define IXWEBSOCKET_EXPORT __declspec(dllimport)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef IXWEBSOCKET_NO_EXPORT
|
||||||
|
# define IXWEBSOCKET_NO_EXPORT
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else /* _WIN32 */
|
||||||
|
|
||||||
|
# define IXWEBSOCKET_EXPORT
|
||||||
|
# define IXWEBSOCKET_NO_EXPORT
|
||||||
|
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
#endif /* IXWEBSOCKET_EXPORT_H */
|
Loading…
x
Reference in New Issue
Block a user