worker
Class MWorker

java.lang.Object
  extended by java.lang.Thread
      extended by worker.MWorker
All Implemented Interfaces:
java.lang.Runnable

public class MWorker
extends java.lang.Thread


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MWorker(int port, java.lang.String serverIP, java.lang.String nic, ClientGUI gui)
          The constructor of MWorker..
 
Method Summary
 ClientGUI accessGUI()
           
 java.lang.String getIPAdress()
          BE AWARE! - THIS METHOD SHOULDN'T BE USED ANY LONGER!
 javax.swing.DefaultListModel getListModel()
           
 java.lang.String getNic()
           
 void logon()
          This method just sends a logon-message to the server
(ip-adress configured when created new MWorker object!)
 void run()
          ..
 void sendFile(java.lang.String recipiant, java.io.File file)
          This is the main file-sending method!
 void sendMessage(java.lang.String recipiant, java.lang.String msg)
          This method is the main message-sending method!
 void setNewListModel(javax.swing.DefaultListModel dlm)
          This tiny method updates the userlist in the GUI.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MWorker

public MWorker(int port,
               java.lang.String serverIP,
               java.lang.String nic,
               ClientGUI gui)
The constructor of MWorker..
Creates new Instantce of MWorker!

Parameters:
port - ... the port on which messages will be sent
serverIP - ... the ip-adress of the server you're communicating with
nic - ... the client nickname
gui - ... the ClientGUI
Method Detail

getListModel

public javax.swing.DefaultListModel getListModel()

setNewListModel

public void setNewListModel(javax.swing.DefaultListModel dlm)
This tiny method updates the userlist in the GUI.

Parameters:
dlm - ... the new DefaultListModel (list of available users)

logon

public void logon()
This method just sends a logon-message to the server
(ip-adress configured when created new MWorker object!)


sendMessage

public void sendMessage(java.lang.String recipiant,
                        java.lang.String msg)
                 throws java.lang.Exception
This method is the main message-sending method!

Parameters:
recipiant - ... username of the user you want to send the message to!
msg - ... the message you want to send in form of a String.
Throws:
java.lang.Exception

sendFile

public void sendFile(java.lang.String recipiant,
                     java.io.File file)
              throws java.lang.Exception
This is the main file-sending method!

Parameters:
recipiant - ... username of the user you want to send the message to!
file - ... the File you want to send to a user (java.io.File)
Throws:
java.lang.Exception

run

public void run()
.. the Thread which checks always for incoming data!

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

getIPAdress

public java.lang.String getIPAdress()
                             throws java.lang.Exception
BE AWARE! - THIS METHOD SHOULDN'T BE USED ANY LONGER!

Returns:
the localhost ip-adress (ipV4) .. in form of a String!
Throws:
java.lang.Exception

getNic

public java.lang.String getNic()
Returns:
the client-nickname

accessGUI

public ClientGUI accessGUI()
Returns:
the ClientGUI-object the MWorker is working with!