package com.uzh.csg.overlaynetworks.web.controller;

import java.util.Set;

import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

import com.uzh.csg.overlaynetworks.domain.dto.ContactWithStatus;
import com.uzh.csg.overlaynetworks.domain.dto.ReceiveMessage;
import com.uzh.csg.overlaynetworks.domain.dto.ReceiveNotary;
import com.uzh.csg.overlaynetworks.web.dto.example.Greeting;
import com.uzh.csg.overlaynetworks.web.dto.example.HelloMessage;

@Controller
public class MainWebsocketController {

	/* EXAMPLE */
	@MessageMapping("/hello") // input
	@SendTo("/topic/greetings") // output
	public Greeting greeting(HelloMessage message) throws Exception {
		Thread.sleep(1000); // simulated delay
		return new Greeting("Hello, " + message.getName() + "!");
	}
	/* EXAMPLE END */

	@SendTo("/topic/receive-message")
	public ReceiveMessage receiveMessage(ReceiveMessage message) {
		return message;
	}

	@SendTo("/topic/receive-notary")
	public ReceiveNotary receiveNotary(ReceiveNotary notary) {
		return notary;
	}

	@SendTo("/topic/update-contacts")
	public Set<ContactWithStatus> updateContacts(Set<ContactWithStatus> contactsWithStatus) {
		return contactsWithStatus;
	}

}
@@ -69,16 +69,79 @@
 l.Set;%0A%0A
+import org.springframework.beans.factory.annotation.Autowired;%0A
 import o
@@ -200,24 +200,24 @@
 ageMapping;%0A
-
 import org.s
@@ -686,16 +686,77 @@
 ller %7B%0A%0A
+%09@Autowired%0A%09private MainRestController mainRestController;%0A%0A
 %09/* EXAM
@@ -1386,24 +1386,24 @@
 thStatus) %7B%0A
-
 %09%09return con
@@ -1423,9 +1423,96 @@
 us;%0A%09%7D%0A%0A
+%09@MessageMapping(%22/logout%22)%0A%09public void logout() %7B%0A%09%09mainRestController.logout();%0A%09%7D%0A%0A
 %7D

add logout as a websocket interface