dropped prefix C

This commit is contained in:
XinyuHou 2015-01-12 10:33:29 +00:00
parent 7bff958422
commit f973d1498d
9 changed files with 55 additions and 55 deletions

View File

@ -58,7 +58,7 @@ private:
private: private:
NetworkAddress m_serverAddress; NetworkAddress m_serverAddress;
CTCPSocket m_socket; TCPSocket m_socket;
IpcServerProxy* m_server; IpcServerProxy* m_server;
IEventQueue* m_events; IEventQueue* m_events;
}; };

View File

@ -110,7 +110,7 @@ TCPListenSocket::accept()
{ {
IDataSocket* socket = NULL; IDataSocket* socket = NULL;
try { try {
socket = new CTCPSocket(m_events, m_socketMultiplexer, ARCH->acceptSocket(m_socket, NULL)); socket = new TCPSocket(m_events, m_socketMultiplexer, ARCH->acceptSocket(m_socket, NULL));
if (socket != NULL) { if (socket != NULL) {
m_socketMultiplexer->addSocket(this, m_socketMultiplexer->addSocket(this,
new TSocketMultiplexerMethodJob<TCPListenSocket>( new TSocketMultiplexerMethodJob<TCPListenSocket>(

View File

@ -34,10 +34,10 @@
#include <memory> #include <memory>
// //
// CTCPSocket // TCPSocket
// //
CTCPSocket::CTCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer) : TCPSocket::TCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer) :
IDataSocket(events), IDataSocket(events),
m_mutex(), m_mutex(),
m_flushed(&m_mutex, true), m_flushed(&m_mutex, true),
@ -54,7 +54,7 @@ CTCPSocket::CTCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer
init(); init();
} }
CTCPSocket::CTCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, ArchSocket socket) : TCPSocket::TCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, ArchSocket socket) :
IDataSocket(events), IDataSocket(events),
m_mutex(), m_mutex(),
m_socket(socket), m_socket(socket),
@ -70,7 +70,7 @@ CTCPSocket::CTCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer
setJob(newJob()); setJob(newJob());
} }
CTCPSocket::~CTCPSocket() TCPSocket::~TCPSocket()
{ {
try { try {
close(); close();
@ -81,7 +81,7 @@ CTCPSocket::~CTCPSocket()
} }
void void
CTCPSocket::bind(const NetworkAddress& addr) TCPSocket::bind(const NetworkAddress& addr)
{ {
try { try {
ARCH->bindSocket(m_socket, addr.getAddress()); ARCH->bindSocket(m_socket, addr.getAddress());
@ -95,7 +95,7 @@ CTCPSocket::bind(const NetworkAddress& addr)
} }
void void
CTCPSocket::close() TCPSocket::close()
{ {
// remove ourself from the multiplexer // remove ourself from the multiplexer
setJob(NULL); setJob(NULL);
@ -123,13 +123,13 @@ CTCPSocket::close()
} }
void* void*
CTCPSocket::getEventTarget() const TCPSocket::getEventTarget() const
{ {
return const_cast<void*>(reinterpret_cast<const void*>(this)); return const_cast<void*>(reinterpret_cast<const void*>(this));
} }
UInt32 UInt32
CTCPSocket::read(void* buffer, UInt32 n) TCPSocket::read(void* buffer, UInt32 n)
{ {
// copy data directly from our input buffer // copy data directly from our input buffer
Lock lock(&m_mutex); Lock lock(&m_mutex);
@ -152,7 +152,7 @@ CTCPSocket::read(void* buffer, UInt32 n)
} }
void void
CTCPSocket::write(const void* buffer, UInt32 n) TCPSocket::write(const void* buffer, UInt32 n)
{ {
bool wasEmpty; bool wasEmpty;
{ {
@ -184,7 +184,7 @@ CTCPSocket::write(const void* buffer, UInt32 n)
} }
void void
CTCPSocket::flush() TCPSocket::flush()
{ {
Lock lock(&m_mutex); Lock lock(&m_mutex);
while (m_flushed == false) { while (m_flushed == false) {
@ -193,7 +193,7 @@ CTCPSocket::flush()
} }
void void
CTCPSocket::shutdownInput() TCPSocket::shutdownInput()
{ {
bool useNewJob = false; bool useNewJob = false;
{ {
@ -220,7 +220,7 @@ CTCPSocket::shutdownInput()
} }
void void
CTCPSocket::shutdownOutput() TCPSocket::shutdownOutput()
{ {
bool useNewJob = false; bool useNewJob = false;
{ {
@ -247,21 +247,21 @@ CTCPSocket::shutdownOutput()
} }
bool bool
CTCPSocket::isReady() const TCPSocket::isReady() const
{ {
Lock lock(&m_mutex); Lock lock(&m_mutex);
return (m_inputBuffer.getSize() > 0); return (m_inputBuffer.getSize() > 0);
} }
UInt32 UInt32
CTCPSocket::getSize() const TCPSocket::getSize() const
{ {
Lock lock(&m_mutex); Lock lock(&m_mutex);
return m_inputBuffer.getSize(); return m_inputBuffer.getSize();
} }
void void
CTCPSocket::connect(const NetworkAddress& addr) TCPSocket::connect(const NetworkAddress& addr)
{ {
{ {
Lock lock(&m_mutex); Lock lock(&m_mutex);
@ -290,7 +290,7 @@ CTCPSocket::connect(const NetworkAddress& addr)
} }
void void
CTCPSocket::init() TCPSocket::init()
{ {
// default state // default state
m_connected = false; m_connected = false;
@ -316,7 +316,7 @@ CTCPSocket::init()
} }
void void
CTCPSocket::setJob(ISocketMultiplexerJob* job) TCPSocket::setJob(ISocketMultiplexerJob* job)
{ {
// multiplexer will delete the old job // multiplexer will delete the old job
if (job == NULL) { if (job == NULL) {
@ -328,7 +328,7 @@ CTCPSocket::setJob(ISocketMultiplexerJob* job)
} }
ISocketMultiplexerJob* ISocketMultiplexerJob*
CTCPSocket::newJob() TCPSocket::newJob()
{ {
// note -- must have m_mutex locked on entry // note -- must have m_mutex locked on entry
@ -340,23 +340,23 @@ CTCPSocket::newJob()
if (!(m_readable || m_writable)) { if (!(m_readable || m_writable)) {
return NULL; return NULL;
} }
return new TSocketMultiplexerMethodJob<CTCPSocket>( return new TSocketMultiplexerMethodJob<TCPSocket>(
this, &CTCPSocket::serviceConnecting, this, &TCPSocket::serviceConnecting,
m_socket, m_readable, m_writable); m_socket, m_readable, m_writable);
} }
else { else {
if (!(m_readable || (m_writable && (m_outputBuffer.getSize() > 0)))) { if (!(m_readable || (m_writable && (m_outputBuffer.getSize() > 0)))) {
return NULL; return NULL;
} }
return new TSocketMultiplexerMethodJob<CTCPSocket>( return new TSocketMultiplexerMethodJob<TCPSocket>(
this, &CTCPSocket::serviceConnected, this, &TCPSocket::serviceConnected,
m_socket, m_readable, m_socket, m_readable,
m_writable && (m_outputBuffer.getSize() > 0)); m_writable && (m_outputBuffer.getSize() > 0));
} }
} }
void void
CTCPSocket::sendConnectionFailedEvent(const char* msg) TCPSocket::sendConnectionFailedEvent(const char* msg)
{ {
ConnectionFailedInfo* info = new ConnectionFailedInfo(msg); ConnectionFailedInfo* info = new ConnectionFailedInfo(msg);
m_events->addEvent(Event(m_events->forIDataSocket().connectionFailed(), m_events->addEvent(Event(m_events->forIDataSocket().connectionFailed(),
@ -364,13 +364,13 @@ CTCPSocket::sendConnectionFailedEvent(const char* msg)
} }
void void
CTCPSocket::sendEvent(Event::Type type) TCPSocket::sendEvent(Event::Type type)
{ {
m_events->addEvent(Event(type, getEventTarget(), NULL)); m_events->addEvent(Event(type, getEventTarget(), NULL));
} }
void void
CTCPSocket::onConnected() TCPSocket::onConnected()
{ {
m_connected = true; m_connected = true;
m_readable = true; m_readable = true;
@ -378,14 +378,14 @@ CTCPSocket::onConnected()
} }
void void
CTCPSocket::onInputShutdown() TCPSocket::onInputShutdown()
{ {
m_inputBuffer.pop(m_inputBuffer.getSize()); m_inputBuffer.pop(m_inputBuffer.getSize());
m_readable = false; m_readable = false;
} }
void void
CTCPSocket::onOutputShutdown() TCPSocket::onOutputShutdown()
{ {
m_outputBuffer.pop(m_outputBuffer.getSize()); m_outputBuffer.pop(m_outputBuffer.getSize());
m_writable = false; m_writable = false;
@ -396,7 +396,7 @@ CTCPSocket::onOutputShutdown()
} }
void void
CTCPSocket::onDisconnected() TCPSocket::onDisconnected()
{ {
// disconnected // disconnected
onInputShutdown(); onInputShutdown();
@ -405,7 +405,7 @@ CTCPSocket::onDisconnected()
} }
ISocketMultiplexerJob* ISocketMultiplexerJob*
CTCPSocket::serviceConnecting(ISocketMultiplexerJob* job, TCPSocket::serviceConnecting(ISocketMultiplexerJob* job,
bool, bool write, bool error) bool, bool write, bool error)
{ {
Lock lock(&m_mutex); Lock lock(&m_mutex);
@ -449,7 +449,7 @@ CTCPSocket::serviceConnecting(ISocketMultiplexerJob* job,
} }
ISocketMultiplexerJob* ISocketMultiplexerJob*
CTCPSocket::serviceConnected(ISocketMultiplexerJob* job, TCPSocket::serviceConnected(ISocketMultiplexerJob* job,
bool read, bool write, bool error) bool read, bool write, bool error)
{ {
Lock lock(&m_mutex); Lock lock(&m_mutex);

View File

@ -34,11 +34,11 @@ class SocketMultiplexer;
/*! /*!
A data socket using TCP. A data socket using TCP.
*/ */
class CTCPSocket : public IDataSocket { class TCPSocket : public IDataSocket {
public: public:
CTCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer); TCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer);
CTCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, ArchSocket socket); TCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, ArchSocket socket);
~CTCPSocket(); ~TCPSocket();
// ISocket overrides // ISocket overrides
virtual void bind(const NetworkAddress&); virtual void bind(const NetworkAddress&);

View File

@ -22,29 +22,29 @@
#include "net/TCPListenSocket.h" #include "net/TCPListenSocket.h"
// //
// CTCPSocketFactory // TCPSocketFactory
// //
CTCPSocketFactory::CTCPSocketFactory(IEventQueue* events, SocketMultiplexer* socketMultiplexer) : TCPSocketFactory::TCPSocketFactory(IEventQueue* events, SocketMultiplexer* socketMultiplexer) :
m_events(events), m_events(events),
m_socketMultiplexer(socketMultiplexer) m_socketMultiplexer(socketMultiplexer)
{ {
// do nothing // do nothing
} }
CTCPSocketFactory::~CTCPSocketFactory() TCPSocketFactory::~TCPSocketFactory()
{ {
// do nothing // do nothing
} }
IDataSocket* IDataSocket*
CTCPSocketFactory::create() const TCPSocketFactory::create() const
{ {
return new CTCPSocket(m_events, m_socketMultiplexer); return new TCPSocket(m_events, m_socketMultiplexer);
} }
IListenSocket* IListenSocket*
CTCPSocketFactory::createListen() const TCPSocketFactory::createListen() const
{ {
return new TCPListenSocket(m_events, m_socketMultiplexer); return new TCPListenSocket(m_events, m_socketMultiplexer);
} }

View File

@ -24,10 +24,10 @@ class IEventQueue;
class SocketMultiplexer; class SocketMultiplexer;
//! Socket factory for TCP sockets //! Socket factory for TCP sockets
class CTCPSocketFactory : public ISocketFactory { class TCPSocketFactory : public ISocketFactory {
public: public:
CTCPSocketFactory(IEventQueue* events, SocketMultiplexer* socketMultiplexer); TCPSocketFactory(IEventQueue* events, SocketMultiplexer* socketMultiplexer);
virtual ~CTCPSocketFactory(); virtual ~TCPSocketFactory();
// ISocketFactory overrides // ISocketFactory overrides
virtual IDataSocket* create() const; virtual IDataSocket* create() const;

View File

@ -340,7 +340,7 @@ ClientApp::openClient(const String& name, const NetworkAddress& address,
m_events, m_events,
name, name,
address, address,
new CTCPSocketFactory(m_events, getSocketMultiplexer()), new TCPSocketFactory(m_events, getSocketMultiplexer()),
NULL, NULL,
screen, screen,
crypto, crypto,

View File

@ -631,7 +631,7 @@ ServerApp::openClientListener(const NetworkAddress& address)
{ {
ClientListener* listen = new ClientListener( ClientListener* listen = new ClientListener(
address, address,
new CTCPSocketFactory(m_events, getSocketMultiplexer()), new TCPSocketFactory(m_events, getSocketMultiplexer()),
NULL, NULL,
args().m_crypto, args().m_crypto,
m_events); m_events);

View File

@ -115,7 +115,7 @@ TEST_F(NetworkTests, sendToClient_mockData)
// server // server
SocketMultiplexer serverSocketMultiplexer; SocketMultiplexer serverSocketMultiplexer;
CTCPSocketFactory* serverSocketFactory = new CTCPSocketFactory(&m_events, &serverSocketMultiplexer); TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer);
ClientListener listener(serverAddress, serverSocketFactory, NULL, cryptoOptions, &m_events); ClientListener listener(serverAddress, serverSocketFactory, NULL, cryptoOptions, &m_events);
NiceMock<MockScreen> serverScreen; NiceMock<MockScreen> serverScreen;
NiceMock<MockPrimaryClient> primaryClient; NiceMock<MockPrimaryClient> primaryClient;
@ -137,7 +137,7 @@ TEST_F(NetworkTests, sendToClient_mockData)
// client // client
NiceMock<MockScreen> clientScreen; NiceMock<MockScreen> clientScreen;
SocketMultiplexer clientSocketMultiplexer; SocketMultiplexer clientSocketMultiplexer;
CTCPSocketFactory* clientSocketFactory = new CTCPSocketFactory(&m_events, &clientSocketMultiplexer); TCPSocketFactory* clientSocketFactory = new TCPSocketFactory(&m_events, &clientSocketMultiplexer);
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape)); ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos)); ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
@ -168,7 +168,7 @@ TEST_F(NetworkTests, sendToClient_mockFile)
// server // server
SocketMultiplexer serverSocketMultiplexer; SocketMultiplexer serverSocketMultiplexer;
CTCPSocketFactory* serverSocketFactory = new CTCPSocketFactory(&m_events, &serverSocketMultiplexer); TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer);
ClientListener listener(serverAddress, serverSocketFactory, NULL, cryptoOptions, &m_events); ClientListener listener(serverAddress, serverSocketFactory, NULL, cryptoOptions, &m_events);
NiceMock<MockScreen> serverScreen; NiceMock<MockScreen> serverScreen;
NiceMock<MockPrimaryClient> primaryClient; NiceMock<MockPrimaryClient> primaryClient;
@ -190,7 +190,7 @@ TEST_F(NetworkTests, sendToClient_mockFile)
// client // client
NiceMock<MockScreen> clientScreen; NiceMock<MockScreen> clientScreen;
SocketMultiplexer clientSocketMultiplexer; SocketMultiplexer clientSocketMultiplexer;
CTCPSocketFactory* clientSocketFactory = new CTCPSocketFactory(&m_events, &clientSocketMultiplexer); TCPSocketFactory* clientSocketFactory = new TCPSocketFactory(&m_events, &clientSocketMultiplexer);
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape)); ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos)); ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
@ -221,7 +221,7 @@ TEST_F(NetworkTests, sendToServer_mockData)
// server // server
SocketMultiplexer serverSocketMultiplexer; SocketMultiplexer serverSocketMultiplexer;
CTCPSocketFactory* serverSocketFactory = new CTCPSocketFactory(&m_events, &serverSocketMultiplexer); TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer);
ClientListener listener(serverAddress, serverSocketFactory, NULL, cryptoOptions, &m_events); ClientListener listener(serverAddress, serverSocketFactory, NULL, cryptoOptions, &m_events);
NiceMock<MockScreen> serverScreen; NiceMock<MockScreen> serverScreen;
NiceMock<MockPrimaryClient> primaryClient; NiceMock<MockPrimaryClient> primaryClient;
@ -238,7 +238,7 @@ TEST_F(NetworkTests, sendToServer_mockData)
// client // client
NiceMock<MockScreen> clientScreen; NiceMock<MockScreen> clientScreen;
SocketMultiplexer clientSocketMultiplexer; SocketMultiplexer clientSocketMultiplexer;
CTCPSocketFactory* clientSocketFactory = new CTCPSocketFactory(&m_events, &clientSocketMultiplexer); TCPSocketFactory* clientSocketFactory = new TCPSocketFactory(&m_events, &clientSocketMultiplexer);
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape)); ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos)); ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
@ -274,7 +274,7 @@ TEST_F(NetworkTests, sendToServer_mockFile)
// server // server
SocketMultiplexer serverSocketMultiplexer; SocketMultiplexer serverSocketMultiplexer;
CTCPSocketFactory* serverSocketFactory = new CTCPSocketFactory(&m_events, &serverSocketMultiplexer); TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer);
ClientListener listener(serverAddress, serverSocketFactory, NULL, cryptoOptions, &m_events); ClientListener listener(serverAddress, serverSocketFactory, NULL, cryptoOptions, &m_events);
NiceMock<MockScreen> serverScreen; NiceMock<MockScreen> serverScreen;
NiceMock<MockPrimaryClient> primaryClient; NiceMock<MockPrimaryClient> primaryClient;
@ -291,7 +291,7 @@ TEST_F(NetworkTests, sendToServer_mockFile)
// client // client
NiceMock<MockScreen> clientScreen; NiceMock<MockScreen> clientScreen;
SocketMultiplexer clientSocketMultiplexer; SocketMultiplexer clientSocketMultiplexer;
CTCPSocketFactory* clientSocketFactory = new CTCPSocketFactory(&m_events, &clientSocketMultiplexer); TCPSocketFactory* clientSocketFactory = new TCPSocketFactory(&m_events, &clientSocketMultiplexer);
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape)); ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos)); ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));