net.sf.opensmus
Class MUSServer

java.lang.Object
  extended by net.sf.opensmus.MUSServer
All Implemented Interfaces:
ServerObject

public class MUSServer
extends java.lang.Object
implements ServerObject


Field Summary
 int authentication
           
 long drop_msg
           
 java.lang.String encryptionKey
           
 int idle
           
 long in_bytes
           
 long in_msg
           
 boolean m_alive
          Alive flag of server.
protected  java.util.Vector<java.lang.String> m_allowedmoviepathnames
           
protected  java.util.Vector<java.lang.String> m_allowedmovieslist
           
 java.util.concurrent.ConcurrentHashMap<java.lang.String,MUSUser> m_clientlist
           
 MUSDBConnection m_dbConn
           
protected  java.util.Vector<java.lang.String> m_disabledmovieslist
           
protected  boolean m_enabled
           
 int m_loginlimit
           
protected  MUSServerLoginQueue m_loginqueue
           
 int m_maxconnections
           
 java.util.concurrent.ConcurrentHashMap<java.lang.String,MUSMovie> m_movielist
           
 java.util.Vector<MUSConnectionPort> m_ports
           
 MUSServerProperties m_props
           
 MUSScriptMap m_scriptmap
           
 MUSSQLConnection m_sqlConn
           
 long m_starttime
           
 java.lang.String m_udpAddress
           
protected  java.util.Vector<java.lang.Integer> m_udpPortsInUse
           
 int m_udpStartingPort
           
static java.lang.String m_vendorname
           
static java.lang.String m_version
           
 long out_bytes
           
 long out_msg
           
 java.util.LinkedHashMap<java.lang.Integer,java.lang.Long> recentIPs
           
 org.jboss.netty.channel.group.ChannelGroup UDP_channels
           
 
Constructor Summary
MUSServer()
           
MUSServer(MUSServerProperties properties)
           
 
Method Summary
 void addConnectionPort(MUSConnectionPort onePort)
           
 void addMovie(MUSMovie onemovie)
           
 void addMUSUser(MUSUser oneClient)
           
 void addUDPPort(int portNum)
           
 void changeUserMovie(ServerUser wuser, java.lang.String wnewmovie)
           
 void checkDatabaseConnections()
           
 void checkStructure()
           
 ServerMovie createServerMovie(java.lang.String moviename)
          Creates a new movie on the server and returns a pointer to it.
 void deleteServerMovie(java.lang.String moviename)
          Deletes a movie from the server.
 void disable()
           
 void disableMovie(java.lang.String mname)
           
 void disconnectAllUsers()
           
 boolean doesServerLogging()
           
 void enable()
           
 void enableMovie(java.lang.String mname)
           
 void ensureLoggerThreadIsAlive()
           
 void ensureThreadsAreAlive()
           
 void freeConnectionPorts()
           
 MUSMovie getMovie(java.lang.String mname)
           
 ServerMovie getServerMovie(int movieidx)
          Deprecated. since it's not working correctly
 ServerMovie getServerMovie(java.lang.String moviename)
          Retrieves a pointer to a ServerMovie object active on the server.
 ServerUserDatabase getServerUserDatabase()
          Returns a pointer to the ServerUserDatabase interface representing the default user authentication table.
 SQLGateway getSQLGateway()
          Returns a pointer to the SQLGateway interface representing the default SQL connection.
 int getUDPPortNumber()
           
 void initConnectionPorts()
           
protected  boolean isMovieAllowed(java.lang.String moviename)
           
protected  boolean isMoviePathnameAllowed(java.lang.String pathname, int logonmsgformat)
           
 void killServer()
           
 int language()
          This method is reserved.
 void logDroppedMsg()
           
 void logInBytes(int bytes)
           
 void logOutBytes(int bytes)
           
 java.lang.String path()
          Gets the path of the server executable in the system
protected  void processLogonMessage(MUSMessage msg, MUSUser oneUser)
           
 void put(java.lang.String msg)
          Displays a message to the server active output (log file or terminal window)
 void queueLogonMessage(MUSMessage msg, MUSUser oneUser)
           
 void releaseUDPPort(int portNum)
           
 void removeConnectionPort(MUSConnectionPort onePort)
           
 void removeMovie(MUSMovie onemovie)
           
 void removeMUSUser(MUSUser oneClient)
           
 int serverMovieCount()
          Gets the number of active movies in the server.
 void setuserLevel(int level)
          Sets the default user levels for users that connect to the server and do not have a user account in the DB.
 LValue srvcmd_getMovies()
           
 LValue srvcmd_getUserCount()
           
 LValue srvcmd_getVersion()
           
 int timeStamp()
          Gets the current server time as an int
 java.lang.String timeString()
          Gets the current server time formatted as a String
 int userLevel()
          Gets the default user levels for users that connect to the server and do not have a user account in the DB.
 boolean userThreadAlive(java.lang.String uname)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_clientlist

