// Path: src/main/java/org/nextrtc/signalingserver/cases/ExchangeSignalsBetweenMembers.java
// @Component
// @Scope("prototype")
// public class ExchangeSignalsBetweenMembers {
// 
//     private RTCConnections connections;
//     private ConnectionContextFactory factory;
// 
//     @Inject
//     public ExchangeSignalsBetweenMembers(RTCConnections connections, ConnectionContextFactory factory) {
//         this.connections = connections;
//         this.factory = factory;
//     }
// 
//     public synchronized void begin(Member from, Member to) {
//         connections.put(from, to, factory.create(from, to));
//         connections.get(from, to).ifPresent(ConnectionContext::begin);
//     }
// 
//     public synchronized void execute(InternalMessage message) {
//         connections.get(message.getFrom(), message.getTo()).ifPresent(context -> context.process(message));
//     }
// }
// 
// Path: src/main/java/org/nextrtc/signalingserver/cases/LeftConversation.java
// @Component(Signals.LEFT_HANDLER)
// public class LeftConversation implements SignalHandler {
// 
//     private NextRTCEventBus eventBus;
//     private ConversationRepository conversations;
// 
//     @Inject
//     public LeftConversation(NextRTCEventBus eventBus, ConversationRepository conversations) {
//         this.eventBus = eventBus;
//         this.conversations = conversations;
//     }
// 
//     public void execute(InternalMessage context) {
//         final Member leaving = context.getFrom();
//         Conversation conversation = checkPrecondition(leaving.getConversation());
// 
//         conversation.left(leaving);
//     }
// 
//     public void destroy(Conversation toRemove, Member last) {
//         eventBus.post(CONVERSATION_DESTROYED.basedOn(
//                 builder()
//                         .conversation(conversations.remove(toRemove.getId()))
//                         .from(last)));
//     }
// 
//     private Conversation checkPrecondition(Optional<Conversation> conversation) {
//         if (!conversation.isPresent()) {
//             throw CONVERSATION_NOT_FOUND.exception();
//         }
//         return conversation.get();
//     }
// 
// }
// 
// Path: src/main/java/org/nextrtc/signalingserver/domain/MessageSender.java
// public interface MessageSender {
//     void send(InternalMessage message);
// }


import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
package org.nextrtc.signalingserver.domain.conversation;


@Component
@Scope("prototype")
public class MeshConversation extends AbstractMeshConversation {
    public MeshConversation(String id) {
        super(id);
    }

// Path: src/main/java/org/nextrtc/signalingserver/cases/ExchangeSignalsBetweenMembers.java
// @Component
// @Scope("prototype")
// public class ExchangeSignalsBetweenMembers {
// 
//     private RTCConnections connections;
//     private ConnectionContextFactory factory;
// 
//     @Inject
//     public ExchangeSignalsBetweenMembers(RTCConnections connections, ConnectionContextFactory factory) {
//         this.connections = connections;
//         this.factory = factory;
//     }
// 
//     public synchronized void begin(Member from, Member to) {
//         connections.put(from, to, factory.create(from, to));
//         connections.get(from, to).ifPresent(ConnectionContext::begin);
//     }
// 
//     public synchronized void execute(InternalMessage message) {
//         connections.get(message.getFrom(), message.getTo()).ifPresent(context -> context.process(message));
//     }
// }
// 
// Path: src/main/java/org/nextrtc/signalingserver/cases/LeftConversation.java
// @Component(Signals.LEFT_HANDLER)
// public class LeftConversation implements SignalHandler {
// 
//     private NextRTCEventBus eventBus;
//     private ConversationRepository conversations;
// 
//     @Inject
//     public LeftConversation(NextRTCEventBus eventBus, ConversationRepository conversations) {
//         this.eventBus = eventBus;
//         this.conversations = conversations;
//     }
// 
//     public void execute(InternalMessage context) {
//         final Member leaving = context.getFrom();
//         Conversation conversation = checkPrecondition(leaving.getConversation());
// 
//         conversation.left(leaving);
//     }
// 
//     public void destroy(Conversation toRemove, Member last) {
//         eventBus.post(CONVERSATION_DESTROYED.basedOn(
//                 builder()
//                         .conversation(conversations.remove(toRemove.getId()))
//                         .from(last)));
//     }
// 
//     private Conversation checkPrecondition(Optional<Conversation> conversation) {
//         if (!conversation.isPresent()) {
//             throw CONVERSATION_NOT_FOUND.exception();
//         }
//         return conversation.get();
//     }
// 
// }
// 
// Path: src/main/java/org/nextrtc/signalingserver/domain/MessageSender.java
// public interface MessageSender {
//     void send(InternalMessage message);
// }


// Path: src/main/java/org/nextrtc/signalingserver/domain/conversation/MeshConversation.java
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

package org.nextrtc.signalingserver.domain.conversation;


@Component
@Scope("prototype")
public class MeshConversation extends AbstractMeshConversation {
    public MeshConversation(String id) {
        super(id);
    }

    public MeshConversation(String id, LeftConversation left, MessageSender sender, ExchangeSignalsBetweenMembers exchange) {