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
-
bots
-
-
games
-
-
mainPort
-
-
MSocket
-
-
server
-
-
users
-
users handle the uselist by binding a nick name to a Human()
-
ServM(int)
-
Construct a new Server and launch the Thread
-
bdM(String)
- Broadcast message to persons that aren't playing
-
bdS(String)
- Broadcast message to every clients
-
bdU(String)
- Brodcast an update message
-
createBots()
- Update the bots in the userlist
-
die()
-
-
log(String)
- write a msg to the log stream
-
main(String[])
- usage: ServM
-
rehash()
- reload jSave.dat
-
run()
-
wait for incoming connections and open new streams
users
static Hashtable users
- users handle the uselist by binding a nick name to a Human()
games
static Hashtable games
bots
static Hashtable bots
mainPort
int mainPort
MSocket
ServerSocket MSocket
server
Thread server
ServM
public ServM(int port)
- Construct a new Server and launch the Thread
main
public static void main(String args[])
- usage: ServM
run
public void run()
- wait for incoming connections and open new streams
bdS
static void bdS(String msg)
- Broadcast message to every clients
bdM
static void bdM(String msg)
- Broadcast message to persons that aren't playing
bdU
static void bdU(String key)
- Brodcast an update message
rehash
static void rehash()
- reload jSave.dat
createBots
static void createBots()
- Update the bots in the userlist
log
static void log(String msg)
- write a msg to the log stream
die
static void die()