public final java.util.concurrent.ConcurrentHashMap<java.lang.String,MUSUser> m_clientlist

m_movielist

public final java.util.concurrent.ConcurrentHashMap<java.lang.String,MUSMovie> m_movielist

m_loginqueue

protected MUSServerLoginQueue m_loginqueue

m_allowedmovieslist

protected final java.util.Vector<java.lang.String> m_allowedmovieslist

m_disabledmovieslist

protected final java.util.Vector<java.lang.String> m_disabledmovieslist

m_allowedmoviepathnames

protected final java.util.Vector<java.lang.String> m_allowedmoviepathnames

m_ports

public final java.util.Vector<MUSConnectionPort> m_ports

recentIPs

public final java.util.LinkedHashMap<java.lang.Integer,java.lang.Long> recentIPs

m_dbConn

public MUSDBConnection m_dbConn

m_sqlConn

public MUSSQLConnection m_sqlConn

m_props

public MUSServerProperties m_props

m_scriptmap

public MUSScriptMap m_scriptmap

m_starttime

public long m_starttime

m_vendorname

public static java.lang.String m_vendorname

m_version

public static java.lang.String m_version

idle

public volatile int idle

m_maxconnections

public int m_maxconnections

m_loginlimit

public int m_loginlimit

m_enabled

protected boolean m_enabled

m_alive

public volatile boolean m_alive
Alive flag of server. Set to true on startup and false on shutdown. Must be volatile, since other threads will read its state


encryptionKey

public java.lang.String encryptionKey

authentication

public int authentication

m_udpStartingPort

public int m_udpStartingPort

m_udpAddress

public java.lang.String m_udpAddress

m_udpPortsInUse

protected java.util.Vector<java.lang.Integer> m_udpPortsInUse

UDP_channels

public org.jboss.netty.channel.group.ChannelGroup UDP_channels

in_bytes

public long in_bytes

out_bytes

public long out_bytes

in_msg

public long in_msg

out_msg

public long out_msg

drop_msg

public long drop_msg
Constructor Detail

MUSServer

public MUSServer()

MUSServer

public MUSServer(MUSServerProperties properties)
Method Detail

killServer

public void killServer()

disconnectAllUsers

public void disconnectAllUsers()

freeConnectionPorts

public void freeConnectionPorts()

initConnectionPorts

public void initConnectionPorts()

disable

public void disable()

enable

public void enable()

checkDatabaseConnections

public void checkDatabaseConnections()

ensureLoggerThreadIsAlive

public void ensureLoggerThreadIsAlive()

ensureThreadsAreAlive

public void ensureThreadsAreAlive()

removeMUSUser

public void removeMUSUser(MUSUser oneClient)

addMUSUser

public void addMUSUser(MUSUser oneClient)

userThreadAlive

public boolean userThreadAlive(java.lang.String uname)

checkStructure

public void checkStructure()

logInBytes

public void logInBytes(int bytes)

logOutBytes

public void logOutBytes(int bytes)

logDroppedMsg

public void logDroppedMsg()

addConnectionPort

public void addConnectionPort(MUSConnectionPort onePort)

removeConnectionPort

public void removeConnectionPort(MUSConnectionPort onePort)

getUDPPortNumber

public int getUDPPortNumber()

addUDPPort

public void addUDPPort(int portNum)

releaseUDPPort

public void releaseUDPPort(int portNum)

isMovieAllowed

protected boolean isMovieAllowed(java.lang.String moviename)

isMoviePathnameAllowed

protected boolean isMoviePathnameAllowed(java.lang.String pathname,
                                         int logonmsgformat)

getMovie

public MUSMovie getMovie(java.lang.String mname)
                  throws MovieNotFoundException
Throws:
MovieNotFoundException

disableMovie

public void disableMovie(java.lang.String mname)

enableMovie

public void enableMovie(java.lang.String mname)

changeUserMovie

public void changeUserMovie(ServerUser wuser,
                            java.lang.String wnewmovie)
                     throws MUSErrorCode
