spellcast.net
Class WizardSocket

java.lang.Object
  extended by spellcast.net.WizardSocket
All Implemented Interfaces:
IPCHandle

public class WizardSocket
extends java.lang.Object
implements IPCHandle

A Wizard Socket encapsulates the network communication required to send and receive game events.

Author:
Barrie Treloar

Constructor Summary
WizardSocket(VersionDetails programVersionDetails)
           
 
Method Summary
 void close()
          Immediately closes all input and output streams and closes the socket.
 Id getID()
          Get the value of id.
 java.net.Socket getSocket()
          Get the value of socket.
 boolean isConnected()
          Indicates whether the IPC system has connected the client yet.
 GameEvent receive()
          Receive a message from the socket.
 void send(GameEvent e)
          Send the GameEvent down the socket.
 void setID(Id v)
          Set the value of id.
 void setSocket(java.net.Socket v)
          Set the value of socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WizardSocket

public WizardSocket(VersionDetails programVersionDetails)
Method Detail

receive

public GameEvent receive()
                  throws java.io.IOException
Receive a message from the socket. If an entire message is not read in then return null. Each time this method is called try to build up an entire message. When one has been completely received then return it.

The format of the message is:

Throws:
java.io.IOException - if an I/O error occurs
See Also:
marshalMessage, unmarshalMessage

send

public void send(GameEvent e)
          throws java.io.IOException
Send the GameEvent down the socket. The format of the message is:

Throws:
java.io.IOException
See Also:
marshalMessage, unmarshalMessage

close

public void close()
Immediately closes all input and output streams and closes the socket. Other classes should ensure that no threads are currently using this object.


getSocket

public java.net.Socket getSocket()
Get the value of socket.

Returns:
value of socket.

setSocket

public void setSocket(java.net.Socket v)
               throws java.io.IOException
Set the value of socket.

Parameters:
v - Value to assign to socket.
Throws:
java.io.IOException

getID

public Id getID()
Get the value of id.

Returns:
value of id.

setID

public void setID(Id v)
Set the value of id.

Parameters:
v - Value to assign to id.

isConnected

public boolean isConnected()
Indicates whether the IPC system has connected the client yet. The WizardSocket is only connected when it has an Id that is not Id.NO_ONE.

Specified by:
isConnected in interface IPCHandle
See Also:
IPC.connect


Copyright © 2001-2005 Spellcast. All Rights Reserved.