Created
October 15, 2012 14:42
-
-
Save hjerpbakk/3892849 to your computer and use it in GitHub Desktop.
Dersom man har for mye kobling og for lite kohesjon...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Created on 22.apr.2005 | |
*/ | |
package sys; | |
import nett.*; | |
/** | |
* @author Uno, hjerpbak | |
*/ | |
public class Kohesjon extends Thread{ | |
private Connection con; | |
private boolean close; | |
private Server server; | |
private String melding; | |
private Melding meldinga; | |
public Kohesjon(Connection c, Server server){ | |
con = c; | |
this.server = server; | |
} | |
public void send(Melding meldinga) { | |
try { | |
con.send(meldinga.getMelding()); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
public void run(){ | |
close = false; | |
while(!close){ | |
try{ | |
melding = con.receive(); | |
meldinga = new Melding(); | |
meldinga.setMelding(melding); | |
if (meldinga.getType() == Melding.TEKST) | |
server.sendTilAlle(meldinga); | |
} catch(Exception e){} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment