UBSocket Class Reference

This class handles all data from and to the user. More...

#include <UBSocket.h>

List of all members.

Public Member Functions

 UBSocket (ISocketHandler &h)
 Constructs a UBSocket using the specified socket handler.
 ~UBSocket (void)
 Destructor, deletes all editors.
void OnAccept ()
 Accept a new connection.
void OnLine (const std::string &line)
 Accept the next line of user input.
void Send (const std::string &msg)
 Send text to the user.
void Sendf (const char *format,...)
 Send formatted text to the user.
bool hasAccount () const
 Whether this socket already has an account associated with it.
mud::AccountPtr GetAccount () const
 Returns the account associated with this socket, this account is asserted to have been assigned.
bool hasForcer () const
 Whether the user was forced to send their latest line.
UBSocketGetForcer () const
 Returns the socket that forced this user to send their latest line, it is asserted that there is a forcer.
bool isHighForced () const
 Whether the current force is from an Admin.
bool isForced () const
 Whether the current force is from a Forcer.
bool isLowForced () const
 Whether the current force is from another player.
bool canReceiveChannel (mud::ChannelPtr channel)
 Is the user in a state capable of receiving the specified channel.
void SetAccount (mud::AccountPtr account)
 Sets the account associated with this user.
void SetEditor (Editor *editor, bool popLast=false)
 Set the specified editor as the current editor.
void PopEditor ()
 Return to the previous editor, it is asserted that the user is never left with an empty editor list.
void SetForcer (UBSocket *forcer, bool weakForced=true, bool forced=false, bool highForced=false)
 Sets the forces of the next commands.
void EndForce ()
 End the force.
void SwitchEditors ()
 This will switch editors.

Static Public Member Functions

static UBSocketCast (Socket *sock, bool error=true)
 This is an utility function that will cast the specified socket to an UBSocket.


Detailed Description

This class handles all data from and to the user.

When accepting an connection it will set the login editor. All lines received are processed by calling the topmost editor's OnLine function.

Definition at line 46 of file UBSocket.h.


Constructor & Destructor Documentation

UBSocket::UBSocket ( ISocketHandler &  h  ) 

Constructs a UBSocket using the specified socket handler.

UBSocket::~UBSocket ( void   ) 

Destructor, deletes all editors.


Member Function Documentation

void UBSocket::OnAccept (  ) 

Accept a new connection.

void UBSocket::OnLine ( const std::string &  line  ) 

Accept the next line of user input.

void UBSocket::Send ( const std::string &  msg  ) 

Send text to the user.

void UBSocket::Sendf ( const char *  format,
  ... 
)

Send formatted text to the user.

bool UBSocket::hasAccount (  )  const

Whether this socket already has an account associated with it.

mud::AccountPtr UBSocket::GetAccount (  )  const

Returns the account associated with this socket, this account is asserted to have been assigned.

bool UBSocket::hasForcer (  )  const

Whether the user was forced to send their latest line.

UBSocket* UBSocket::GetForcer (  )  const

Returns the socket that forced this user to send their latest line, it is asserted that there is a forcer.

bool UBSocket::isHighForced (  )  const [inline]

Whether the current force is from an Admin.

Definition at line 83 of file UBSocket.h.

bool UBSocket::isForced (  )  const [inline]

Whether the current force is from a Forcer.

Definition at line 86 of file UBSocket.h.

bool UBSocket::isLowForced (  )  const [inline]

Whether the current force is from another player.

Definition at line 89 of file UBSocket.h.

bool UBSocket::canReceiveChannel ( mud::ChannelPtr  channel  ) 

Is the user in a state capable of receiving the specified channel.

void UBSocket::SetAccount ( mud::AccountPtr  account  )  [inline]

Sets the account associated with this user.

Definition at line 96 of file UBSocket.h.

void UBSocket::SetEditor ( Editor editor,
bool  popLast = false 
)

Set the specified editor as the current editor.

The specified editor does not replace any previous editors. Instead it is prepended to a list of editors. This allows for 'stacked' editors.

Parameters:
editor The editor that should be prepended to the editor list.
popLast Remove the most recent editor before adding the current editor.

void UBSocket::PopEditor (  ) 

Return to the previous editor, it is asserted that the user is never left with an empty editor list.

void UBSocket::SetForcer ( UBSocket forcer,
bool  weakForced = true,
bool  forced = false,
bool  highForced = false 
)

Sets the forces of the next commands.

The forcer remains in place untill EndForce is called. The optional parameters describe what authorization the forcer has.

Parameters:
forcer The socket that will force the next commands.
weakForced Whether the force is done by another user.
forced Whether the force is done by a Forcer.
highForced Whether the force is done by an Admin.
See also:
EndForce

void UBSocket::EndForce (  ) 

End the force.

void UBSocket::SwitchEditors (  ) 

This will switch editors.

The SetEditor and PopEditor methods do not actually change editors. Instead they 'queue' editor changing actions till the end of the current 'loop', when this function is called. Each editor will therefore return from the function that called SetEditor or PopEditor. As such, editors do not have to worry about being deleted after calling either of those functions.

See also:
SetEditor

PopEditor

static UBSocket* UBSocket::Cast ( Socket *  sock,
bool  error = true 
) [static]

This is an utility function that will cast the specified socket to an UBSocket.

Parameters:
sock The socket to cast from.
error Whether we should throw an exception when the socket could not be casted.


Generated for UnsignedByte by  doxygen 1.5.3
SourceForge.net Logo