Throws:
MUSErrorCode

queueLogonMessage

public void queueLogonMessage(MUSMessage msg,
                              MUSUser oneUser)

processLogonMessage

protected void processLogonMessage(MUSMessage msg,
                                   MUSUser oneUser)

addMovie

public void addMovie(MUSMovie onemovie)

removeMovie

public void removeMovie(MUSMovie onemovie)

srvcmd_getVersion

public LValue srvcmd_getVersion()

srvcmd_getUserCount

public LValue srvcmd_getUserCount()

srvcmd_getMovies

public LValue srvcmd_getMovies()

getSQLGateway

public SQLGateway getSQLGateway()
Description copied from interface: ServerObject
Returns a pointer to the SQLGateway interface representing the default SQL connection.
Please consult the documentation of SQLGateway for more information.

Specified by:
getSQLGateway in interface ServerObject

getServerUserDatabase

public ServerUserDatabase getServerUserDatabase()
Description copied from interface: ServerObject
Returns a pointer to the ServerUserDatabase interface representing the default user authentication table.
Please consult the documentation of ServerUserDatabase for more information.

Specified by:
getServerUserDatabase in interface ServerObject

put

public void put(java.lang.String msg)
Description copied from interface: ServerObject
Displays a message to the server active output (log file or terminal window)

Specified by:
put in interface ServerObject

getServerMovie

public ServerMovie getServerMovie(java.lang.String moviename)
                           throws MovieNotFoundException
Description copied from interface: ServerObject
Retrieves a pointer to a ServerMovie object active on the server.

Specified by:
getServerMovie in interface ServerObject
Parameters:
moviename - String with the name of the movie to be returned
Returns:
ServerMovie pointer, or throws a MovieNotFoundException
Throws:
MovieNotFoundException

getServerMovie

public ServerMovie getServerMovie(int movieidx)
                           throws MovieNotFoundException
Deprecated. since it's not working correctly

TODO Movies are stored in a map without guaranteed sequence order

Specified by:
getServerMovie in interface ServerObject
Parameters:
movieidx - index of the movie to be returned
Returns:
ServerMovie pointer, or throws a MovieNotFoundException
Throws:
MovieNotFoundException
See Also:
ServerObject.getServerMovie(int)

createServerMovie

public ServerMovie createServerMovie(java.lang.String moviename)
                              throws MUSErrorCode
Description copied from interface: ServerObject
Creates a new movie on the server and returns a pointer to it.

Specified by:
createServerMovie in interface ServerObject
Parameters:
moviename - String with the name of the movie to be created
Returns:
ServerMovie pointer, or throws a MUSErrorCode if the creation fails
Throws:
MUSErrorCode

deleteServerMovie

public void deleteServerMovie(java.lang.String moviename)
Description copied from interface: ServerObject
Deletes a movie from the server.

Specified by:
deleteServerMovie in interface ServerObject
Parameters:
moviename - String with the name of the movie to be deleted

serverMovieCount

public int serverMovieCount()
Description copied from interface: ServerObject
Gets the number of active movies in the server.

Specified by:
serverMovieCount in interface ServerObject
Returns:
the number of movies

path

public java.lang.String path()
Description copied from interface: ServerObject
Gets the path of the server executable in the system

Specified by:
path in interface ServerObject

timeString

public java.lang.String timeString()
Description copied from interface: ServerObject
Gets the current server time formatted as a String

Specified by:
timeString in interface ServerObject

timeStamp

public int timeStamp()
Description copied from interface: ServerObject
Gets the current server time as an int

Specified by:
timeStamp in interface ServerObject

language

public int language()
Description copied from interface: ServerObject
This method is reserved. Current implementation returns 0 for the English version of OpenSMUS.

Specified by:
language in interface ServerObject

userLevel

public int userLevel()
Description copied from interface: ServerObject
Gets the default user levels for users that connect to the server and do not have a user account in the DB.
This value can be configured by the DefaultUserLevel directive in OpenSMUS.cfg.

Specified by:
userLevel in interface ServerObject

setuserLevel

public void setuserLevel(int level)
Description copied from interface: ServerObject
Sets the default user levels for users that connect to the server and do not have a user account in the DB.
When this method is used it overrides the value configured by the DefaultUserLevel directive in OpenSMUS.cfg.

Specified by:
setuserLevel in interface ServerObject

doesServerLogging

public final boolean doesServerLogging()
Returns: