Class ServM

java.lang.Object
   |
   +----ServM

public class ServM
extends Object
implements Runnable
This is the server class for the game jMancala
Start it with the command : java ServM

version 1.0b1 26/04/98
author Pierre-Mikael Legris (plegris@fbwww.epfl.ch)
How does it works?
   ServM
     -listen to the determinate port. 
     -handle the user list: (nick , Human(nick,Socket,comment))
     -is used to broadcast messages to users.
    when a connection occure ServM pass the socket to SocketHub.
- 
   SocketHub(Socket)
    get the stream from the socket, verify the nick of the
    incoming user. When evrything is OK it add the user to
    ServM's user list with Human(nick,Socket,comment)
    and create a new Mstream(nick)
- 
   Human(nick,Socket,comment)
    read and write in the Socket
    have some usefull method such as isAlive()
-
   Mstream(nick)
    Mstream is the "waiting room" on the server for the users.
    It takes the control of this user, then handle the data
    streams between users until he starts a game.
    with Game(opponent,nick)
-
   Game(opponent,nick)
    Take the control of the 2 players: Player(nick,Human,move)
    and manage the game using MRules(nick1). When the game end 
    it gives the two users back to Mstream.
-
   Player(nick,Human,move)
    is an extension of Human, with some more method for Game()
    it handle if it's his Turn to play ...
-
   MRules(nick) (note that MRules is also used by the client)
    It handle the game board and the rules.
-       
 
This is opensource software.
(just notify me if you use a part of this code or modify it)

Version:
1.0b1 26/04/98

Variable Index

 o bots
 o games
 o mainPort
 o MSocket
 o server
 o users
users handle the uselist by binding a nick name to a Human()

Constructor Index

 o ServM(int)
Construct a new Server and launch the Thread

Method Index

 o bdM(String)
Broadcast message to persons that aren't playing
 o bdS(String)
Broadcast message to every clients
 o bdU(String)
Brodcast an update message
 o createBots()
Update the bots in the userlist
 o die()
 o log(String)
write a msg to the log stream
 o main(String[])
usage: ServM
 o rehash()
reload jSave.dat
 o run()
wait for incoming connections and open new streams

Variables

 o users
 static Hashtable users
users handle the uselist by binding a nick name to a Human()

 o games
 static Hashtable games
 o bots
 static Hashtable bots
 o mainPort
 int mainPort
 o MSocket
 ServerSocket MSocket
 o server
 Thread server

Constructors

 o ServM
 public ServM(int port)
Construct a new Server and launch the Thread

Methods

 o main
 public static void main(String args[])
usage: ServM

 o run
 public void run()
wait for incoming connections and open new streams

 o bdS
 static void bdS(String msg)
Broadcast message to every clients

 o bdM
 static void bdM(String msg)
Broadcast message to persons that aren't playing

 o bdU
 static void bdU(String key)
Brodcast an update message

 o rehash
 static void rehash()
reload jSave.dat

 o createBots
 static void createBots()
Update the bots in the userlist

 o log
 static void log(String msg)
write a msg to the log stream

 o die
 static void die()