123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
- package netz.model;
-
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.io.OutputStream;
- import java.io.OutputStreamWriter;
- import java.io.PrintWriter;
- import java.net.ServerSocket;
- import java.net.Socket;
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- import java.util.concurrent.Flow;
- import java.util.concurrent.SubmissionPublisher;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import netz.controller.ChatController;
- import ohmlogger.OhmLogger;
-
- /**
- *
- * @author chris
- */
- public class ChatModel
- {
- private static Logger lg = OhmLogger.getLogger();
- private ServerRunnable serverRunnable;
- private ClientRunnable clientRunnable;
- // private ChatController controller;
-
- public ChatModel()
- {
-
-
- }
- public void startServer(int PORT, ChatController chatcontroller) throws IOException
- {
- ServerSocket sSocket = new ServerSocket(PORT);
- serverRunnable = new ServerRunnable(sSocket);
- chatcontroller.upddateStatus("Server: Warte auf Verbindung ...");
-
- }
- public void startClient(int PORT, String ip_adresse, ChatController chatcontroller) throws IOException
- {
- clientRunnable = new ClientRunnable(ip_adresse, PORT);
- chatcontroller.upddateStatus("Client: Warte auf Verbindung ...");
-
- }
- }
- //public class Bandit implements Runnable
- //{
- // private static Logger lg = OhmLogger.getLogger();
- //
- // private BanditInfo info;
- // private volatile boolean laufend;
- // private ExecutorService eService;
- // private SubmissionPublisher<BanditInfo> iPublisher;
- //
- // public Bandit(int nr)
- // {
- // info = new BanditInfo(nr);
- // synchronized(this)
- // {
- // laufend = true;
- // }
- // eService = Executors.newSingleThreadExecutor();
- // iPublisher = new SubmissionPublisher<>();
- //
- // }
- //
- // /**
- // * startet würfeln
- // */
- // public synchronized void start()
- // {
- // laufend = true;
- // eService.submit(this);
- // this.notifyAll();
- // lg.info("Thread startet");
- // }
- //
- // /**
- // * stopt würfeln
- // *
- // */
- // public void stop()
- // {
- // synchronized(this)
- // {
- // laufend = false;
- // }
- // lg.info("Thread stopt");
- // }
- //
- // public void addSubscription(Flow.Subscriber<BanditInfo> subscriber)
- // {
- // iPublisher.subscribe(subscriber);
- // }
- //
- // private synchronized void doWait()
- // {
- // try
- // {
- // this.wait();
- // } catch (InterruptedException ex)
- // {
- // Logger.getLogger(Bandit.class.getName()).log(Level.SEVERE, null, ex);
- // }
- // }
- //
- // @Override
- // public void run()
- // {
- //
- // while(true)
- // {
- //
- // while(!laufend)
- // this.doWait();
- //
- // try
- // {
- // Thread.sleep(10);
- // } catch (InterruptedException ex)
- // {
- // Logger.getLogger(Bandit.class.getName()).log(Level.SEVERE, null, ex);
- // }
- // info.setZaehlerWert((int)(Math.round(Math.random()*100) % 9) + 1);
- // iPublisher.submit(info);
- // }
- // }
- //}
|