package com.gruppe27.fellesprosjekt.server;

import com.esotericsoftware.kryonet.Connection;
import com.esotericsoftware.kryonet.Server;
import com.gruppe27.fellesprosjekt.common.Network;

import java.io.IOException;


public class CalendarServer {
    Server server;
    DatabaseConnector connector;

    public CalendarServer() {
        server = new Server() {
            protected Connection newConnection() {
                return new CalendarConnection();
            }
        };

        Network.register(server);

        server.addListener(new CalendarListener(server));

        try {
            server.bind(Network.PORT);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }

        server.start();
    }


    public static void main(String[] args) {
        CalendarServer server = new CalendarServer();
    }
}

@@ -246,16 +246,31 @@
 r %7B%0A    
+private static 
 Server s
@@ -274,16 +274,23 @@
 r server
+ = null
 ;%0A    Da
@@ -322,21 +322,24 @@
 ;%0A%0A    p
-ublic
+rotected
  Calenda
@@ -342,32 +342,112 @@
 endarServer() %7B%0A
+    %7D%0A%0A    public static Server getServer() %7B%0A        if (server == null) %7B%0A    
         server =
@@ -454,32 +454,36 @@
  new Server() %7B%0A
+    
             prot
@@ -533,16 +533,20 @@
         
+    
 return n
@@ -582,18 +582,26 @@
         
+   
+ 
 %7D%0A
+    
         
@@ -604,16 +604,20 @@
     %7D;%0A%0A
+    
         
@@ -639,24 +639,28 @@
 r(server);%0A%0A
+    
         serv
@@ -718,14 +718,22 @@
     
+    
 try %7B%0A
+    
     
@@ -767,16 +767,20 @@
 .PORT);%0A
+    
         
@@ -817,16 +817,20 @@
         
+    
 e.printS
@@ -854,16 +854,20 @@
         
+   
+ 
 System.e
@@ -878,24 +878,28 @@
 1);%0A        
+    
 %7D%0A%0A        s
@@ -893,24 +893,28 @@
  %7D%0A%0A        
+ 
+   
 server.start
@@ -921,16 +921,48 @@
 ();%0A
+        %7D%0A        return server;%0A
     %7D%0A%0A
-%0A
     
@@ -1028,30 +1028,12 @@
 rver
- server = new Calendar
+.get
 Serv

Make the calendar server a singleton