#include <main.h>
Inheritance diagram for TCPConnection:


Public Member Functions | |
| TCPConnection (Manager &_mgr) | |
| ~TCPConnection () | |
| void | StartRunning () |
| BOOL | IsRunning () |
| void | PrintOn (ostream &strm) const |
| void | Terminate () |
| void | AssignSourceId (PString &newId) |
| PString | GetSourceId () |
| void | Clear () |
| void | StartWorkNow (PTCPSocket &listener) |
| void | StartWorkNowNotPossible () |
Protected Types | |
| enum | { readArraySize = 10 } |
Protected Member Functions | |
| void | DoOneMessage () |
| void | BreakUpMessageBlock (PBYTEArray &src, PINDEX srcLen, PStringArray &result) |
| void | ProcessOneTextMessage (PString &txt) |
| void | SendThisMessage (PBYTEArray &msg) |
| virtual void | OnReleaseThreadMain (PThread &, INT) |
| virtual void | OnReleased () |
| virtual void | IncomingMessagesMain (PThread &, INT) |
Protected Attributes | |
| Manager & | manager |
| PMutex | incomingLock |
| PThread * | incomingMessages |
| PSyncPoint | socketInitialised |
| PTCPSocket | serverSocket |
| PString | sourceId |
| PINDEX | readArray [readArraySize] |
| PINDEX | readArrayIndex |
| PMutex | clearMutex |
| BOOL | isClearing |
| BOOL | reportReadMessages |
|
|
The size of the array that we keep track on the read size |
|
|
Constructor |
|
|
Destructor |
|
|
Assign this thread a unique Id - the caller had better make sure it is unique, otherwise the list of connectionsActive will never accept it |
|
||||||||||||||||
|
Take in a PBYTEArray, the specified size, and partition it up for each of the null terminated strings in it. The output is stored in the PStringArray |
|
|
End this particular TCP connection, and remove it dead. Do notifiy the manager etc. |
|
|
The method that reads in one message, and then sends it to the other node. Note that this message may actually be several messages which he naughty internet comms system has glued together. Oh joy. Each message is deliminated by a zero byte. |
|
|
Report the source id as used by this connection |
|
||||||||||||
|
This is the main method of the IncomingMessages thread |
|
|
Managing thread is alive |
|
|
Clean up the termination of the connection. This function can do any internal cleaning up and waiting on background threads that may be using the connection object. The default behaviour calls the Manager function of the same name. |
|
||||||||||||
|
This contains the 1 notifier that is used when closing down this instance of TCPConnection class. It is called by a custom thread, which deletes the class |
|
|
Pretty print this connection |
|
|
Now, we have exactly one message, not multiple messages. Process it on |
|
|
Send the supplied message to the node on this socket |
|
|
Get the thread in this class to start running, to process incoming connections |
|
|
Give this class the socket that we accept off, and then start the work |
|
|
The opposite of StartWorkNow, - the listen request failed, so we have to get this TCPConnection to die and go away |
|
|
Stop the thread on this class |
|
|
Mutex to protect access to the isClearing flag, which ensures that only one thread attempts to clear this connection |
|
|
Lock on the pointer to the incoming messages thread |
|
|
The thread which does all the work of handling (and sending) incoming messages |
|
|
Flag to indicate we are being cleared, or have been cleared |
|
|
The manager that looks after us |
|
|
The array we record the sizes in |
|
|
The index as to where we write the data in the readArray |
|
|
Flag to control if we should write messages read in to the console |
|
|
Socket we manage incoming connection requests on |
|
|
Flag which says that the socket is accepted on and ready to go |
|
|
The id, as chosen by the remote node who is talking to us |
1.4.4