2

I want to create simple chat which uses 2 ports(8080 and 9090) without WebSocket.

I have my message class:

public class Message {

private String message;

public Message(){}

public Message(String message) {
    this.message = message;
}
//get and set method
}

My repository looks like:

@Repository
public class MessageManager {

    List<Message> messageList = new ArrayList<>();

    public List<Message> getMessage(){
        return messageList;
    }

    public void addMessage(Message message){
        messageList.add(message);
}
}

And GUI:

public class ChatGUI extends VerticalLayout {
//my fields to create chat

   @Autowired
public MessageManager messageManager;

public ChatGUI(){
    horizontalLayout.add(label);
    verticalLayout.add(inputTextArea,sendMessageButton,horizontalLayout);
    add(verticalLayout);
    sendMessageButton.addClickListener(e -> {
        Message message = new Message(inputTextArea.getValue());
        messageManager.addMessage(message);
        label.setText(messageManager.getMessage().toString() +"\n");
    });
}

And what should I do now? I want to run the same program and have acces in 2 differents ports and add message to list and display them. Does anybody have any idea how to solve this?

Frendom
  • 508
  • 6
  • 24
  • You want to run your program twice and each with different HTTP port? If yes, have a look at [this](https://stackoverflow.com/questions/21083170) post. There is a command line option that defines the server port in Spring Boot. – Steffen Harbich Jan 27 '19 at 15:11
  • @SteffenHarbich I solved this by adding another server in intelliJ and run the same programm on 2 different ports – Frendom Jan 27 '19 at 16:41

0 Answers0