repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCMedia.java | // 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/domain/DefaultMessageSender.java
// @Component
// @Scope("singleton")
// @Slf4j
// public class DefaultMessageSender implements MessageSender {
//
// private MemberRepository members;
//
// @Inject
// public DefaultMessageSender(MemberRepository members) {
// this.members = members;
// }
//
// @Override
// public void send(InternalMessage message) {
// send(message, 3);
// }
//
// private void send(InternalMessage message, int retry) {
// if (message.getSignal() != Signal.PING) {
// log.debug("Outgoing: " + message.transformToExternalMessage());
// }
// if (message.getSignal() == Signal.ERROR) {
// tryToSendErrorMessage(message);
// return;
// }
// Member destination = message.getTo();
// if (destination == null || !destination.getConnection().isOpen()) {
// log.warn("Destination member is not set or session is closed! Message will not be send: " + message.transformToExternalMessage());
// return;
// }
// members.findBy(destination.getId()).ifPresent(member ->
// lockAndRun(message, member, retry)
// );
// }
//
// private void tryToSendErrorMessage(InternalMessage message) {
// try {
// Connection connection = message.getTo().getConnection();
// synchronized (connection) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
//
// private void lockAndRun(InternalMessage message, Member destination, int retry) {
// try {
// Connection connection = destination.getConnection();
// synchronized (destination) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// if (retry >= 0) {
// log.warn("Retrying... " + message.transformToExternalMessage());
// send(message, --retry);
// }
// log.error("Unable to send message: " + message.transformToExternalMessage() + " error during sending!");
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/RTCConnections.java
// @Component
// @Scope("singleton")
// public class RTCConnections implements Closeable{
// private static Table<Member, Member, ConnectionContext> connections = HashBasedTable.create();
//
// private ScheduledExecutorService scheduler;
// private NextRTCProperties properties;
//
// @Inject
// public RTCConnections(ScheduledExecutorService scheduler, NextRTCProperties properties) {
// this.scheduler = scheduler;
// this.properties = properties;
// }
//
// @PostConstruct
// void cleanOldConnections() {
// scheduler.scheduleWithFixedDelay(this::removeOldConnections,
// properties.getMaxConnectionSetupTime(),
// properties.getMaxConnectionSetupTime(),
// TimeUnit.SECONDS);
// }
//
// void removeOldConnections() {
// List<ConnectionContext> oldConnections = connections.values().stream()
// .filter(context -> !context.isCurrent())
// .collect(Collectors.toList());
// oldConnections.forEach(c -> connections.remove(c.getMaster(), c.getSlave()));
// }
//
// public void put(Member from, Member to, ConnectionContext ctx) {
// connections.put(from, to, ctx);
// connections.put(to, from, ctx);
// }
//
// public Optional<ConnectionContext> get(Member from, Member to) {
// return Optional.ofNullable(connections.get(from, to));
// }
//
//
// @Override
// public void close() throws IOException {
// connections.clear();
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConnectionContextFactory.java
// public interface ConnectionContextFactory {
// ConnectionContext create(Member from, Member to);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
| import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.domain.DefaultMessageSender;
import org.nextrtc.signalingserver.domain.RTCConnections;
import org.nextrtc.signalingserver.factory.ConnectionContextFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import javax.inject.Singleton;
import java.util.concurrent.ScheduledExecutorService; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCMedia {
@Provides | // 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/domain/DefaultMessageSender.java
// @Component
// @Scope("singleton")
// @Slf4j
// public class DefaultMessageSender implements MessageSender {
//
// private MemberRepository members;
//
// @Inject
// public DefaultMessageSender(MemberRepository members) {
// this.members = members;
// }
//
// @Override
// public void send(InternalMessage message) {
// send(message, 3);
// }
//
// private void send(InternalMessage message, int retry) {
// if (message.getSignal() != Signal.PING) {
// log.debug("Outgoing: " + message.transformToExternalMessage());
// }
// if (message.getSignal() == Signal.ERROR) {
// tryToSendErrorMessage(message);
// return;
// }
// Member destination = message.getTo();
// if (destination == null || !destination.getConnection().isOpen()) {
// log.warn("Destination member is not set or session is closed! Message will not be send: " + message.transformToExternalMessage());
// return;
// }
// members.findBy(destination.getId()).ifPresent(member ->
// lockAndRun(message, member, retry)
// );
// }
//
// private void tryToSendErrorMessage(InternalMessage message) {
// try {
// Connection connection = message.getTo().getConnection();
// synchronized (connection) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
//
// private void lockAndRun(InternalMessage message, Member destination, int retry) {
// try {
// Connection connection = destination.getConnection();
// synchronized (destination) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// if (retry >= 0) {
// log.warn("Retrying... " + message.transformToExternalMessage());
// send(message, --retry);
// }
// log.error("Unable to send message: " + message.transformToExternalMessage() + " error during sending!");
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/RTCConnections.java
// @Component
// @Scope("singleton")
// public class RTCConnections implements Closeable{
// private static Table<Member, Member, ConnectionContext> connections = HashBasedTable.create();
//
// private ScheduledExecutorService scheduler;
// private NextRTCProperties properties;
//
// @Inject
// public RTCConnections(ScheduledExecutorService scheduler, NextRTCProperties properties) {
// this.scheduler = scheduler;
// this.properties = properties;
// }
//
// @PostConstruct
// void cleanOldConnections() {
// scheduler.scheduleWithFixedDelay(this::removeOldConnections,
// properties.getMaxConnectionSetupTime(),
// properties.getMaxConnectionSetupTime(),
// TimeUnit.SECONDS);
// }
//
// void removeOldConnections() {
// List<ConnectionContext> oldConnections = connections.values().stream()
// .filter(context -> !context.isCurrent())
// .collect(Collectors.toList());
// oldConnections.forEach(c -> connections.remove(c.getMaster(), c.getSlave()));
// }
//
// public void put(Member from, Member to, ConnectionContext ctx) {
// connections.put(from, to, ctx);
// connections.put(to, from, ctx);
// }
//
// public Optional<ConnectionContext> get(Member from, Member to) {
// return Optional.ofNullable(connections.get(from, to));
// }
//
//
// @Override
// public void close() throws IOException {
// connections.clear();
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConnectionContextFactory.java
// public interface ConnectionContextFactory {
// ConnectionContext create(Member from, Member to);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCMedia.java
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.domain.DefaultMessageSender;
import org.nextrtc.signalingserver.domain.RTCConnections;
import org.nextrtc.signalingserver.factory.ConnectionContextFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import javax.inject.Singleton;
import java.util.concurrent.ScheduledExecutorService;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCMedia {
@Provides | static DefaultMessageSender defaultMessageSender(MemberRepository repo) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCMedia.java | // 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/domain/DefaultMessageSender.java
// @Component
// @Scope("singleton")
// @Slf4j
// public class DefaultMessageSender implements MessageSender {
//
// private MemberRepository members;
//
// @Inject
// public DefaultMessageSender(MemberRepository members) {
// this.members = members;
// }
//
// @Override
// public void send(InternalMessage message) {
// send(message, 3);
// }
//
// private void send(InternalMessage message, int retry) {
// if (message.getSignal() != Signal.PING) {
// log.debug("Outgoing: " + message.transformToExternalMessage());
// }
// if (message.getSignal() == Signal.ERROR) {
// tryToSendErrorMessage(message);
// return;
// }
// Member destination = message.getTo();
// if (destination == null || !destination.getConnection().isOpen()) {
// log.warn("Destination member is not set or session is closed! Message will not be send: " + message.transformToExternalMessage());
// return;
// }
// members.findBy(destination.getId()).ifPresent(member ->
// lockAndRun(message, member, retry)
// );
// }
//
// private void tryToSendErrorMessage(InternalMessage message) {
// try {
// Connection connection = message.getTo().getConnection();
// synchronized (connection) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
//
// private void lockAndRun(InternalMessage message, Member destination, int retry) {
// try {
// Connection connection = destination.getConnection();
// synchronized (destination) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// if (retry >= 0) {
// log.warn("Retrying... " + message.transformToExternalMessage());
// send(message, --retry);
// }
// log.error("Unable to send message: " + message.transformToExternalMessage() + " error during sending!");
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/RTCConnections.java
// @Component
// @Scope("singleton")
// public class RTCConnections implements Closeable{
// private static Table<Member, Member, ConnectionContext> connections = HashBasedTable.create();
//
// private ScheduledExecutorService scheduler;
// private NextRTCProperties properties;
//
// @Inject
// public RTCConnections(ScheduledExecutorService scheduler, NextRTCProperties properties) {
// this.scheduler = scheduler;
// this.properties = properties;
// }
//
// @PostConstruct
// void cleanOldConnections() {
// scheduler.scheduleWithFixedDelay(this::removeOldConnections,
// properties.getMaxConnectionSetupTime(),
// properties.getMaxConnectionSetupTime(),
// TimeUnit.SECONDS);
// }
//
// void removeOldConnections() {
// List<ConnectionContext> oldConnections = connections.values().stream()
// .filter(context -> !context.isCurrent())
// .collect(Collectors.toList());
// oldConnections.forEach(c -> connections.remove(c.getMaster(), c.getSlave()));
// }
//
// public void put(Member from, Member to, ConnectionContext ctx) {
// connections.put(from, to, ctx);
// connections.put(to, from, ctx);
// }
//
// public Optional<ConnectionContext> get(Member from, Member to) {
// return Optional.ofNullable(connections.get(from, to));
// }
//
//
// @Override
// public void close() throws IOException {
// connections.clear();
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConnectionContextFactory.java
// public interface ConnectionContextFactory {
// ConnectionContext create(Member from, Member to);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
| import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.domain.DefaultMessageSender;
import org.nextrtc.signalingserver.domain.RTCConnections;
import org.nextrtc.signalingserver.factory.ConnectionContextFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import javax.inject.Singleton;
import java.util.concurrent.ScheduledExecutorService; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCMedia {
@Provides
static DefaultMessageSender defaultMessageSender(MemberRepository repo) {
return new DefaultMessageSender(repo);
}
@Provides
@Singleton | // 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/domain/DefaultMessageSender.java
// @Component
// @Scope("singleton")
// @Slf4j
// public class DefaultMessageSender implements MessageSender {
//
// private MemberRepository members;
//
// @Inject
// public DefaultMessageSender(MemberRepository members) {
// this.members = members;
// }
//
// @Override
// public void send(InternalMessage message) {
// send(message, 3);
// }
//
// private void send(InternalMessage message, int retry) {
// if (message.getSignal() != Signal.PING) {
// log.debug("Outgoing: " + message.transformToExternalMessage());
// }
// if (message.getSignal() == Signal.ERROR) {
// tryToSendErrorMessage(message);
// return;
// }
// Member destination = message.getTo();
// if (destination == null || !destination.getConnection().isOpen()) {
// log.warn("Destination member is not set or session is closed! Message will not be send: " + message.transformToExternalMessage());
// return;
// }
// members.findBy(destination.getId()).ifPresent(member ->
// lockAndRun(message, member, retry)
// );
// }
//
// private void tryToSendErrorMessage(InternalMessage message) {
// try {
// Connection connection = message.getTo().getConnection();
// synchronized (connection) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
//
// private void lockAndRun(InternalMessage message, Member destination, int retry) {
// try {
// Connection connection = destination.getConnection();
// synchronized (destination) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// if (retry >= 0) {
// log.warn("Retrying... " + message.transformToExternalMessage());
// send(message, --retry);
// }
// log.error("Unable to send message: " + message.transformToExternalMessage() + " error during sending!");
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/RTCConnections.java
// @Component
// @Scope("singleton")
// public class RTCConnections implements Closeable{
// private static Table<Member, Member, ConnectionContext> connections = HashBasedTable.create();
//
// private ScheduledExecutorService scheduler;
// private NextRTCProperties properties;
//
// @Inject
// public RTCConnections(ScheduledExecutorService scheduler, NextRTCProperties properties) {
// this.scheduler = scheduler;
// this.properties = properties;
// }
//
// @PostConstruct
// void cleanOldConnections() {
// scheduler.scheduleWithFixedDelay(this::removeOldConnections,
// properties.getMaxConnectionSetupTime(),
// properties.getMaxConnectionSetupTime(),
// TimeUnit.SECONDS);
// }
//
// void removeOldConnections() {
// List<ConnectionContext> oldConnections = connections.values().stream()
// .filter(context -> !context.isCurrent())
// .collect(Collectors.toList());
// oldConnections.forEach(c -> connections.remove(c.getMaster(), c.getSlave()));
// }
//
// public void put(Member from, Member to, ConnectionContext ctx) {
// connections.put(from, to, ctx);
// connections.put(to, from, ctx);
// }
//
// public Optional<ConnectionContext> get(Member from, Member to) {
// return Optional.ofNullable(connections.get(from, to));
// }
//
//
// @Override
// public void close() throws IOException {
// connections.clear();
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConnectionContextFactory.java
// public interface ConnectionContextFactory {
// ConnectionContext create(Member from, Member to);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCMedia.java
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.domain.DefaultMessageSender;
import org.nextrtc.signalingserver.domain.RTCConnections;
import org.nextrtc.signalingserver.factory.ConnectionContextFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import javax.inject.Singleton;
import java.util.concurrent.ScheduledExecutorService;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCMedia {
@Provides
static DefaultMessageSender defaultMessageSender(MemberRepository repo) {
return new DefaultMessageSender(repo);
}
@Provides
@Singleton | static RTCConnections RTCConnections(ScheduledExecutorService scheduler, NextRTCProperties properties) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCMedia.java | // 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/domain/DefaultMessageSender.java
// @Component
// @Scope("singleton")
// @Slf4j
// public class DefaultMessageSender implements MessageSender {
//
// private MemberRepository members;
//
// @Inject
// public DefaultMessageSender(MemberRepository members) {
// this.members = members;
// }
//
// @Override
// public void send(InternalMessage message) {
// send(message, 3);
// }
//
// private void send(InternalMessage message, int retry) {
// if (message.getSignal() != Signal.PING) {
// log.debug("Outgoing: " + message.transformToExternalMessage());
// }
// if (message.getSignal() == Signal.ERROR) {
// tryToSendErrorMessage(message);
// return;
// }
// Member destination = message.getTo();
// if (destination == null || !destination.getConnection().isOpen()) {
// log.warn("Destination member is not set or session is closed! Message will not be send: " + message.transformToExternalMessage());
// return;
// }
// members.findBy(destination.getId()).ifPresent(member ->
// lockAndRun(message, member, retry)
// );
// }
//
// private void tryToSendErrorMessage(InternalMessage message) {
// try {
// Connection connection = message.getTo().getConnection();
// synchronized (connection) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
//
// private void lockAndRun(InternalMessage message, Member destination, int retry) {
// try {
// Connection connection = destination.getConnection();
// synchronized (destination) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// if (retry >= 0) {
// log.warn("Retrying... " + message.transformToExternalMessage());
// send(message, --retry);
// }
// log.error("Unable to send message: " + message.transformToExternalMessage() + " error during sending!");
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/RTCConnections.java
// @Component
// @Scope("singleton")
// public class RTCConnections implements Closeable{
// private static Table<Member, Member, ConnectionContext> connections = HashBasedTable.create();
//
// private ScheduledExecutorService scheduler;
// private NextRTCProperties properties;
//
// @Inject
// public RTCConnections(ScheduledExecutorService scheduler, NextRTCProperties properties) {
// this.scheduler = scheduler;
// this.properties = properties;
// }
//
// @PostConstruct
// void cleanOldConnections() {
// scheduler.scheduleWithFixedDelay(this::removeOldConnections,
// properties.getMaxConnectionSetupTime(),
// properties.getMaxConnectionSetupTime(),
// TimeUnit.SECONDS);
// }
//
// void removeOldConnections() {
// List<ConnectionContext> oldConnections = connections.values().stream()
// .filter(context -> !context.isCurrent())
// .collect(Collectors.toList());
// oldConnections.forEach(c -> connections.remove(c.getMaster(), c.getSlave()));
// }
//
// public void put(Member from, Member to, ConnectionContext ctx) {
// connections.put(from, to, ctx);
// connections.put(to, from, ctx);
// }
//
// public Optional<ConnectionContext> get(Member from, Member to) {
// return Optional.ofNullable(connections.get(from, to));
// }
//
//
// @Override
// public void close() throws IOException {
// connections.clear();
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConnectionContextFactory.java
// public interface ConnectionContextFactory {
// ConnectionContext create(Member from, Member to);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
| import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.domain.DefaultMessageSender;
import org.nextrtc.signalingserver.domain.RTCConnections;
import org.nextrtc.signalingserver.factory.ConnectionContextFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import javax.inject.Singleton;
import java.util.concurrent.ScheduledExecutorService; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCMedia {
@Provides
static DefaultMessageSender defaultMessageSender(MemberRepository repo) {
return new DefaultMessageSender(repo);
}
@Provides
@Singleton | // 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/domain/DefaultMessageSender.java
// @Component
// @Scope("singleton")
// @Slf4j
// public class DefaultMessageSender implements MessageSender {
//
// private MemberRepository members;
//
// @Inject
// public DefaultMessageSender(MemberRepository members) {
// this.members = members;
// }
//
// @Override
// public void send(InternalMessage message) {
// send(message, 3);
// }
//
// private void send(InternalMessage message, int retry) {
// if (message.getSignal() != Signal.PING) {
// log.debug("Outgoing: " + message.transformToExternalMessage());
// }
// if (message.getSignal() == Signal.ERROR) {
// tryToSendErrorMessage(message);
// return;
// }
// Member destination = message.getTo();
// if (destination == null || !destination.getConnection().isOpen()) {
// log.warn("Destination member is not set or session is closed! Message will not be send: " + message.transformToExternalMessage());
// return;
// }
// members.findBy(destination.getId()).ifPresent(member ->
// lockAndRun(message, member, retry)
// );
// }
//
// private void tryToSendErrorMessage(InternalMessage message) {
// try {
// Connection connection = message.getTo().getConnection();
// synchronized (connection) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
//
// private void lockAndRun(InternalMessage message, Member destination, int retry) {
// try {
// Connection connection = destination.getConnection();
// synchronized (destination) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// if (retry >= 0) {
// log.warn("Retrying... " + message.transformToExternalMessage());
// send(message, --retry);
// }
// log.error("Unable to send message: " + message.transformToExternalMessage() + " error during sending!");
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/RTCConnections.java
// @Component
// @Scope("singleton")
// public class RTCConnections implements Closeable{
// private static Table<Member, Member, ConnectionContext> connections = HashBasedTable.create();
//
// private ScheduledExecutorService scheduler;
// private NextRTCProperties properties;
//
// @Inject
// public RTCConnections(ScheduledExecutorService scheduler, NextRTCProperties properties) {
// this.scheduler = scheduler;
// this.properties = properties;
// }
//
// @PostConstruct
// void cleanOldConnections() {
// scheduler.scheduleWithFixedDelay(this::removeOldConnections,
// properties.getMaxConnectionSetupTime(),
// properties.getMaxConnectionSetupTime(),
// TimeUnit.SECONDS);
// }
//
// void removeOldConnections() {
// List<ConnectionContext> oldConnections = connections.values().stream()
// .filter(context -> !context.isCurrent())
// .collect(Collectors.toList());
// oldConnections.forEach(c -> connections.remove(c.getMaster(), c.getSlave()));
// }
//
// public void put(Member from, Member to, ConnectionContext ctx) {
// connections.put(from, to, ctx);
// connections.put(to, from, ctx);
// }
//
// public Optional<ConnectionContext> get(Member from, Member to) {
// return Optional.ofNullable(connections.get(from, to));
// }
//
//
// @Override
// public void close() throws IOException {
// connections.clear();
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConnectionContextFactory.java
// public interface ConnectionContextFactory {
// ConnectionContext create(Member from, Member to);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCMedia.java
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.domain.DefaultMessageSender;
import org.nextrtc.signalingserver.domain.RTCConnections;
import org.nextrtc.signalingserver.factory.ConnectionContextFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import javax.inject.Singleton;
import java.util.concurrent.ScheduledExecutorService;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCMedia {
@Provides
static DefaultMessageSender defaultMessageSender(MemberRepository repo) {
return new DefaultMessageSender(repo);
}
@Provides
@Singleton | static RTCConnections RTCConnections(ScheduledExecutorService scheduler, NextRTCProperties properties) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCFactories.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
| import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.factory.*;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import javax.inject.Singleton; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCFactories {
@Provides
@Singleton | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCFactories.java
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.factory.*;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import javax.inject.Singleton;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCFactories {
@Provides
@Singleton | static ManualConversationFactory ManualConversationFactory(LeftConversation left, |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCFactories.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
| import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.factory.*;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import javax.inject.Singleton; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCFactories {
@Provides
@Singleton
static ManualConversationFactory ManualConversationFactory(LeftConversation left, | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCFactories.java
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.factory.*;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import javax.inject.Singleton;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCFactories {
@Provides
@Singleton
static ManualConversationFactory ManualConversationFactory(LeftConversation left, | MessageSender sender, |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCFactories.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
| import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.factory.*;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import javax.inject.Singleton; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCFactories {
@Provides
@Singleton
static ManualConversationFactory ManualConversationFactory(LeftConversation left,
MessageSender sender, | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCFactories.java
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.factory.*;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import javax.inject.Singleton;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCFactories {
@Provides
@Singleton
static ManualConversationFactory ManualConversationFactory(LeftConversation left,
MessageSender sender, | ExchangeSignalsBetweenMembers exchange, |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCFactories.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
| import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.factory.*;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import javax.inject.Singleton; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCFactories {
@Provides
@Singleton
static ManualConversationFactory ManualConversationFactory(LeftConversation left,
MessageSender sender,
ExchangeSignalsBetweenMembers exchange, | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCFactories.java
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.factory.*;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import javax.inject.Singleton;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCFactories {
@Provides
@Singleton
static ManualConversationFactory ManualConversationFactory(LeftConversation left,
MessageSender sender,
ExchangeSignalsBetweenMembers exchange, | NextRTCProperties properties) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCFactories.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
| import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.factory.*;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import javax.inject.Singleton; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCFactories {
@Provides
@Singleton
static ManualConversationFactory ManualConversationFactory(LeftConversation left,
MessageSender sender,
ExchangeSignalsBetweenMembers exchange,
NextRTCProperties properties) {
return new ManualConversationFactory(left, exchange, sender, properties);
}
@Provides
@Singleton | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCFactories.java
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.factory.*;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import javax.inject.Singleton;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCFactories {
@Provides
@Singleton
static ManualConversationFactory ManualConversationFactory(LeftConversation left,
MessageSender sender,
ExchangeSignalsBetweenMembers exchange,
NextRTCProperties properties) {
return new ManualConversationFactory(left, exchange, sender, properties);
}
@Provides
@Singleton | static ManualMemberFactory ManualMemberFactory(NextRTCEventBus eventBus) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/conversation/BroadcastConversation.java | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// 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();
// }
//
// }
| import com.google.common.collect.Sets;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Set; | package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public class BroadcastConversation extends Conversation {
| // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// 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/conversation/BroadcastConversation.java
import com.google.common.collect.Sets;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Set;
package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public class BroadcastConversation extends Conversation {
| private ExchangeSignalsBetweenMembers exchange; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/conversation/BroadcastConversation.java | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// 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();
// }
//
// }
| import com.google.common.collect.Sets;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Set; | package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public class BroadcastConversation extends Conversation {
private ExchangeSignalsBetweenMembers exchange;
private Member broadcaster;
private Set<Member> audience = Sets.newConcurrentHashSet();
public BroadcastConversation(String id) {
super(id);
}
public BroadcastConversation(String id, | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// 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/conversation/BroadcastConversation.java
import com.google.common.collect.Sets;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Set;
package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public class BroadcastConversation extends Conversation {
private ExchangeSignalsBetweenMembers exchange;
private Member broadcaster;
private Set<Member> audience = Sets.newConcurrentHashSet();
public BroadcastConversation(String id) {
super(id);
}
public BroadcastConversation(String id, | LeftConversation left, |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/conversation/BroadcastConversation.java | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// 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();
// }
//
// }
| import com.google.common.collect.Sets;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Set; | exchange.begin(broadcaster, sender);
}
}
private void sendJoinedToBroadcaster(Member sender, String id) {
messageSender.send(InternalMessage.create()//
.to(sender)//
.signal(Signal.CREATED)//
.addCustom("type", "BROADCAST")
.content(id)//
.build()//
);
}
@Override
public void close() throws IOException {
remove(broadcaster);
}
@Inject
public void setExchange(ExchangeSignalsBetweenMembers exchange) {
this.exchange = exchange;
}
@Override
public Member getCreator() {
return broadcaster;
}
@Override | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// 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/conversation/BroadcastConversation.java
import com.google.common.collect.Sets;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Set;
exchange.begin(broadcaster, sender);
}
}
private void sendJoinedToBroadcaster(Member sender, String id) {
messageSender.send(InternalMessage.create()//
.to(sender)//
.signal(Signal.CREATED)//
.addCustom("type", "BROADCAST")
.content(id)//
.build()//
);
}
@Override
public void close() throws IOException {
remove(broadcaster);
}
@Inject
public void setExchange(ExchangeSignalsBetweenMembers exchange) {
this.exchange = exchange;
}
@Override
public Member getCreator() {
return broadcaster;
}
@Override | public Set<NextRTCMember> getMembers() { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/eventbus/EventBusSetup.java | // Path: src/main/java/org/nextrtc/signalingserver/Names.java
// public interface Names {
// String EVENT_BUS = "nextRTCEventBus";
// String EVENT_DISPATCHER = "nextRTCEventDispatcher";
//
// String SCHEDULER_SIZE = "${nextrtc.scheduler_size:10}";
// String SCHEDULER_NAME = "nextRTCPingScheduler";
// String SCHEDULED_PERIOD = "${nextrtc.ping_period:3}";
// String MAX_CONNECTION_SETUP_TIME = "${nextrtc.max_connection_setup_time:30}";
// String JOIN_ONLY_TO_EXISTING = "${nextrtc.join_only_to_existing:false}";
//
// String DEFAULT_CONVERSATION_TYPE = "${nextrtc.default_conversation_type:MESH}";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
| import org.nextrtc.signalingserver.Names;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.annotation.NextRTCEventListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; | package org.nextrtc.signalingserver.eventbus;
@Component("nextRTCEventBusSetup")
@Scope("singleton")
public class EventBusSetup {
@Autowired | // Path: src/main/java/org/nextrtc/signalingserver/Names.java
// public interface Names {
// String EVENT_BUS = "nextRTCEventBus";
// String EVENT_DISPATCHER = "nextRTCEventDispatcher";
//
// String SCHEDULER_SIZE = "${nextrtc.scheduler_size:10}";
// String SCHEDULER_NAME = "nextRTCPingScheduler";
// String SCHEDULED_PERIOD = "${nextrtc.ping_period:3}";
// String MAX_CONNECTION_SETUP_TIME = "${nextrtc.max_connection_setup_time:30}";
// String JOIN_ONLY_TO_EXISTING = "${nextrtc.join_only_to_existing:false}";
//
// String DEFAULT_CONVERSATION_TYPE = "${nextrtc.default_conversation_type:MESH}";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/eventbus/EventBusSetup.java
import org.nextrtc.signalingserver.Names;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.annotation.NextRTCEventListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
package org.nextrtc.signalingserver.eventbus;
@Component("nextRTCEventBusSetup")
@Scope("singleton")
public class EventBusSetup {
@Autowired | @Qualifier(Names.EVENT_BUS) |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/eventbus/EventBusSetup.java | // Path: src/main/java/org/nextrtc/signalingserver/Names.java
// public interface Names {
// String EVENT_BUS = "nextRTCEventBus";
// String EVENT_DISPATCHER = "nextRTCEventDispatcher";
//
// String SCHEDULER_SIZE = "${nextrtc.scheduler_size:10}";
// String SCHEDULER_NAME = "nextRTCPingScheduler";
// String SCHEDULED_PERIOD = "${nextrtc.ping_period:3}";
// String MAX_CONNECTION_SETUP_TIME = "${nextrtc.max_connection_setup_time:30}";
// String JOIN_ONLY_TO_EXISTING = "${nextrtc.join_only_to_existing:false}";
//
// String DEFAULT_CONVERSATION_TYPE = "${nextrtc.default_conversation_type:MESH}";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
| import org.nextrtc.signalingserver.Names;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.annotation.NextRTCEventListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; | package org.nextrtc.signalingserver.eventbus;
@Component("nextRTCEventBusSetup")
@Scope("singleton")
public class EventBusSetup {
@Autowired
@Qualifier(Names.EVENT_BUS) | // Path: src/main/java/org/nextrtc/signalingserver/Names.java
// public interface Names {
// String EVENT_BUS = "nextRTCEventBus";
// String EVENT_DISPATCHER = "nextRTCEventDispatcher";
//
// String SCHEDULER_SIZE = "${nextrtc.scheduler_size:10}";
// String SCHEDULER_NAME = "nextRTCPingScheduler";
// String SCHEDULED_PERIOD = "${nextrtc.ping_period:3}";
// String MAX_CONNECTION_SETUP_TIME = "${nextrtc.max_connection_setup_time:30}";
// String JOIN_ONLY_TO_EXISTING = "${nextrtc.join_only_to_existing:false}";
//
// String DEFAULT_CONVERSATION_TYPE = "${nextrtc.default_conversation_type:MESH}";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/eventbus/EventBusSetup.java
import org.nextrtc.signalingserver.Names;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.annotation.NextRTCEventListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
package org.nextrtc.signalingserver.eventbus;
@Component("nextRTCEventBusSetup")
@Scope("singleton")
public class EventBusSetup {
@Autowired
@Qualifier(Names.EVENT_BUS) | private NextRTCEventBus eventBus; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/conversation/MeshConversation.java | // 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) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/conversation/MeshConversation.java | // 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) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/conversation/MeshConversation.java | // 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) { |
mslosarz/nextrtc-signaling-server | src/test/java/org/nextrtc/signalingserver/domain/PingTaskTest.java | // Path: src/test/java/org/nextrtc/signalingserver/BaseTest.java
// @ContextConfiguration(classes = {TestConfig.class})
// @RunWith(SpringJUnit4ClassRunner.class)
// public abstract class BaseTest {
//
// @Autowired
// private CreateConversation create;
//
// @Autowired
// private JoinConversation join;
//
// @Autowired
// private Members members;
//
// @Autowired
// private Conversations conversations;
//
// @Autowired
// private List<EventChecker> checkers;
//
// @Autowired
// private ApplicationContext context;
//
// @Before
// public void reset() {
//
// for (String id : conversations.getAllIds()) {
// conversations.remove(id);
// }
// for (String id : members.getAllIds()) {
// members.unregister(id);
// }
// for (EventChecker checker : checkers) {
// checker.reset();
// }
// }
//
// protected Connection mockConnection(String string) {
// return mockConnection(string, new MessageMatcher());
// }
//
// protected Connection mockConnection(String id, ArgumentMatcher<Message> match) {
// Connection s = mock(Connection.class);
// when(s.getId()).thenReturn(id);
// when(s.isOpen()).thenReturn(true);
// doNothing().when(s).sendObject(Mockito.argThat(match));
// return s;
// }
//
// protected Member mockMember(String string) {
// return context.getBean(Member.class, mockConnection(string), mock(ScheduledFuture.class));
// }
//
// protected Member mockMember(String string, ArgumentMatcher<Message> match) {
// return context.getBean(Member.class, mockConnection(string, match), mock(ScheduledFuture.class));
// }
//
// protected void createConversation(String conversationName, Member member) {
// members.register(member);
// create.execute(InternalMessage.create()//
// .from(member)//
// .content(conversationName)//
// .build());
// }
//
// protected void createBroadcastConversation(String conversationName, Member member) {
// members.register(member);
// create.execute(InternalMessage.create()//
// .from(member)//
// .content(conversationName)//
// .addCustom("type", "BROADCAST")//
// .build());
// }
//
// protected void joinConversation(String conversationName, Member member) {
// members.register(member);
// join.execute(InternalMessage.create()//
// .from(member)//
// .content(conversationName)//
// .build());
// }
//
// protected void assertMessage(MessageMatcher matcher, int number, String from, String to, String signal, String content) {
// assertThat(matcher.getMessage(number).getFrom(), is(from));
// assertThat(matcher.getMessage(number).getTo(), is(to));
// assertThat(matcher.getMessage(number).getSignal(), is(signal));
// assertThat(matcher.getMessage(number).getContent(), is(content));
// }
// }
//
// Path: src/test/java/org/nextrtc/signalingserver/MessageMatcher.java
// @Slf4j
// public class MessageMatcher extends ArgumentMatcher<Message> {
//
// private final List<String> filter;
// private List<Message> messages = Collections.synchronizedList(new ArrayList<>());
//
// public MessageMatcher() {
// this.filter = Arrays.asList("ping");
// }
//
// public MessageMatcher(String... filter) {
// this.filter = Arrays.asList(filter);
// }
//
// @Override
// public boolean matches(Object argument) {
// if (argument instanceof Message) {
// Message msg = (Message) argument;
// if (!filter.contains(msg.getSignal())) {
// messages.add(msg);
// }
// return true;
// }
// return false;
// }
//
// public Message getMessage() {
// return messages.get(0);
// }
//
// public Message getMessage(int number) {
// if (messages.size() <= number) {
// return null;
// }
// return messages.get(number);
// }
//
// public void reset() {
// messages.clear();
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// for (Message msg : messages) {
// sb.append(msg);
// sb.append(", ");
// }
// return sb.toString();
// }
//
// public List<Message> getMessages() {
// return this.messages;
// }
//
// public CheckMessage has(Predicate<Message> condition) {
// return new CheckMessage().has(condition);
// }
//
// public class CheckMessage {
// private List<Predicate<Message>> predicates = new ArrayList<>();
//
// public CheckMessage has(Predicate<Message> condition) {
// predicates.add(condition);
// return this;
// }
//
// public boolean check() {
// return messages.stream()
// .filter(this::matchAllPredicates)
// .count() > 0;
// }
//
// private boolean matchAllPredicates(final Message m) {
// return predicates.stream().filter(p -> p.test(m)).count() == predicates.size();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
| import org.junit.Test;
import org.nextrtc.signalingserver.BaseTest;
import org.nextrtc.signalingserver.MessageMatcher;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.beans.factory.annotation.Autowired;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when; | package org.nextrtc.signalingserver.domain;
public class PingTaskTest extends BaseTest {
@Autowired
private MessageSender sender;
@Autowired | // Path: src/test/java/org/nextrtc/signalingserver/BaseTest.java
// @ContextConfiguration(classes = {TestConfig.class})
// @RunWith(SpringJUnit4ClassRunner.class)
// public abstract class BaseTest {
//
// @Autowired
// private CreateConversation create;
//
// @Autowired
// private JoinConversation join;
//
// @Autowired
// private Members members;
//
// @Autowired
// private Conversations conversations;
//
// @Autowired
// private List<EventChecker> checkers;
//
// @Autowired
// private ApplicationContext context;
//
// @Before
// public void reset() {
//
// for (String id : conversations.getAllIds()) {
// conversations.remove(id);
// }
// for (String id : members.getAllIds()) {
// members.unregister(id);
// }
// for (EventChecker checker : checkers) {
// checker.reset();
// }
// }
//
// protected Connection mockConnection(String string) {
// return mockConnection(string, new MessageMatcher());
// }
//
// protected Connection mockConnection(String id, ArgumentMatcher<Message> match) {
// Connection s = mock(Connection.class);
// when(s.getId()).thenReturn(id);
// when(s.isOpen()).thenReturn(true);
// doNothing().when(s).sendObject(Mockito.argThat(match));
// return s;
// }
//
// protected Member mockMember(String string) {
// return context.getBean(Member.class, mockConnection(string), mock(ScheduledFuture.class));
// }
//
// protected Member mockMember(String string, ArgumentMatcher<Message> match) {
// return context.getBean(Member.class, mockConnection(string, match), mock(ScheduledFuture.class));
// }
//
// protected void createConversation(String conversationName, Member member) {
// members.register(member);
// create.execute(InternalMessage.create()//
// .from(member)//
// .content(conversationName)//
// .build());
// }
//
// protected void createBroadcastConversation(String conversationName, Member member) {
// members.register(member);
// create.execute(InternalMessage.create()//
// .from(member)//
// .content(conversationName)//
// .addCustom("type", "BROADCAST")//
// .build());
// }
//
// protected void joinConversation(String conversationName, Member member) {
// members.register(member);
// join.execute(InternalMessage.create()//
// .from(member)//
// .content(conversationName)//
// .build());
// }
//
// protected void assertMessage(MessageMatcher matcher, int number, String from, String to, String signal, String content) {
// assertThat(matcher.getMessage(number).getFrom(), is(from));
// assertThat(matcher.getMessage(number).getTo(), is(to));
// assertThat(matcher.getMessage(number).getSignal(), is(signal));
// assertThat(matcher.getMessage(number).getContent(), is(content));
// }
// }
//
// Path: src/test/java/org/nextrtc/signalingserver/MessageMatcher.java
// @Slf4j
// public class MessageMatcher extends ArgumentMatcher<Message> {
//
// private final List<String> filter;
// private List<Message> messages = Collections.synchronizedList(new ArrayList<>());
//
// public MessageMatcher() {
// this.filter = Arrays.asList("ping");
// }
//
// public MessageMatcher(String... filter) {
// this.filter = Arrays.asList(filter);
// }
//
// @Override
// public boolean matches(Object argument) {
// if (argument instanceof Message) {
// Message msg = (Message) argument;
// if (!filter.contains(msg.getSignal())) {
// messages.add(msg);
// }
// return true;
// }
// return false;
// }
//
// public Message getMessage() {
// return messages.get(0);
// }
//
// public Message getMessage(int number) {
// if (messages.size() <= number) {
// return null;
// }
// return messages.get(number);
// }
//
// public void reset() {
// messages.clear();
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// for (Message msg : messages) {
// sb.append(msg);
// sb.append(", ");
// }
// return sb.toString();
// }
//
// public List<Message> getMessages() {
// return this.messages;
// }
//
// public CheckMessage has(Predicate<Message> condition) {
// return new CheckMessage().has(condition);
// }
//
// public class CheckMessage {
// private List<Predicate<Message>> predicates = new ArrayList<>();
//
// public CheckMessage has(Predicate<Message> condition) {
// predicates.add(condition);
// return this;
// }
//
// public boolean check() {
// return messages.stream()
// .filter(this::matchAllPredicates)
// .count() > 0;
// }
//
// private boolean matchAllPredicates(final Message m) {
// return predicates.stream().filter(p -> p.test(m)).count() == predicates.size();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
// Path: src/test/java/org/nextrtc/signalingserver/domain/PingTaskTest.java
import org.junit.Test;
import org.nextrtc.signalingserver.BaseTest;
import org.nextrtc.signalingserver.MessageMatcher;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.beans.factory.annotation.Autowired;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
package org.nextrtc.signalingserver.domain;
public class PingTaskTest extends BaseTest {
@Autowired
private MessageSender sender;
@Autowired | private MemberRepository members; |
mslosarz/nextrtc-signaling-server | src/test/java/org/nextrtc/signalingserver/domain/PingTaskTest.java | // Path: src/test/java/org/nextrtc/signalingserver/BaseTest.java
// @ContextConfiguration(classes = {TestConfig.class})
// @RunWith(SpringJUnit4ClassRunner.class)
// public abstract class BaseTest {
//
// @Autowired
// private CreateConversation create;
//
// @Autowired
// private JoinConversation join;
//
// @Autowired
// private Members members;
//
// @Autowired
// private Conversations conversations;
//
// @Autowired
// private List<EventChecker> checkers;
//
// @Autowired
// private ApplicationContext context;
//
// @Before
// public void reset() {
//
// for (String id : conversations.getAllIds()) {
// conversations.remove(id);
// }
// for (String id : members.getAllIds()) {
// members.unregister(id);
// }
// for (EventChecker checker : checkers) {
// checker.reset();
// }
// }
//
// protected Connection mockConnection(String string) {
// return mockConnection(string, new MessageMatcher());
// }
//
// protected Connection mockConnection(String id, ArgumentMatcher<Message> match) {
// Connection s = mock(Connection.class);
// when(s.getId()).thenReturn(id);
// when(s.isOpen()).thenReturn(true);
// doNothing().when(s).sendObject(Mockito.argThat(match));
// return s;
// }
//
// protected Member mockMember(String string) {
// return context.getBean(Member.class, mockConnection(string), mock(ScheduledFuture.class));
// }
//
// protected Member mockMember(String string, ArgumentMatcher<Message> match) {
// return context.getBean(Member.class, mockConnection(string, match), mock(ScheduledFuture.class));
// }
//
// protected void createConversation(String conversationName, Member member) {
// members.register(member);
// create.execute(InternalMessage.create()//
// .from(member)//
// .content(conversationName)//
// .build());
// }
//
// protected void createBroadcastConversation(String conversationName, Member member) {
// members.register(member);
// create.execute(InternalMessage.create()//
// .from(member)//
// .content(conversationName)//
// .addCustom("type", "BROADCAST")//
// .build());
// }
//
// protected void joinConversation(String conversationName, Member member) {
// members.register(member);
// join.execute(InternalMessage.create()//
// .from(member)//
// .content(conversationName)//
// .build());
// }
//
// protected void assertMessage(MessageMatcher matcher, int number, String from, String to, String signal, String content) {
// assertThat(matcher.getMessage(number).getFrom(), is(from));
// assertThat(matcher.getMessage(number).getTo(), is(to));
// assertThat(matcher.getMessage(number).getSignal(), is(signal));
// assertThat(matcher.getMessage(number).getContent(), is(content));
// }
// }
//
// Path: src/test/java/org/nextrtc/signalingserver/MessageMatcher.java
// @Slf4j
// public class MessageMatcher extends ArgumentMatcher<Message> {
//
// private final List<String> filter;
// private List<Message> messages = Collections.synchronizedList(new ArrayList<>());
//
// public MessageMatcher() {
// this.filter = Arrays.asList("ping");
// }
//
// public MessageMatcher(String... filter) {
// this.filter = Arrays.asList(filter);
// }
//
// @Override
// public boolean matches(Object argument) {
// if (argument instanceof Message) {
// Message msg = (Message) argument;
// if (!filter.contains(msg.getSignal())) {
// messages.add(msg);
// }
// return true;
// }
// return false;
// }
//
// public Message getMessage() {
// return messages.get(0);
// }
//
// public Message getMessage(int number) {
// if (messages.size() <= number) {
// return null;
// }
// return messages.get(number);
// }
//
// public void reset() {
// messages.clear();
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// for (Message msg : messages) {
// sb.append(msg);
// sb.append(", ");
// }
// return sb.toString();
// }
//
// public List<Message> getMessages() {
// return this.messages;
// }
//
// public CheckMessage has(Predicate<Message> condition) {
// return new CheckMessage().has(condition);
// }
//
// public class CheckMessage {
// private List<Predicate<Message>> predicates = new ArrayList<>();
//
// public CheckMessage has(Predicate<Message> condition) {
// predicates.add(condition);
// return this;
// }
//
// public boolean check() {
// return messages.stream()
// .filter(this::matchAllPredicates)
// .count() > 0;
// }
//
// private boolean matchAllPredicates(final Message m) {
// return predicates.stream().filter(p -> p.test(m)).count() == predicates.size();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
| import org.junit.Test;
import org.nextrtc.signalingserver.BaseTest;
import org.nextrtc.signalingserver.MessageMatcher;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.beans.factory.annotation.Autowired;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when; | package org.nextrtc.signalingserver.domain;
public class PingTaskTest extends BaseTest {
@Autowired
private MessageSender sender;
@Autowired
private MemberRepository members;
@Test
public void shouldSendMessageWhenSessionIsOpen() {
// given | // Path: src/test/java/org/nextrtc/signalingserver/BaseTest.java
// @ContextConfiguration(classes = {TestConfig.class})
// @RunWith(SpringJUnit4ClassRunner.class)
// public abstract class BaseTest {
//
// @Autowired
// private CreateConversation create;
//
// @Autowired
// private JoinConversation join;
//
// @Autowired
// private Members members;
//
// @Autowired
// private Conversations conversations;
//
// @Autowired
// private List<EventChecker> checkers;
//
// @Autowired
// private ApplicationContext context;
//
// @Before
// public void reset() {
//
// for (String id : conversations.getAllIds()) {
// conversations.remove(id);
// }
// for (String id : members.getAllIds()) {
// members.unregister(id);
// }
// for (EventChecker checker : checkers) {
// checker.reset();
// }
// }
//
// protected Connection mockConnection(String string) {
// return mockConnection(string, new MessageMatcher());
// }
//
// protected Connection mockConnection(String id, ArgumentMatcher<Message> match) {
// Connection s = mock(Connection.class);
// when(s.getId()).thenReturn(id);
// when(s.isOpen()).thenReturn(true);
// doNothing().when(s).sendObject(Mockito.argThat(match));
// return s;
// }
//
// protected Member mockMember(String string) {
// return context.getBean(Member.class, mockConnection(string), mock(ScheduledFuture.class));
// }
//
// protected Member mockMember(String string, ArgumentMatcher<Message> match) {
// return context.getBean(Member.class, mockConnection(string, match), mock(ScheduledFuture.class));
// }
//
// protected void createConversation(String conversationName, Member member) {
// members.register(member);
// create.execute(InternalMessage.create()//
// .from(member)//
// .content(conversationName)//
// .build());
// }
//
// protected void createBroadcastConversation(String conversationName, Member member) {
// members.register(member);
// create.execute(InternalMessage.create()//
// .from(member)//
// .content(conversationName)//
// .addCustom("type", "BROADCAST")//
// .build());
// }
//
// protected void joinConversation(String conversationName, Member member) {
// members.register(member);
// join.execute(InternalMessage.create()//
// .from(member)//
// .content(conversationName)//
// .build());
// }
//
// protected void assertMessage(MessageMatcher matcher, int number, String from, String to, String signal, String content) {
// assertThat(matcher.getMessage(number).getFrom(), is(from));
// assertThat(matcher.getMessage(number).getTo(), is(to));
// assertThat(matcher.getMessage(number).getSignal(), is(signal));
// assertThat(matcher.getMessage(number).getContent(), is(content));
// }
// }
//
// Path: src/test/java/org/nextrtc/signalingserver/MessageMatcher.java
// @Slf4j
// public class MessageMatcher extends ArgumentMatcher<Message> {
//
// private final List<String> filter;
// private List<Message> messages = Collections.synchronizedList(new ArrayList<>());
//
// public MessageMatcher() {
// this.filter = Arrays.asList("ping");
// }
//
// public MessageMatcher(String... filter) {
// this.filter = Arrays.asList(filter);
// }
//
// @Override
// public boolean matches(Object argument) {
// if (argument instanceof Message) {
// Message msg = (Message) argument;
// if (!filter.contains(msg.getSignal())) {
// messages.add(msg);
// }
// return true;
// }
// return false;
// }
//
// public Message getMessage() {
// return messages.get(0);
// }
//
// public Message getMessage(int number) {
// if (messages.size() <= number) {
// return null;
// }
// return messages.get(number);
// }
//
// public void reset() {
// messages.clear();
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// for (Message msg : messages) {
// sb.append(msg);
// sb.append(", ");
// }
// return sb.toString();
// }
//
// public List<Message> getMessages() {
// return this.messages;
// }
//
// public CheckMessage has(Predicate<Message> condition) {
// return new CheckMessage().has(condition);
// }
//
// public class CheckMessage {
// private List<Predicate<Message>> predicates = new ArrayList<>();
//
// public CheckMessage has(Predicate<Message> condition) {
// predicates.add(condition);
// return this;
// }
//
// public boolean check() {
// return messages.stream()
// .filter(this::matchAllPredicates)
// .count() > 0;
// }
//
// private boolean matchAllPredicates(final Message m) {
// return predicates.stream().filter(p -> p.test(m)).count() == predicates.size();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
// Path: src/test/java/org/nextrtc/signalingserver/domain/PingTaskTest.java
import org.junit.Test;
import org.nextrtc.signalingserver.BaseTest;
import org.nextrtc.signalingserver.MessageMatcher;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.beans.factory.annotation.Autowired;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
package org.nextrtc.signalingserver.domain;
public class PingTaskTest extends BaseTest {
@Autowired
private MessageSender sender;
@Autowired
private MemberRepository members;
@Test
public void shouldSendMessageWhenSessionIsOpen() {
// given | MessageMatcher messages = new MessageMatcher(""); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/conversation/AbstractMeshConversation.java | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// 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();
// }
//
// }
| import com.google.common.collect.Sets;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Set; | package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public abstract class AbstractMeshConversation extends Conversation { | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// 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/conversation/AbstractMeshConversation.java
import com.google.common.collect.Sets;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Set;
package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public abstract class AbstractMeshConversation extends Conversation { | private ExchangeSignalsBetweenMembers exchange; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/conversation/AbstractMeshConversation.java | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// 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();
// }
//
// }
| import com.google.common.collect.Sets;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Set; | package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public abstract class AbstractMeshConversation extends Conversation {
private ExchangeSignalsBetweenMembers exchange;
private Set<Member> members = Sets.newConcurrentHashSet();
private Member creator;
@Override | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// 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/conversation/AbstractMeshConversation.java
import com.google.common.collect.Sets;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Set;
package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public abstract class AbstractMeshConversation extends Conversation {
private ExchangeSignalsBetweenMembers exchange;
private Set<Member> members = Sets.newConcurrentHashSet();
private Member creator;
@Override | public Set<NextRTCMember> getMembers() { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/conversation/AbstractMeshConversation.java | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// 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();
// }
//
// }
| import com.google.common.collect.Sets;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Set; | package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public abstract class AbstractMeshConversation extends Conversation {
private ExchangeSignalsBetweenMembers exchange;
private Set<Member> members = Sets.newConcurrentHashSet();
private Member creator;
@Override
public Set<NextRTCMember> getMembers() {
return Sets.newHashSet(members);
}
@Override
public Member getCreator() {
return creator;
}
protected Set<Member> members() {
return Sets.newHashSet(members);
}
public AbstractMeshConversation(String id) {
super(id);
}
public AbstractMeshConversation(String id, | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// 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/conversation/AbstractMeshConversation.java
import com.google.common.collect.Sets;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Set;
package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public abstract class AbstractMeshConversation extends Conversation {
private ExchangeSignalsBetweenMembers exchange;
private Set<Member> members = Sets.newConcurrentHashSet();
private Member creator;
@Override
public Set<NextRTCMember> getMembers() {
return Sets.newHashSet(members);
}
@Override
public Member getCreator() {
return creator;
}
protected Set<Member> members() {
return Sets.newHashSet(members);
}
public AbstractMeshConversation(String id) {
super(id);
}
public AbstractMeshConversation(String id, | LeftConversation left, |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java | // Path: src/main/java/org/nextrtc/signalingserver/Names.java
// public interface Names {
// String EVENT_BUS = "nextRTCEventBus";
// String EVENT_DISPATCHER = "nextRTCEventDispatcher";
//
// String SCHEDULER_SIZE = "${nextrtc.scheduler_size:10}";
// String SCHEDULER_NAME = "nextRTCPingScheduler";
// String SCHEDULED_PERIOD = "${nextrtc.ping_period:3}";
// String MAX_CONNECTION_SETUP_TIME = "${nextrtc.max_connection_setup_time:30}";
// String JOIN_ONLY_TO_EXISTING = "${nextrtc.join_only_to_existing:false}";
//
// String DEFAULT_CONVERSATION_TYPE = "${nextrtc.default_conversation_type:MESH}";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
| import com.google.common.eventbus.EventBus;
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.Names;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service; | package org.nextrtc.signalingserver.api;
@Slf4j
@Service(Names.EVENT_BUS)
@Scope("singleton")
public class NextRTCEventBus {
private EventBus eventBus;
public NextRTCEventBus() {
this.eventBus = new EventBus();
}
| // Path: src/main/java/org/nextrtc/signalingserver/Names.java
// public interface Names {
// String EVENT_BUS = "nextRTCEventBus";
// String EVENT_DISPATCHER = "nextRTCEventDispatcher";
//
// String SCHEDULER_SIZE = "${nextrtc.scheduler_size:10}";
// String SCHEDULER_NAME = "nextRTCPingScheduler";
// String SCHEDULED_PERIOD = "${nextrtc.ping_period:3}";
// String MAX_CONNECTION_SETUP_TIME = "${nextrtc.max_connection_setup_time:30}";
// String JOIN_ONLY_TO_EXISTING = "${nextrtc.join_only_to_existing:false}";
//
// String DEFAULT_CONVERSATION_TYPE = "${nextrtc.default_conversation_type:MESH}";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
import com.google.common.eventbus.EventBus;
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.Names;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
package org.nextrtc.signalingserver.api;
@Slf4j
@Service(Names.EVENT_BUS)
@Scope("singleton")
public class NextRTCEventBus {
private EventBus eventBus;
public NextRTCEventBus() {
this.eventBus = new EventBus();
}
| public void post(NextRTCEvent event) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/RTCConnections.java | // Path: src/main/java/org/nextrtc/signalingserver/cases/connection/ConnectionContext.java
// @Getter
// @Component
// @Scope("prototype")
// public class ConnectionContext {
//
// private ConnectionState state = ConnectionState.NOT_INITIALIZED;
// private ZonedDateTime lastUpdated = ZonedDateTime.now();
//
// private NextRTCProperties properties;
// private NextRTCEventBus bus;
// private MessageSender sender;
//
// private Member master;
// private Member slave;
// private List<InternalMessage> candidates = new ArrayList<>();
//
// public ConnectionContext(Member master, Member slave) {
// this.master = master;
// this.slave = slave;
// }
//
//
// public void process(InternalMessage message) {
// if(message.getSignal() == Signal.CANDIDATE && !is(message, ConnectionState.EXCHANGE_CANDIDATES)){
// recordCandidate(message);
// }
// if (is(message, ConnectionState.OFFER_REQUESTED)) {
// setState(ConnectionState.ANSWER_REQUESTED);
// answerRequest(message);
// } else if (is(message, ConnectionState.ANSWER_REQUESTED)) {
// setState(ConnectionState.EXCHANGE_CANDIDATES);
// finalize(message);
// sendCollectedCandidates();
// } else if (is(message, ConnectionState.EXCHANGE_CANDIDATES)) {
// exchangeCandidates(message);
// }
// }
//
// private void sendCollectedCandidates() {
// candidates.forEach(this::exchangeCandidates);
// candidates.clear();
// }
//
// private void recordCandidate(InternalMessage message) {
// candidates.add(message);
// }
//
//
// private void exchangeCandidates(InternalMessage message) {
// sender.send(message.copy()
// .signal(Signal.CANDIDATE)
// .build()
// );
// }
//
//
// private void finalize(InternalMessage message) {
// sender.send(message.copy()//
// .from(slave)//
// .to(master)//
// .signal(Signal.FINALIZE)//
// .build());
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_CREATED.occurFor(slave.getConnection()));
// bus.post(NextRTCEvents.MEDIA_STREAMING.occurFor(master.getConnection()));
// bus.post(NextRTCEvents.MEDIA_STREAMING.occurFor(slave.getConnection()));
// }
//
//
// private void answerRequest(InternalMessage message) {
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_CREATED.occurFor(master.getConnection()));
// sender.send(message.copy()//
// .from(master)//
// .to(slave)//
// .signal(Signal.ANSWER_REQUEST)//
// .build()//
// );
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_REQUESTED.occurFor(slave.getConnection()));
// }
//
// private boolean is(InternalMessage message, ConnectionState state) {
// return state.equals(this.state) && state.isValid(message);
// }
//
// public void begin() {
// setState(ConnectionState.OFFER_REQUESTED);
// sender.send(InternalMessage.create()//
// .from(slave)//
// .to(master)//
// .signal(Signal.OFFER_REQUEST)
// .build()//
// );
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_REQUESTED.occurFor(master.getConnection()));
// }
//
// public boolean isCurrent() {
// return lastUpdated.plusSeconds(properties.getMaxConnectionSetupTime()).isAfter(ZonedDateTime.now());
// }
//
// private void setState(ConnectionState state) {
// this.state = state;
// lastUpdated = ZonedDateTime.now();
// }
//
// @Inject
// public void setBus(NextRTCEventBus bus) {
// this.bus = bus;
// }
//
// @Inject
// public void setProperties(NextRTCProperties properties) {
// this.properties = properties;
// }
//
// @Inject
// public void setSender(MessageSender sender) {
// this.sender = sender;
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
| import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import org.nextrtc.signalingserver.cases.connection.ConnectionContext;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.io.Closeable;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; | package org.nextrtc.signalingserver.domain;
@Component
@Scope("singleton")
public class RTCConnections implements Closeable{ | // Path: src/main/java/org/nextrtc/signalingserver/cases/connection/ConnectionContext.java
// @Getter
// @Component
// @Scope("prototype")
// public class ConnectionContext {
//
// private ConnectionState state = ConnectionState.NOT_INITIALIZED;
// private ZonedDateTime lastUpdated = ZonedDateTime.now();
//
// private NextRTCProperties properties;
// private NextRTCEventBus bus;
// private MessageSender sender;
//
// private Member master;
// private Member slave;
// private List<InternalMessage> candidates = new ArrayList<>();
//
// public ConnectionContext(Member master, Member slave) {
// this.master = master;
// this.slave = slave;
// }
//
//
// public void process(InternalMessage message) {
// if(message.getSignal() == Signal.CANDIDATE && !is(message, ConnectionState.EXCHANGE_CANDIDATES)){
// recordCandidate(message);
// }
// if (is(message, ConnectionState.OFFER_REQUESTED)) {
// setState(ConnectionState.ANSWER_REQUESTED);
// answerRequest(message);
// } else if (is(message, ConnectionState.ANSWER_REQUESTED)) {
// setState(ConnectionState.EXCHANGE_CANDIDATES);
// finalize(message);
// sendCollectedCandidates();
// } else if (is(message, ConnectionState.EXCHANGE_CANDIDATES)) {
// exchangeCandidates(message);
// }
// }
//
// private void sendCollectedCandidates() {
// candidates.forEach(this::exchangeCandidates);
// candidates.clear();
// }
//
// private void recordCandidate(InternalMessage message) {
// candidates.add(message);
// }
//
//
// private void exchangeCandidates(InternalMessage message) {
// sender.send(message.copy()
// .signal(Signal.CANDIDATE)
// .build()
// );
// }
//
//
// private void finalize(InternalMessage message) {
// sender.send(message.copy()//
// .from(slave)//
// .to(master)//
// .signal(Signal.FINALIZE)//
// .build());
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_CREATED.occurFor(slave.getConnection()));
// bus.post(NextRTCEvents.MEDIA_STREAMING.occurFor(master.getConnection()));
// bus.post(NextRTCEvents.MEDIA_STREAMING.occurFor(slave.getConnection()));
// }
//
//
// private void answerRequest(InternalMessage message) {
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_CREATED.occurFor(master.getConnection()));
// sender.send(message.copy()//
// .from(master)//
// .to(slave)//
// .signal(Signal.ANSWER_REQUEST)//
// .build()//
// );
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_REQUESTED.occurFor(slave.getConnection()));
// }
//
// private boolean is(InternalMessage message, ConnectionState state) {
// return state.equals(this.state) && state.isValid(message);
// }
//
// public void begin() {
// setState(ConnectionState.OFFER_REQUESTED);
// sender.send(InternalMessage.create()//
// .from(slave)//
// .to(master)//
// .signal(Signal.OFFER_REQUEST)
// .build()//
// );
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_REQUESTED.occurFor(master.getConnection()));
// }
//
// public boolean isCurrent() {
// return lastUpdated.plusSeconds(properties.getMaxConnectionSetupTime()).isAfter(ZonedDateTime.now());
// }
//
// private void setState(ConnectionState state) {
// this.state = state;
// lastUpdated = ZonedDateTime.now();
// }
//
// @Inject
// public void setBus(NextRTCEventBus bus) {
// this.bus = bus;
// }
//
// @Inject
// public void setProperties(NextRTCProperties properties) {
// this.properties = properties;
// }
//
// @Inject
// public void setSender(MessageSender sender) {
// this.sender = sender;
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
// Path: src/main/java/org/nextrtc/signalingserver/domain/RTCConnections.java
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import org.nextrtc.signalingserver.cases.connection.ConnectionContext;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.io.Closeable;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
package org.nextrtc.signalingserver.domain;
@Component
@Scope("singleton")
public class RTCConnections implements Closeable{ | private static Table<Member, Member, ConnectionContext> connections = HashBasedTable.create(); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/RTCConnections.java | // Path: src/main/java/org/nextrtc/signalingserver/cases/connection/ConnectionContext.java
// @Getter
// @Component
// @Scope("prototype")
// public class ConnectionContext {
//
// private ConnectionState state = ConnectionState.NOT_INITIALIZED;
// private ZonedDateTime lastUpdated = ZonedDateTime.now();
//
// private NextRTCProperties properties;
// private NextRTCEventBus bus;
// private MessageSender sender;
//
// private Member master;
// private Member slave;
// private List<InternalMessage> candidates = new ArrayList<>();
//
// public ConnectionContext(Member master, Member slave) {
// this.master = master;
// this.slave = slave;
// }
//
//
// public void process(InternalMessage message) {
// if(message.getSignal() == Signal.CANDIDATE && !is(message, ConnectionState.EXCHANGE_CANDIDATES)){
// recordCandidate(message);
// }
// if (is(message, ConnectionState.OFFER_REQUESTED)) {
// setState(ConnectionState.ANSWER_REQUESTED);
// answerRequest(message);
// } else if (is(message, ConnectionState.ANSWER_REQUESTED)) {
// setState(ConnectionState.EXCHANGE_CANDIDATES);
// finalize(message);
// sendCollectedCandidates();
// } else if (is(message, ConnectionState.EXCHANGE_CANDIDATES)) {
// exchangeCandidates(message);
// }
// }
//
// private void sendCollectedCandidates() {
// candidates.forEach(this::exchangeCandidates);
// candidates.clear();
// }
//
// private void recordCandidate(InternalMessage message) {
// candidates.add(message);
// }
//
//
// private void exchangeCandidates(InternalMessage message) {
// sender.send(message.copy()
// .signal(Signal.CANDIDATE)
// .build()
// );
// }
//
//
// private void finalize(InternalMessage message) {
// sender.send(message.copy()//
// .from(slave)//
// .to(master)//
// .signal(Signal.FINALIZE)//
// .build());
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_CREATED.occurFor(slave.getConnection()));
// bus.post(NextRTCEvents.MEDIA_STREAMING.occurFor(master.getConnection()));
// bus.post(NextRTCEvents.MEDIA_STREAMING.occurFor(slave.getConnection()));
// }
//
//
// private void answerRequest(InternalMessage message) {
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_CREATED.occurFor(master.getConnection()));
// sender.send(message.copy()//
// .from(master)//
// .to(slave)//
// .signal(Signal.ANSWER_REQUEST)//
// .build()//
// );
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_REQUESTED.occurFor(slave.getConnection()));
// }
//
// private boolean is(InternalMessage message, ConnectionState state) {
// return state.equals(this.state) && state.isValid(message);
// }
//
// public void begin() {
// setState(ConnectionState.OFFER_REQUESTED);
// sender.send(InternalMessage.create()//
// .from(slave)//
// .to(master)//
// .signal(Signal.OFFER_REQUEST)
// .build()//
// );
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_REQUESTED.occurFor(master.getConnection()));
// }
//
// public boolean isCurrent() {
// return lastUpdated.plusSeconds(properties.getMaxConnectionSetupTime()).isAfter(ZonedDateTime.now());
// }
//
// private void setState(ConnectionState state) {
// this.state = state;
// lastUpdated = ZonedDateTime.now();
// }
//
// @Inject
// public void setBus(NextRTCEventBus bus) {
// this.bus = bus;
// }
//
// @Inject
// public void setProperties(NextRTCProperties properties) {
// this.properties = properties;
// }
//
// @Inject
// public void setSender(MessageSender sender) {
// this.sender = sender;
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
| import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import org.nextrtc.signalingserver.cases.connection.ConnectionContext;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.io.Closeable;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; | package org.nextrtc.signalingserver.domain;
@Component
@Scope("singleton")
public class RTCConnections implements Closeable{
private static Table<Member, Member, ConnectionContext> connections = HashBasedTable.create();
private ScheduledExecutorService scheduler; | // Path: src/main/java/org/nextrtc/signalingserver/cases/connection/ConnectionContext.java
// @Getter
// @Component
// @Scope("prototype")
// public class ConnectionContext {
//
// private ConnectionState state = ConnectionState.NOT_INITIALIZED;
// private ZonedDateTime lastUpdated = ZonedDateTime.now();
//
// private NextRTCProperties properties;
// private NextRTCEventBus bus;
// private MessageSender sender;
//
// private Member master;
// private Member slave;
// private List<InternalMessage> candidates = new ArrayList<>();
//
// public ConnectionContext(Member master, Member slave) {
// this.master = master;
// this.slave = slave;
// }
//
//
// public void process(InternalMessage message) {
// if(message.getSignal() == Signal.CANDIDATE && !is(message, ConnectionState.EXCHANGE_CANDIDATES)){
// recordCandidate(message);
// }
// if (is(message, ConnectionState.OFFER_REQUESTED)) {
// setState(ConnectionState.ANSWER_REQUESTED);
// answerRequest(message);
// } else if (is(message, ConnectionState.ANSWER_REQUESTED)) {
// setState(ConnectionState.EXCHANGE_CANDIDATES);
// finalize(message);
// sendCollectedCandidates();
// } else if (is(message, ConnectionState.EXCHANGE_CANDIDATES)) {
// exchangeCandidates(message);
// }
// }
//
// private void sendCollectedCandidates() {
// candidates.forEach(this::exchangeCandidates);
// candidates.clear();
// }
//
// private void recordCandidate(InternalMessage message) {
// candidates.add(message);
// }
//
//
// private void exchangeCandidates(InternalMessage message) {
// sender.send(message.copy()
// .signal(Signal.CANDIDATE)
// .build()
// );
// }
//
//
// private void finalize(InternalMessage message) {
// sender.send(message.copy()//
// .from(slave)//
// .to(master)//
// .signal(Signal.FINALIZE)//
// .build());
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_CREATED.occurFor(slave.getConnection()));
// bus.post(NextRTCEvents.MEDIA_STREAMING.occurFor(master.getConnection()));
// bus.post(NextRTCEvents.MEDIA_STREAMING.occurFor(slave.getConnection()));
// }
//
//
// private void answerRequest(InternalMessage message) {
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_CREATED.occurFor(master.getConnection()));
// sender.send(message.copy()//
// .from(master)//
// .to(slave)//
// .signal(Signal.ANSWER_REQUEST)//
// .build()//
// );
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_REQUESTED.occurFor(slave.getConnection()));
// }
//
// private boolean is(InternalMessage message, ConnectionState state) {
// return state.equals(this.state) && state.isValid(message);
// }
//
// public void begin() {
// setState(ConnectionState.OFFER_REQUESTED);
// sender.send(InternalMessage.create()//
// .from(slave)//
// .to(master)//
// .signal(Signal.OFFER_REQUEST)
// .build()//
// );
// bus.post(NextRTCEvents.MEDIA_LOCAL_STREAM_REQUESTED.occurFor(master.getConnection()));
// }
//
// public boolean isCurrent() {
// return lastUpdated.plusSeconds(properties.getMaxConnectionSetupTime()).isAfter(ZonedDateTime.now());
// }
//
// private void setState(ConnectionState state) {
// this.state = state;
// lastUpdated = ZonedDateTime.now();
// }
//
// @Inject
// public void setBus(NextRTCEventBus bus) {
// this.bus = bus;
// }
//
// @Inject
// public void setProperties(NextRTCProperties properties) {
// this.properties = properties;
// }
//
// @Inject
// public void setSender(MessageSender sender) {
// this.sender = sender;
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
// Path: src/main/java/org/nextrtc/signalingserver/domain/RTCConnections.java
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import org.nextrtc.signalingserver.cases.connection.ConnectionContext;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.io.Closeable;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
package org.nextrtc.signalingserver.domain;
@Component
@Scope("singleton")
public class RTCConnections implements Closeable{
private static Table<Member, Member, ConnectionContext> connections = HashBasedTable.create();
private ScheduledExecutorService scheduler; | private NextRTCProperties properties; |
mslosarz/nextrtc-signaling-server | src/test/java/org/nextrtc/signalingserver/performance/Peer.java | // Path: src/main/java/org/nextrtc/signalingserver/domain/Message.java
// @Getter
// @Builder(builderMethodName = "create")
// @AllArgsConstructor(access = AccessLevel.PRIVATE)
// public class Message {
// /**
// * Use Message.create(...) instead of new Message()
// */
// @Deprecated
// Message() {
// }
//
// @Expose
// private String from = EMPTY;
//
// @Expose
// private String to = EMPTY;
//
// @Expose
// private String signal = EMPTY;
//
// @Expose
// private String content = EMPTY;
//
// @Expose
// private Map<String, String> custom = Maps.newHashMap();
//
// @Override
// public String toString() {
// return String.format("(%s -> %s)[%s]: %s |%s", from, to, signal, content, custom);
// }
// }
| import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import lombok.Getter;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
import org.nextrtc.signalingserver.domain.Message;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static java.lang.String.format;
import static java.util.Collections.synchronizedList;
import static org.awaitility.Awaitility.await;
import static org.nextrtc.signalingserver.domain.Message.create; | package org.nextrtc.signalingserver.performance;
@WebSocket
@Getter
public class Peer {
private final static ExecutorService service = Executors.newCachedThreadPool();
private final Gson gson = new GsonBuilder().create();
private Session session;
private String name;
private String joinedTo; | // Path: src/main/java/org/nextrtc/signalingserver/domain/Message.java
// @Getter
// @Builder(builderMethodName = "create")
// @AllArgsConstructor(access = AccessLevel.PRIVATE)
// public class Message {
// /**
// * Use Message.create(...) instead of new Message()
// */
// @Deprecated
// Message() {
// }
//
// @Expose
// private String from = EMPTY;
//
// @Expose
// private String to = EMPTY;
//
// @Expose
// private String signal = EMPTY;
//
// @Expose
// private String content = EMPTY;
//
// @Expose
// private Map<String, String> custom = Maps.newHashMap();
//
// @Override
// public String toString() {
// return String.format("(%s -> %s)[%s]: %s |%s", from, to, signal, content, custom);
// }
// }
// Path: src/test/java/org/nextrtc/signalingserver/performance/Peer.java
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import lombok.Getter;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
import org.nextrtc.signalingserver.domain.Message;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static java.lang.String.format;
import static java.util.Collections.synchronizedList;
import static org.awaitility.Awaitility.await;
import static org.nextrtc.signalingserver.domain.Message.create;
package org.nextrtc.signalingserver.performance;
@WebSocket
@Getter
public class Peer {
private final static ExecutorService service = Executors.newCachedThreadPool();
private final Gson gson = new GsonBuilder().create();
private Session session;
private String name;
private String joinedTo; | private List<Message> offerRequests = synchronizedList(new ArrayList<>()); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/eventbus/EventDispatcher.java | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
| import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent; | package org.nextrtc.signalingserver.eventbus;
public interface EventDispatcher {
@Subscribe
@AllowConcurrentEvents | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/eventbus/EventDispatcher.java
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
package org.nextrtc.signalingserver.eventbus;
public interface EventDispatcher {
@Subscribe
@AllowConcurrentEvents | void handle(NextRTCEvent event); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/exception/SignalingException.java
// public class SignalingException extends RuntimeException {
//
// private static final long serialVersionUID = 4171073365651049929L;
//
// private String customMessage;
//
// public SignalingException(Exceptions exception) {
// super(exception.name());
// }
//
// public SignalingException(Exceptions exception, Throwable t) {
// super(exception.name(), t);
// }
//
// public SignalingException(Exceptions exception, String customMessage) {
// super(exception.name());
// this.customMessage = customMessage;
// }
//
//
// public String getCustomMessage() {
// return StringUtils.defaultString(customMessage);
// }
//
// public void throwException() {
// throw this;
// }
//
// @Override
// public String toString() {
// return format("Signaling Exception %s [%s]", getMessage(), getCustomMessage());
// }
//
// }
| import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.exception.SignalingException;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Optional; | package org.nextrtc.signalingserver.api.dto;
public interface NextRTCEvent {
NextRTCEvents type();
ZonedDateTime published();
Optional<NextRTCMember> from();
Optional<NextRTCMember> to();
Optional<NextRTCConversation> conversation();
| // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/exception/SignalingException.java
// public class SignalingException extends RuntimeException {
//
// private static final long serialVersionUID = 4171073365651049929L;
//
// private String customMessage;
//
// public SignalingException(Exceptions exception) {
// super(exception.name());
// }
//
// public SignalingException(Exceptions exception, Throwable t) {
// super(exception.name(), t);
// }
//
// public SignalingException(Exceptions exception, String customMessage) {
// super(exception.name());
// this.customMessage = customMessage;
// }
//
//
// public String getCustomMessage() {
// return StringUtils.defaultString(customMessage);
// }
//
// public void throwException() {
// throw this;
// }
//
// @Override
// public String toString() {
// return format("Signaling Exception %s [%s]", getMessage(), getCustomMessage());
// }
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.exception.SignalingException;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Optional;
package org.nextrtc.signalingserver.api.dto;
public interface NextRTCEvent {
NextRTCEvents type();
ZonedDateTime published();
Optional<NextRTCMember> from();
Optional<NextRTCMember> to();
Optional<NextRTCConversation> conversation();
| Optional<SignalingException> exception(); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/eventbus/ManualEventDispatcher.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
| import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.annotation.NextRTCEventListener;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List; | package org.nextrtc.signalingserver.eventbus;
@NextRTCEventListener
public class ManualEventDispatcher extends AbstractEventDispatcher {
private final List<Object> events = new ArrayList<>();
| // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/eventbus/ManualEventDispatcher.java
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.annotation.NextRTCEventListener;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
package org.nextrtc.signalingserver.eventbus;
@NextRTCEventListener
public class ManualEventDispatcher extends AbstractEventDispatcher {
private final List<Object> events = new ArrayList<>();
| private final NextRTCEventBus eventBus; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/eventbus/ManualEventDispatcher.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
| import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.annotation.NextRTCEventListener;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List; | package org.nextrtc.signalingserver.eventbus;
@NextRTCEventListener
public class ManualEventDispatcher extends AbstractEventDispatcher {
private final List<Object> events = new ArrayList<>();
private final NextRTCEventBus eventBus;
public ManualEventDispatcher(NextRTCEventBus eventBus) {
this.eventBus = eventBus;
}
protected Collection<Object> getNextRTCEventListeners() {
return events;
}
@Override | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/eventbus/ManualEventDispatcher.java
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.annotation.NextRTCEventListener;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
package org.nextrtc.signalingserver.eventbus;
@NextRTCEventListener
public class ManualEventDispatcher extends AbstractEventDispatcher {
private final List<Object> events = new ArrayList<>();
private final NextRTCEventBus eventBus;
public ManualEventDispatcher(NextRTCEventBus eventBus) {
this.eventBus = eventBus;
}
protected Collection<Object> getNextRTCEventListeners() {
return events;
}
@Override | protected NextRTCEvents[] getSupportedEvents(Object listener) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/eventbus/ManualEventDispatcher.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
| import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.annotation.NextRTCEventListener;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List; | package org.nextrtc.signalingserver.eventbus;
@NextRTCEventListener
public class ManualEventDispatcher extends AbstractEventDispatcher {
private final List<Object> events = new ArrayList<>();
private final NextRTCEventBus eventBus;
public ManualEventDispatcher(NextRTCEventBus eventBus) {
this.eventBus = eventBus;
}
protected Collection<Object> getNextRTCEventListeners() {
return events;
}
@Override
protected NextRTCEvents[] getSupportedEvents(Object listener) {
return (NextRTCEvents[]) getValue(listener.getClass().getAnnotation(NextRTCEventListener.class));
}
public static Object getValue(Annotation annotation) {
if (annotation != null) {
try {
Method method = annotation.annotationType().getDeclaredMethod("value", new Class[0]);
method.setAccessible(true);
return method.invoke(annotation, new Object[0]);
} catch (Exception var3) {
return null;
}
} else {
return null;
}
}
| // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/eventbus/ManualEventDispatcher.java
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.annotation.NextRTCEventListener;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
package org.nextrtc.signalingserver.eventbus;
@NextRTCEventListener
public class ManualEventDispatcher extends AbstractEventDispatcher {
private final List<Object> events = new ArrayList<>();
private final NextRTCEventBus eventBus;
public ManualEventDispatcher(NextRTCEventBus eventBus) {
this.eventBus = eventBus;
}
protected Collection<Object> getNextRTCEventListeners() {
return events;
}
@Override
protected NextRTCEvents[] getSupportedEvents(Object listener) {
return (NextRTCEvents[]) getValue(listener.getClass().getAnnotation(NextRTCEventListener.class));
}
public static Object getValue(Annotation annotation) {
if (annotation != null) {
try {
Method method = annotation.annotationType().getDeclaredMethod("value", new Class[0]);
method.setAccessible(true);
return method.invoke(annotation, new Object[0]);
} catch (Exception var3) {
return null;
}
} else {
return null;
}
}
| public void addListener(NextRTCHandler handler) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/repository/Members.java | // Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
| import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.domain.Member;
import org.springframework.stereotype.Repository;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Optional; | package org.nextrtc.signalingserver.repository;
@Slf4j
@Repository
public class Members implements MemberRepository {
| // Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/repository/Members.java
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.domain.Member;
import org.springframework.stereotype.Repository;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
package org.nextrtc.signalingserver.repository;
@Slf4j
@Repository
public class Members implements MemberRepository {
| private Map<String, Member> members = Maps.newConcurrentMap(); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/cases/TextMessage.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
| import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import static org.nextrtc.signalingserver.api.NextRTCEvents.TEXT; | package org.nextrtc.signalingserver.cases;
@Component(Signals.TEXT_HANDLER)
public class TextMessage implements SignalHandler {
| // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/cases/TextMessage.java
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.*;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import static org.nextrtc.signalingserver.api.NextRTCEvents.TEXT;
package org.nextrtc.signalingserver.cases;
@Component(Signals.TEXT_HANDLER)
public class TextMessage implements SignalHandler {
| private NextRTCEventBus eventBus; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/factory/SpringMemberFactory.java | // Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
| import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.util.concurrent.ScheduledFuture; | package org.nextrtc.signalingserver.factory;
@Component
public class SpringMemberFactory implements MemberFactory {
@Autowired
private ApplicationContext context;
@Override | // Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/factory/SpringMemberFactory.java
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.util.concurrent.ScheduledFuture;
package org.nextrtc.signalingserver.factory;
@Component
public class SpringMemberFactory implements MemberFactory {
@Autowired
private ApplicationContext context;
@Override | public Member create(Connection connection, ScheduledFuture<?> ping) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/factory/SpringMemberFactory.java | // Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
| import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.util.concurrent.ScheduledFuture; | package org.nextrtc.signalingserver.factory;
@Component
public class SpringMemberFactory implements MemberFactory {
@Autowired
private ApplicationContext context;
@Override | // Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/factory/SpringMemberFactory.java
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.util.concurrent.ScheduledFuture;
package org.nextrtc.signalingserver.factory;
@Component
public class SpringMemberFactory implements MemberFactory {
@Autowired
private ApplicationContext context;
@Override | public Member create(Connection connection, ScheduledFuture<?> ping) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/CloseableContext.java | // Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
| import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.ScheduledExecutorService; | package org.nextrtc.signalingserver.domain;
@Slf4j
@Component
class CloseableContext implements Closeable {
private final ScheduledExecutorService scheduler;
private final RTCConnections connections; | // Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/domain/CloseableContext.java
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.ScheduledExecutorService;
package org.nextrtc.signalingserver.domain;
@Slf4j
@Component
class CloseableContext implements Closeable {
private final ScheduledExecutorService scheduler;
private final RTCConnections connections; | private final MemberRepository members; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/CloseableContext.java | // Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
| import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.ScheduledExecutorService; | package org.nextrtc.signalingserver.domain;
@Slf4j
@Component
class CloseableContext implements Closeable {
private final ScheduledExecutorService scheduler;
private final RTCConnections connections;
private final MemberRepository members; | // Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/domain/CloseableContext.java
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.ScheduledExecutorService;
package org.nextrtc.signalingserver.domain;
@Slf4j
@Component
class CloseableContext implements Closeable {
private final ScheduledExecutorService scheduler;
private final RTCConnections connections;
private final MemberRepository members; | private final ConversationRepository conversations; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCRepositories.java | // Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Conversations.java
// @Slf4j
// @Repository
// public class Conversations implements ConversationRepository {
//
// private Map<String, Conversation> conversations = Maps.newConcurrentMap();
//
// @Override
// public Optional<Conversation> findBy(String id) {
// if (isEmpty(id)) {
// return Optional.empty();
// }
// return Optional.ofNullable(conversations.get(id));
// }
//
// @Override
// public Optional<Conversation> findBy(Member from) {
// return conversations.values().stream().filter(conversation -> conversation.has(from)).findAny();
// }
//
// @Override
// public Conversation remove(String id) {
// return conversations.remove(id);
// }
//
// @Override
// public Conversation save(Conversation conversation) {
// if (conversations.containsKey(conversation.getId())) {
// throw CONVERSATION_NAME_OCCUPIED.exception();
// }
// conversations.put(conversation.getId(), conversation);
// return conversation;
// }
//
// @Override
// public Collection<String> getAllIds() {
// return conversations.keySet();
// }
//
// @Override
// public void close() throws IOException {
// for (Conversation conversation : conversations.values()) {
// try {
// conversation.close();
// } catch (Exception e) {
// log.error("Problem during closing conversation " + conversation.getId(), e);
// }
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Members.java
// @Slf4j
// @Repository
// public class Members implements MemberRepository {
//
// private Map<String, Member> members = Maps.newConcurrentMap();
//
// @Override
// public Collection<String> getAllIds() {
// return members.keySet();
// }
//
// @Override
// public Optional<Member> findBy(String id) {
// if (id == null) {
// return Optional.empty();
// }
// return Optional.ofNullable(members.get(id));
// }
//
// @Override
// public Member register(Member member) {
// if (!members.containsKey(member.getId())) {
// members.put(member.getId(), member);
// }
// return member;
// }
//
// @Override
// public void unregister(String id) {
// findBy(id).ifPresent(Member::markLeft);
// Member removed = members.remove(id);
// if (removed != null) {
// removed.getConversation().ifPresent(c -> c.left(removed));
// }
// }
//
// @Override
// public void close() throws IOException {
// for (Member member : members.values()) {
// try {
// member.getConnection().close();
// } catch (Exception e) {
// log.error("Problem during closing member connection " + member.getId(), e);
// }
// }
// members.clear();
// }
// }
| import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import org.nextrtc.signalingserver.repository.Conversations;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.nextrtc.signalingserver.repository.Members;
import javax.inject.Singleton; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCRepositories {
@Provides
@Singleton | // Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Conversations.java
// @Slf4j
// @Repository
// public class Conversations implements ConversationRepository {
//
// private Map<String, Conversation> conversations = Maps.newConcurrentMap();
//
// @Override
// public Optional<Conversation> findBy(String id) {
// if (isEmpty(id)) {
// return Optional.empty();
// }
// return Optional.ofNullable(conversations.get(id));
// }
//
// @Override
// public Optional<Conversation> findBy(Member from) {
// return conversations.values().stream().filter(conversation -> conversation.has(from)).findAny();
// }
//
// @Override
// public Conversation remove(String id) {
// return conversations.remove(id);
// }
//
// @Override
// public Conversation save(Conversation conversation) {
// if (conversations.containsKey(conversation.getId())) {
// throw CONVERSATION_NAME_OCCUPIED.exception();
// }
// conversations.put(conversation.getId(), conversation);
// return conversation;
// }
//
// @Override
// public Collection<String> getAllIds() {
// return conversations.keySet();
// }
//
// @Override
// public void close() throws IOException {
// for (Conversation conversation : conversations.values()) {
// try {
// conversation.close();
// } catch (Exception e) {
// log.error("Problem during closing conversation " + conversation.getId(), e);
// }
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Members.java
// @Slf4j
// @Repository
// public class Members implements MemberRepository {
//
// private Map<String, Member> members = Maps.newConcurrentMap();
//
// @Override
// public Collection<String> getAllIds() {
// return members.keySet();
// }
//
// @Override
// public Optional<Member> findBy(String id) {
// if (id == null) {
// return Optional.empty();
// }
// return Optional.ofNullable(members.get(id));
// }
//
// @Override
// public Member register(Member member) {
// if (!members.containsKey(member.getId())) {
// members.put(member.getId(), member);
// }
// return member;
// }
//
// @Override
// public void unregister(String id) {
// findBy(id).ifPresent(Member::markLeft);
// Member removed = members.remove(id);
// if (removed != null) {
// removed.getConversation().ifPresent(c -> c.left(removed));
// }
// }
//
// @Override
// public void close() throws IOException {
// for (Member member : members.values()) {
// try {
// member.getConnection().close();
// } catch (Exception e) {
// log.error("Problem during closing member connection " + member.getId(), e);
// }
// }
// members.clear();
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCRepositories.java
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import org.nextrtc.signalingserver.repository.Conversations;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.nextrtc.signalingserver.repository.Members;
import javax.inject.Singleton;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCRepositories {
@Provides
@Singleton | static Members Members() { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCRepositories.java | // Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Conversations.java
// @Slf4j
// @Repository
// public class Conversations implements ConversationRepository {
//
// private Map<String, Conversation> conversations = Maps.newConcurrentMap();
//
// @Override
// public Optional<Conversation> findBy(String id) {
// if (isEmpty(id)) {
// return Optional.empty();
// }
// return Optional.ofNullable(conversations.get(id));
// }
//
// @Override
// public Optional<Conversation> findBy(Member from) {
// return conversations.values().stream().filter(conversation -> conversation.has(from)).findAny();
// }
//
// @Override
// public Conversation remove(String id) {
// return conversations.remove(id);
// }
//
// @Override
// public Conversation save(Conversation conversation) {
// if (conversations.containsKey(conversation.getId())) {
// throw CONVERSATION_NAME_OCCUPIED.exception();
// }
// conversations.put(conversation.getId(), conversation);
// return conversation;
// }
//
// @Override
// public Collection<String> getAllIds() {
// return conversations.keySet();
// }
//
// @Override
// public void close() throws IOException {
// for (Conversation conversation : conversations.values()) {
// try {
// conversation.close();
// } catch (Exception e) {
// log.error("Problem during closing conversation " + conversation.getId(), e);
// }
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Members.java
// @Slf4j
// @Repository
// public class Members implements MemberRepository {
//
// private Map<String, Member> members = Maps.newConcurrentMap();
//
// @Override
// public Collection<String> getAllIds() {
// return members.keySet();
// }
//
// @Override
// public Optional<Member> findBy(String id) {
// if (id == null) {
// return Optional.empty();
// }
// return Optional.ofNullable(members.get(id));
// }
//
// @Override
// public Member register(Member member) {
// if (!members.containsKey(member.getId())) {
// members.put(member.getId(), member);
// }
// return member;
// }
//
// @Override
// public void unregister(String id) {
// findBy(id).ifPresent(Member::markLeft);
// Member removed = members.remove(id);
// if (removed != null) {
// removed.getConversation().ifPresent(c -> c.left(removed));
// }
// }
//
// @Override
// public void close() throws IOException {
// for (Member member : members.values()) {
// try {
// member.getConnection().close();
// } catch (Exception e) {
// log.error("Problem during closing member connection " + member.getId(), e);
// }
// }
// members.clear();
// }
// }
| import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import org.nextrtc.signalingserver.repository.Conversations;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.nextrtc.signalingserver.repository.Members;
import javax.inject.Singleton; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCRepositories {
@Provides
@Singleton
static Members Members() {
return new Members();
}
@Provides
@Singleton | // Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Conversations.java
// @Slf4j
// @Repository
// public class Conversations implements ConversationRepository {
//
// private Map<String, Conversation> conversations = Maps.newConcurrentMap();
//
// @Override
// public Optional<Conversation> findBy(String id) {
// if (isEmpty(id)) {
// return Optional.empty();
// }
// return Optional.ofNullable(conversations.get(id));
// }
//
// @Override
// public Optional<Conversation> findBy(Member from) {
// return conversations.values().stream().filter(conversation -> conversation.has(from)).findAny();
// }
//
// @Override
// public Conversation remove(String id) {
// return conversations.remove(id);
// }
//
// @Override
// public Conversation save(Conversation conversation) {
// if (conversations.containsKey(conversation.getId())) {
// throw CONVERSATION_NAME_OCCUPIED.exception();
// }
// conversations.put(conversation.getId(), conversation);
// return conversation;
// }
//
// @Override
// public Collection<String> getAllIds() {
// return conversations.keySet();
// }
//
// @Override
// public void close() throws IOException {
// for (Conversation conversation : conversations.values()) {
// try {
// conversation.close();
// } catch (Exception e) {
// log.error("Problem during closing conversation " + conversation.getId(), e);
// }
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Members.java
// @Slf4j
// @Repository
// public class Members implements MemberRepository {
//
// private Map<String, Member> members = Maps.newConcurrentMap();
//
// @Override
// public Collection<String> getAllIds() {
// return members.keySet();
// }
//
// @Override
// public Optional<Member> findBy(String id) {
// if (id == null) {
// return Optional.empty();
// }
// return Optional.ofNullable(members.get(id));
// }
//
// @Override
// public Member register(Member member) {
// if (!members.containsKey(member.getId())) {
// members.put(member.getId(), member);
// }
// return member;
// }
//
// @Override
// public void unregister(String id) {
// findBy(id).ifPresent(Member::markLeft);
// Member removed = members.remove(id);
// if (removed != null) {
// removed.getConversation().ifPresent(c -> c.left(removed));
// }
// }
//
// @Override
// public void close() throws IOException {
// for (Member member : members.values()) {
// try {
// member.getConnection().close();
// } catch (Exception e) {
// log.error("Problem during closing member connection " + member.getId(), e);
// }
// }
// members.clear();
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCRepositories.java
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import org.nextrtc.signalingserver.repository.Conversations;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.nextrtc.signalingserver.repository.Members;
import javax.inject.Singleton;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCRepositories {
@Provides
@Singleton
static Members Members() {
return new Members();
}
@Provides
@Singleton | static Conversations Conversations() { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCRepositories.java | // Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Conversations.java
// @Slf4j
// @Repository
// public class Conversations implements ConversationRepository {
//
// private Map<String, Conversation> conversations = Maps.newConcurrentMap();
//
// @Override
// public Optional<Conversation> findBy(String id) {
// if (isEmpty(id)) {
// return Optional.empty();
// }
// return Optional.ofNullable(conversations.get(id));
// }
//
// @Override
// public Optional<Conversation> findBy(Member from) {
// return conversations.values().stream().filter(conversation -> conversation.has(from)).findAny();
// }
//
// @Override
// public Conversation remove(String id) {
// return conversations.remove(id);
// }
//
// @Override
// public Conversation save(Conversation conversation) {
// if (conversations.containsKey(conversation.getId())) {
// throw CONVERSATION_NAME_OCCUPIED.exception();
// }
// conversations.put(conversation.getId(), conversation);
// return conversation;
// }
//
// @Override
// public Collection<String> getAllIds() {
// return conversations.keySet();
// }
//
// @Override
// public void close() throws IOException {
// for (Conversation conversation : conversations.values()) {
// try {
// conversation.close();
// } catch (Exception e) {
// log.error("Problem during closing conversation " + conversation.getId(), e);
// }
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Members.java
// @Slf4j
// @Repository
// public class Members implements MemberRepository {
//
// private Map<String, Member> members = Maps.newConcurrentMap();
//
// @Override
// public Collection<String> getAllIds() {
// return members.keySet();
// }
//
// @Override
// public Optional<Member> findBy(String id) {
// if (id == null) {
// return Optional.empty();
// }
// return Optional.ofNullable(members.get(id));
// }
//
// @Override
// public Member register(Member member) {
// if (!members.containsKey(member.getId())) {
// members.put(member.getId(), member);
// }
// return member;
// }
//
// @Override
// public void unregister(String id) {
// findBy(id).ifPresent(Member::markLeft);
// Member removed = members.remove(id);
// if (removed != null) {
// removed.getConversation().ifPresent(c -> c.left(removed));
// }
// }
//
// @Override
// public void close() throws IOException {
// for (Member member : members.values()) {
// try {
// member.getConnection().close();
// } catch (Exception e) {
// log.error("Problem during closing member connection " + member.getId(), e);
// }
// }
// members.clear();
// }
// }
| import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import org.nextrtc.signalingserver.repository.Conversations;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.nextrtc.signalingserver.repository.Members;
import javax.inject.Singleton; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCRepositories {
@Provides
@Singleton
static Members Members() {
return new Members();
}
@Provides
@Singleton
static Conversations Conversations() {
return new Conversations();
}
@Binds | // Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Conversations.java
// @Slf4j
// @Repository
// public class Conversations implements ConversationRepository {
//
// private Map<String, Conversation> conversations = Maps.newConcurrentMap();
//
// @Override
// public Optional<Conversation> findBy(String id) {
// if (isEmpty(id)) {
// return Optional.empty();
// }
// return Optional.ofNullable(conversations.get(id));
// }
//
// @Override
// public Optional<Conversation> findBy(Member from) {
// return conversations.values().stream().filter(conversation -> conversation.has(from)).findAny();
// }
//
// @Override
// public Conversation remove(String id) {
// return conversations.remove(id);
// }
//
// @Override
// public Conversation save(Conversation conversation) {
// if (conversations.containsKey(conversation.getId())) {
// throw CONVERSATION_NAME_OCCUPIED.exception();
// }
// conversations.put(conversation.getId(), conversation);
// return conversation;
// }
//
// @Override
// public Collection<String> getAllIds() {
// return conversations.keySet();
// }
//
// @Override
// public void close() throws IOException {
// for (Conversation conversation : conversations.values()) {
// try {
// conversation.close();
// } catch (Exception e) {
// log.error("Problem during closing conversation " + conversation.getId(), e);
// }
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Members.java
// @Slf4j
// @Repository
// public class Members implements MemberRepository {
//
// private Map<String, Member> members = Maps.newConcurrentMap();
//
// @Override
// public Collection<String> getAllIds() {
// return members.keySet();
// }
//
// @Override
// public Optional<Member> findBy(String id) {
// if (id == null) {
// return Optional.empty();
// }
// return Optional.ofNullable(members.get(id));
// }
//
// @Override
// public Member register(Member member) {
// if (!members.containsKey(member.getId())) {
// members.put(member.getId(), member);
// }
// return member;
// }
//
// @Override
// public void unregister(String id) {
// findBy(id).ifPresent(Member::markLeft);
// Member removed = members.remove(id);
// if (removed != null) {
// removed.getConversation().ifPresent(c -> c.left(removed));
// }
// }
//
// @Override
// public void close() throws IOException {
// for (Member member : members.values()) {
// try {
// member.getConnection().close();
// } catch (Exception e) {
// log.error("Problem during closing member connection " + member.getId(), e);
// }
// }
// members.clear();
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCRepositories.java
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import org.nextrtc.signalingserver.repository.Conversations;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.nextrtc.signalingserver.repository.Members;
import javax.inject.Singleton;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCRepositories {
@Provides
@Singleton
static Members Members() {
return new Members();
}
@Provides
@Singleton
static Conversations Conversations() {
return new Conversations();
}
@Binds | abstract ConversationRepository conversationRepository(Conversations conversations); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCRepositories.java | // Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Conversations.java
// @Slf4j
// @Repository
// public class Conversations implements ConversationRepository {
//
// private Map<String, Conversation> conversations = Maps.newConcurrentMap();
//
// @Override
// public Optional<Conversation> findBy(String id) {
// if (isEmpty(id)) {
// return Optional.empty();
// }
// return Optional.ofNullable(conversations.get(id));
// }
//
// @Override
// public Optional<Conversation> findBy(Member from) {
// return conversations.values().stream().filter(conversation -> conversation.has(from)).findAny();
// }
//
// @Override
// public Conversation remove(String id) {
// return conversations.remove(id);
// }
//
// @Override
// public Conversation save(Conversation conversation) {
// if (conversations.containsKey(conversation.getId())) {
// throw CONVERSATION_NAME_OCCUPIED.exception();
// }
// conversations.put(conversation.getId(), conversation);
// return conversation;
// }
//
// @Override
// public Collection<String> getAllIds() {
// return conversations.keySet();
// }
//
// @Override
// public void close() throws IOException {
// for (Conversation conversation : conversations.values()) {
// try {
// conversation.close();
// } catch (Exception e) {
// log.error("Problem during closing conversation " + conversation.getId(), e);
// }
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Members.java
// @Slf4j
// @Repository
// public class Members implements MemberRepository {
//
// private Map<String, Member> members = Maps.newConcurrentMap();
//
// @Override
// public Collection<String> getAllIds() {
// return members.keySet();
// }
//
// @Override
// public Optional<Member> findBy(String id) {
// if (id == null) {
// return Optional.empty();
// }
// return Optional.ofNullable(members.get(id));
// }
//
// @Override
// public Member register(Member member) {
// if (!members.containsKey(member.getId())) {
// members.put(member.getId(), member);
// }
// return member;
// }
//
// @Override
// public void unregister(String id) {
// findBy(id).ifPresent(Member::markLeft);
// Member removed = members.remove(id);
// if (removed != null) {
// removed.getConversation().ifPresent(c -> c.left(removed));
// }
// }
//
// @Override
// public void close() throws IOException {
// for (Member member : members.values()) {
// try {
// member.getConnection().close();
// } catch (Exception e) {
// log.error("Problem during closing member connection " + member.getId(), e);
// }
// }
// members.clear();
// }
// }
| import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import org.nextrtc.signalingserver.repository.Conversations;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.nextrtc.signalingserver.repository.Members;
import javax.inject.Singleton; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCRepositories {
@Provides
@Singleton
static Members Members() {
return new Members();
}
@Provides
@Singleton
static Conversations Conversations() {
return new Conversations();
}
@Binds
abstract ConversationRepository conversationRepository(Conversations conversations);
@Binds | // Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Conversations.java
// @Slf4j
// @Repository
// public class Conversations implements ConversationRepository {
//
// private Map<String, Conversation> conversations = Maps.newConcurrentMap();
//
// @Override
// public Optional<Conversation> findBy(String id) {
// if (isEmpty(id)) {
// return Optional.empty();
// }
// return Optional.ofNullable(conversations.get(id));
// }
//
// @Override
// public Optional<Conversation> findBy(Member from) {
// return conversations.values().stream().filter(conversation -> conversation.has(from)).findAny();
// }
//
// @Override
// public Conversation remove(String id) {
// return conversations.remove(id);
// }
//
// @Override
// public Conversation save(Conversation conversation) {
// if (conversations.containsKey(conversation.getId())) {
// throw CONVERSATION_NAME_OCCUPIED.exception();
// }
// conversations.put(conversation.getId(), conversation);
// return conversation;
// }
//
// @Override
// public Collection<String> getAllIds() {
// return conversations.keySet();
// }
//
// @Override
// public void close() throws IOException {
// for (Conversation conversation : conversations.values()) {
// try {
// conversation.close();
// } catch (Exception e) {
// log.error("Problem during closing conversation " + conversation.getId(), e);
// }
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/Members.java
// @Slf4j
// @Repository
// public class Members implements MemberRepository {
//
// private Map<String, Member> members = Maps.newConcurrentMap();
//
// @Override
// public Collection<String> getAllIds() {
// return members.keySet();
// }
//
// @Override
// public Optional<Member> findBy(String id) {
// if (id == null) {
// return Optional.empty();
// }
// return Optional.ofNullable(members.get(id));
// }
//
// @Override
// public Member register(Member member) {
// if (!members.containsKey(member.getId())) {
// members.put(member.getId(), member);
// }
// return member;
// }
//
// @Override
// public void unregister(String id) {
// findBy(id).ifPresent(Member::markLeft);
// Member removed = members.remove(id);
// if (removed != null) {
// removed.getConversation().ifPresent(c -> c.left(removed));
// }
// }
//
// @Override
// public void close() throws IOException {
// for (Member member : members.values()) {
// try {
// member.getConnection().close();
// } catch (Exception e) {
// log.error("Problem during closing member connection " + member.getId(), e);
// }
// }
// members.clear();
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCRepositories.java
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import org.nextrtc.signalingserver.repository.Conversations;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.nextrtc.signalingserver.repository.Members;
import javax.inject.Singleton;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCRepositories {
@Provides
@Singleton
static Members Members() {
return new Members();
}
@Provides
@Singleton
static Conversations Conversations() {
return new Conversations();
}
@Binds
abstract ConversationRepository conversationRepository(Conversations conversations);
@Binds | abstract MemberRepository memberRepository(Members members); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCSignals.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/Signals.java
// public interface Signals {
// String EMPTY = "";
// String EMPTY_HANDLER = "nextRTC_EMPTY";
// String OFFER_REQUEST = "offerRequest";
// String OFFER_RESPONSE = "offerResponse";
// String OFFER_RESPONSE_HANDLER = "nextRTC_OFFER_RESPONSE";
// String ANSWER_REQUEST = "answerRequest";
// String ANSWER_RESPONSE = "answerResponse";
// String ANSWER_RESPONSE_HANDLER = "nextRTC_ANSWER_RESPONSE";
// String FINALIZE = "finalize";
// String CANDIDATE = "candidate";
// String CANDIDATE_HANDLER = "nextRTC_CANDIDATE";
// String PING = "ping";
// String LEFT = "left";
// String LEFT_HANDLER = "nextRTC_LEFT";
// String JOIN = "join";
// String JOIN_HANDLER = "nextRTC_JOIN";
// String CREATE = "create";
// String CREATE_HANDLER = "nextRTC_CREATE";
// String JOINED = "joined";
// String CREATED = "created";
// String TEXT = "text";
// String TEXT_HANDLER = "nextRTC_TEXT";
// String NEW_JOINED = "newJoined";
// String ERROR = "error";
// String END = "end";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConversationFactory.java
// public interface ConversationFactory {
// Conversation create(String conversationName, String type);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
| import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.*;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.Signals;
import org.nextrtc.signalingserver.factory.ConversationFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import javax.inject.Singleton; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCSignals {
@Provides
@Singleton
@IntoMap | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/Signals.java
// public interface Signals {
// String EMPTY = "";
// String EMPTY_HANDLER = "nextRTC_EMPTY";
// String OFFER_REQUEST = "offerRequest";
// String OFFER_RESPONSE = "offerResponse";
// String OFFER_RESPONSE_HANDLER = "nextRTC_OFFER_RESPONSE";
// String ANSWER_REQUEST = "answerRequest";
// String ANSWER_RESPONSE = "answerResponse";
// String ANSWER_RESPONSE_HANDLER = "nextRTC_ANSWER_RESPONSE";
// String FINALIZE = "finalize";
// String CANDIDATE = "candidate";
// String CANDIDATE_HANDLER = "nextRTC_CANDIDATE";
// String PING = "ping";
// String LEFT = "left";
// String LEFT_HANDLER = "nextRTC_LEFT";
// String JOIN = "join";
// String JOIN_HANDLER = "nextRTC_JOIN";
// String CREATE = "create";
// String CREATE_HANDLER = "nextRTC_CREATE";
// String JOINED = "joined";
// String CREATED = "created";
// String TEXT = "text";
// String TEXT_HANDLER = "nextRTC_TEXT";
// String NEW_JOINED = "newJoined";
// String ERROR = "error";
// String END = "end";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConversationFactory.java
// public interface ConversationFactory {
// Conversation create(String conversationName, String type);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCSignals.java
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.*;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.Signals;
import org.nextrtc.signalingserver.factory.ConversationFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import javax.inject.Singleton;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCSignals {
@Provides
@Singleton
@IntoMap | @StringKey(Signals.ANSWER_RESPONSE_HANDLER) |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCSignals.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/Signals.java
// public interface Signals {
// String EMPTY = "";
// String EMPTY_HANDLER = "nextRTC_EMPTY";
// String OFFER_REQUEST = "offerRequest";
// String OFFER_RESPONSE = "offerResponse";
// String OFFER_RESPONSE_HANDLER = "nextRTC_OFFER_RESPONSE";
// String ANSWER_REQUEST = "answerRequest";
// String ANSWER_RESPONSE = "answerResponse";
// String ANSWER_RESPONSE_HANDLER = "nextRTC_ANSWER_RESPONSE";
// String FINALIZE = "finalize";
// String CANDIDATE = "candidate";
// String CANDIDATE_HANDLER = "nextRTC_CANDIDATE";
// String PING = "ping";
// String LEFT = "left";
// String LEFT_HANDLER = "nextRTC_LEFT";
// String JOIN = "join";
// String JOIN_HANDLER = "nextRTC_JOIN";
// String CREATE = "create";
// String CREATE_HANDLER = "nextRTC_CREATE";
// String JOINED = "joined";
// String CREATED = "created";
// String TEXT = "text";
// String TEXT_HANDLER = "nextRTC_TEXT";
// String NEW_JOINED = "newJoined";
// String ERROR = "error";
// String END = "end";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConversationFactory.java
// public interface ConversationFactory {
// Conversation create(String conversationName, String type);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
| import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.*;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.Signals;
import org.nextrtc.signalingserver.factory.ConversationFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import javax.inject.Singleton; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCSignals {
@Provides
@Singleton
@IntoMap
@StringKey(Signals.ANSWER_RESPONSE_HANDLER)
static SignalHandler AnswerResponseHandler() {
return new AnswerResponseHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CANDIDATE_HANDLER)
static SignalHandler CandidateHandler() {
return new CandidateHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CREATE_HANDLER)
static SignalHandler CreateConversationEntry(CreateConversation conversation) {
return conversation;
}
@Provides
@Singleton | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/Signals.java
// public interface Signals {
// String EMPTY = "";
// String EMPTY_HANDLER = "nextRTC_EMPTY";
// String OFFER_REQUEST = "offerRequest";
// String OFFER_RESPONSE = "offerResponse";
// String OFFER_RESPONSE_HANDLER = "nextRTC_OFFER_RESPONSE";
// String ANSWER_REQUEST = "answerRequest";
// String ANSWER_RESPONSE = "answerResponse";
// String ANSWER_RESPONSE_HANDLER = "nextRTC_ANSWER_RESPONSE";
// String FINALIZE = "finalize";
// String CANDIDATE = "candidate";
// String CANDIDATE_HANDLER = "nextRTC_CANDIDATE";
// String PING = "ping";
// String LEFT = "left";
// String LEFT_HANDLER = "nextRTC_LEFT";
// String JOIN = "join";
// String JOIN_HANDLER = "nextRTC_JOIN";
// String CREATE = "create";
// String CREATE_HANDLER = "nextRTC_CREATE";
// String JOINED = "joined";
// String CREATED = "created";
// String TEXT = "text";
// String TEXT_HANDLER = "nextRTC_TEXT";
// String NEW_JOINED = "newJoined";
// String ERROR = "error";
// String END = "end";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConversationFactory.java
// public interface ConversationFactory {
// Conversation create(String conversationName, String type);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCSignals.java
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.*;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.Signals;
import org.nextrtc.signalingserver.factory.ConversationFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import javax.inject.Singleton;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCSignals {
@Provides
@Singleton
@IntoMap
@StringKey(Signals.ANSWER_RESPONSE_HANDLER)
static SignalHandler AnswerResponseHandler() {
return new AnswerResponseHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CANDIDATE_HANDLER)
static SignalHandler CandidateHandler() {
return new CandidateHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CREATE_HANDLER)
static SignalHandler CreateConversationEntry(CreateConversation conversation) {
return conversation;
}
@Provides
@Singleton | static CreateConversation CreateConversation(NextRTCEventBus eventBus, |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCSignals.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/Signals.java
// public interface Signals {
// String EMPTY = "";
// String EMPTY_HANDLER = "nextRTC_EMPTY";
// String OFFER_REQUEST = "offerRequest";
// String OFFER_RESPONSE = "offerResponse";
// String OFFER_RESPONSE_HANDLER = "nextRTC_OFFER_RESPONSE";
// String ANSWER_REQUEST = "answerRequest";
// String ANSWER_RESPONSE = "answerResponse";
// String ANSWER_RESPONSE_HANDLER = "nextRTC_ANSWER_RESPONSE";
// String FINALIZE = "finalize";
// String CANDIDATE = "candidate";
// String CANDIDATE_HANDLER = "nextRTC_CANDIDATE";
// String PING = "ping";
// String LEFT = "left";
// String LEFT_HANDLER = "nextRTC_LEFT";
// String JOIN = "join";
// String JOIN_HANDLER = "nextRTC_JOIN";
// String CREATE = "create";
// String CREATE_HANDLER = "nextRTC_CREATE";
// String JOINED = "joined";
// String CREATED = "created";
// String TEXT = "text";
// String TEXT_HANDLER = "nextRTC_TEXT";
// String NEW_JOINED = "newJoined";
// String ERROR = "error";
// String END = "end";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConversationFactory.java
// public interface ConversationFactory {
// Conversation create(String conversationName, String type);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
| import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.*;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.Signals;
import org.nextrtc.signalingserver.factory.ConversationFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import javax.inject.Singleton; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCSignals {
@Provides
@Singleton
@IntoMap
@StringKey(Signals.ANSWER_RESPONSE_HANDLER)
static SignalHandler AnswerResponseHandler() {
return new AnswerResponseHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CANDIDATE_HANDLER)
static SignalHandler CandidateHandler() {
return new CandidateHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CREATE_HANDLER)
static SignalHandler CreateConversationEntry(CreateConversation conversation) {
return conversation;
}
@Provides
@Singleton
static CreateConversation CreateConversation(NextRTCEventBus eventBus, | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/Signals.java
// public interface Signals {
// String EMPTY = "";
// String EMPTY_HANDLER = "nextRTC_EMPTY";
// String OFFER_REQUEST = "offerRequest";
// String OFFER_RESPONSE = "offerResponse";
// String OFFER_RESPONSE_HANDLER = "nextRTC_OFFER_RESPONSE";
// String ANSWER_REQUEST = "answerRequest";
// String ANSWER_RESPONSE = "answerResponse";
// String ANSWER_RESPONSE_HANDLER = "nextRTC_ANSWER_RESPONSE";
// String FINALIZE = "finalize";
// String CANDIDATE = "candidate";
// String CANDIDATE_HANDLER = "nextRTC_CANDIDATE";
// String PING = "ping";
// String LEFT = "left";
// String LEFT_HANDLER = "nextRTC_LEFT";
// String JOIN = "join";
// String JOIN_HANDLER = "nextRTC_JOIN";
// String CREATE = "create";
// String CREATE_HANDLER = "nextRTC_CREATE";
// String JOINED = "joined";
// String CREATED = "created";
// String TEXT = "text";
// String TEXT_HANDLER = "nextRTC_TEXT";
// String NEW_JOINED = "newJoined";
// String ERROR = "error";
// String END = "end";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConversationFactory.java
// public interface ConversationFactory {
// Conversation create(String conversationName, String type);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCSignals.java
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.*;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.Signals;
import org.nextrtc.signalingserver.factory.ConversationFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import javax.inject.Singleton;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCSignals {
@Provides
@Singleton
@IntoMap
@StringKey(Signals.ANSWER_RESPONSE_HANDLER)
static SignalHandler AnswerResponseHandler() {
return new AnswerResponseHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CANDIDATE_HANDLER)
static SignalHandler CandidateHandler() {
return new CandidateHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CREATE_HANDLER)
static SignalHandler CreateConversationEntry(CreateConversation conversation) {
return conversation;
}
@Provides
@Singleton
static CreateConversation CreateConversation(NextRTCEventBus eventBus, | ConversationRepository conversations, |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCSignals.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/Signals.java
// public interface Signals {
// String EMPTY = "";
// String EMPTY_HANDLER = "nextRTC_EMPTY";
// String OFFER_REQUEST = "offerRequest";
// String OFFER_RESPONSE = "offerResponse";
// String OFFER_RESPONSE_HANDLER = "nextRTC_OFFER_RESPONSE";
// String ANSWER_REQUEST = "answerRequest";
// String ANSWER_RESPONSE = "answerResponse";
// String ANSWER_RESPONSE_HANDLER = "nextRTC_ANSWER_RESPONSE";
// String FINALIZE = "finalize";
// String CANDIDATE = "candidate";
// String CANDIDATE_HANDLER = "nextRTC_CANDIDATE";
// String PING = "ping";
// String LEFT = "left";
// String LEFT_HANDLER = "nextRTC_LEFT";
// String JOIN = "join";
// String JOIN_HANDLER = "nextRTC_JOIN";
// String CREATE = "create";
// String CREATE_HANDLER = "nextRTC_CREATE";
// String JOINED = "joined";
// String CREATED = "created";
// String TEXT = "text";
// String TEXT_HANDLER = "nextRTC_TEXT";
// String NEW_JOINED = "newJoined";
// String ERROR = "error";
// String END = "end";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConversationFactory.java
// public interface ConversationFactory {
// Conversation create(String conversationName, String type);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
| import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.*;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.Signals;
import org.nextrtc.signalingserver.factory.ConversationFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import javax.inject.Singleton; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCSignals {
@Provides
@Singleton
@IntoMap
@StringKey(Signals.ANSWER_RESPONSE_HANDLER)
static SignalHandler AnswerResponseHandler() {
return new AnswerResponseHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CANDIDATE_HANDLER)
static SignalHandler CandidateHandler() {
return new CandidateHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CREATE_HANDLER)
static SignalHandler CreateConversationEntry(CreateConversation conversation) {
return conversation;
}
@Provides
@Singleton
static CreateConversation CreateConversation(NextRTCEventBus eventBus,
ConversationRepository conversations, | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/Signals.java
// public interface Signals {
// String EMPTY = "";
// String EMPTY_HANDLER = "nextRTC_EMPTY";
// String OFFER_REQUEST = "offerRequest";
// String OFFER_RESPONSE = "offerResponse";
// String OFFER_RESPONSE_HANDLER = "nextRTC_OFFER_RESPONSE";
// String ANSWER_REQUEST = "answerRequest";
// String ANSWER_RESPONSE = "answerResponse";
// String ANSWER_RESPONSE_HANDLER = "nextRTC_ANSWER_RESPONSE";
// String FINALIZE = "finalize";
// String CANDIDATE = "candidate";
// String CANDIDATE_HANDLER = "nextRTC_CANDIDATE";
// String PING = "ping";
// String LEFT = "left";
// String LEFT_HANDLER = "nextRTC_LEFT";
// String JOIN = "join";
// String JOIN_HANDLER = "nextRTC_JOIN";
// String CREATE = "create";
// String CREATE_HANDLER = "nextRTC_CREATE";
// String JOINED = "joined";
// String CREATED = "created";
// String TEXT = "text";
// String TEXT_HANDLER = "nextRTC_TEXT";
// String NEW_JOINED = "newJoined";
// String ERROR = "error";
// String END = "end";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConversationFactory.java
// public interface ConversationFactory {
// Conversation create(String conversationName, String type);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCSignals.java
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.*;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.Signals;
import org.nextrtc.signalingserver.factory.ConversationFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import javax.inject.Singleton;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCSignals {
@Provides
@Singleton
@IntoMap
@StringKey(Signals.ANSWER_RESPONSE_HANDLER)
static SignalHandler AnswerResponseHandler() {
return new AnswerResponseHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CANDIDATE_HANDLER)
static SignalHandler CandidateHandler() {
return new CandidateHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CREATE_HANDLER)
static SignalHandler CreateConversationEntry(CreateConversation conversation) {
return conversation;
}
@Provides
@Singleton
static CreateConversation CreateConversation(NextRTCEventBus eventBus,
ConversationRepository conversations, | ConversationFactory factory) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCSignals.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/Signals.java
// public interface Signals {
// String EMPTY = "";
// String EMPTY_HANDLER = "nextRTC_EMPTY";
// String OFFER_REQUEST = "offerRequest";
// String OFFER_RESPONSE = "offerResponse";
// String OFFER_RESPONSE_HANDLER = "nextRTC_OFFER_RESPONSE";
// String ANSWER_REQUEST = "answerRequest";
// String ANSWER_RESPONSE = "answerResponse";
// String ANSWER_RESPONSE_HANDLER = "nextRTC_ANSWER_RESPONSE";
// String FINALIZE = "finalize";
// String CANDIDATE = "candidate";
// String CANDIDATE_HANDLER = "nextRTC_CANDIDATE";
// String PING = "ping";
// String LEFT = "left";
// String LEFT_HANDLER = "nextRTC_LEFT";
// String JOIN = "join";
// String JOIN_HANDLER = "nextRTC_JOIN";
// String CREATE = "create";
// String CREATE_HANDLER = "nextRTC_CREATE";
// String JOINED = "joined";
// String CREATED = "created";
// String TEXT = "text";
// String TEXT_HANDLER = "nextRTC_TEXT";
// String NEW_JOINED = "newJoined";
// String ERROR = "error";
// String END = "end";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConversationFactory.java
// public interface ConversationFactory {
// Conversation create(String conversationName, String type);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
| import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.*;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.Signals;
import org.nextrtc.signalingserver.factory.ConversationFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import javax.inject.Singleton; | @Provides
@Singleton
@IntoMap
@StringKey(Signals.CANDIDATE_HANDLER)
static SignalHandler CandidateHandler() {
return new CandidateHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CREATE_HANDLER)
static SignalHandler CreateConversationEntry(CreateConversation conversation) {
return conversation;
}
@Provides
@Singleton
static CreateConversation CreateConversation(NextRTCEventBus eventBus,
ConversationRepository conversations,
ConversationFactory factory) {
return new CreateConversation(eventBus, conversations, factory);
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.JOIN_HANDLER)
static SignalHandler JoinConversation(ConversationRepository conversations,
CreateConversation create, | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/Signals.java
// public interface Signals {
// String EMPTY = "";
// String EMPTY_HANDLER = "nextRTC_EMPTY";
// String OFFER_REQUEST = "offerRequest";
// String OFFER_RESPONSE = "offerResponse";
// String OFFER_RESPONSE_HANDLER = "nextRTC_OFFER_RESPONSE";
// String ANSWER_REQUEST = "answerRequest";
// String ANSWER_RESPONSE = "answerResponse";
// String ANSWER_RESPONSE_HANDLER = "nextRTC_ANSWER_RESPONSE";
// String FINALIZE = "finalize";
// String CANDIDATE = "candidate";
// String CANDIDATE_HANDLER = "nextRTC_CANDIDATE";
// String PING = "ping";
// String LEFT = "left";
// String LEFT_HANDLER = "nextRTC_LEFT";
// String JOIN = "join";
// String JOIN_HANDLER = "nextRTC_JOIN";
// String CREATE = "create";
// String CREATE_HANDLER = "nextRTC_CREATE";
// String JOINED = "joined";
// String CREATED = "created";
// String TEXT = "text";
// String TEXT_HANDLER = "nextRTC_TEXT";
// String NEW_JOINED = "newJoined";
// String ERROR = "error";
// String END = "end";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConversationFactory.java
// public interface ConversationFactory {
// Conversation create(String conversationName, String type);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCSignals.java
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.*;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.Signals;
import org.nextrtc.signalingserver.factory.ConversationFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import javax.inject.Singleton;
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CANDIDATE_HANDLER)
static SignalHandler CandidateHandler() {
return new CandidateHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.CREATE_HANDLER)
static SignalHandler CreateConversationEntry(CreateConversation conversation) {
return conversation;
}
@Provides
@Singleton
static CreateConversation CreateConversation(NextRTCEventBus eventBus,
ConversationRepository conversations,
ConversationFactory factory) {
return new CreateConversation(eventBus, conversations, factory);
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.JOIN_HANDLER)
static SignalHandler JoinConversation(ConversationRepository conversations,
CreateConversation create, | NextRTCProperties properties) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCSignals.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/Signals.java
// public interface Signals {
// String EMPTY = "";
// String EMPTY_HANDLER = "nextRTC_EMPTY";
// String OFFER_REQUEST = "offerRequest";
// String OFFER_RESPONSE = "offerResponse";
// String OFFER_RESPONSE_HANDLER = "nextRTC_OFFER_RESPONSE";
// String ANSWER_REQUEST = "answerRequest";
// String ANSWER_RESPONSE = "answerResponse";
// String ANSWER_RESPONSE_HANDLER = "nextRTC_ANSWER_RESPONSE";
// String FINALIZE = "finalize";
// String CANDIDATE = "candidate";
// String CANDIDATE_HANDLER = "nextRTC_CANDIDATE";
// String PING = "ping";
// String LEFT = "left";
// String LEFT_HANDLER = "nextRTC_LEFT";
// String JOIN = "join";
// String JOIN_HANDLER = "nextRTC_JOIN";
// String CREATE = "create";
// String CREATE_HANDLER = "nextRTC_CREATE";
// String JOINED = "joined";
// String CREATED = "created";
// String TEXT = "text";
// String TEXT_HANDLER = "nextRTC_TEXT";
// String NEW_JOINED = "newJoined";
// String ERROR = "error";
// String END = "end";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConversationFactory.java
// public interface ConversationFactory {
// Conversation create(String conversationName, String type);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
| import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.*;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.Signals;
import org.nextrtc.signalingserver.factory.ConversationFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import javax.inject.Singleton; | @IntoMap
@StringKey(Signals.JOIN_HANDLER)
static SignalHandler JoinConversation(ConversationRepository conversations,
CreateConversation create,
NextRTCProperties properties) {
return new JoinConversation(conversations, create, properties);
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.LEFT_HANDLER)
static SignalHandler LeftConversation(NextRTCEventBus eventBus,
ConversationRepository conversations) {
return new LeftConversation(eventBus, conversations);
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.OFFER_RESPONSE_HANDLER)
static SignalHandler OfferResponseHandler() {
return new OfferResponseHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.TEXT_HANDLER)
static SignalHandler TextMessage(NextRTCEventBus eventBus, | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// 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/Signals.java
// public interface Signals {
// String EMPTY = "";
// String EMPTY_HANDLER = "nextRTC_EMPTY";
// String OFFER_REQUEST = "offerRequest";
// String OFFER_RESPONSE = "offerResponse";
// String OFFER_RESPONSE_HANDLER = "nextRTC_OFFER_RESPONSE";
// String ANSWER_REQUEST = "answerRequest";
// String ANSWER_RESPONSE = "answerResponse";
// String ANSWER_RESPONSE_HANDLER = "nextRTC_ANSWER_RESPONSE";
// String FINALIZE = "finalize";
// String CANDIDATE = "candidate";
// String CANDIDATE_HANDLER = "nextRTC_CANDIDATE";
// String PING = "ping";
// String LEFT = "left";
// String LEFT_HANDLER = "nextRTC_LEFT";
// String JOIN = "join";
// String JOIN_HANDLER = "nextRTC_JOIN";
// String CREATE = "create";
// String CREATE_HANDLER = "nextRTC_CREATE";
// String JOINED = "joined";
// String CREATED = "created";
// String TEXT = "text";
// String TEXT_HANDLER = "nextRTC_TEXT";
// String NEW_JOINED = "newJoined";
// String ERROR = "error";
// String END = "end";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConversationFactory.java
// public interface ConversationFactory {
// Conversation create(String conversationName, String type);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
// public interface ConversationRepository extends Closeable {
// Optional<Conversation> findBy(String id);
//
// Optional<Conversation> findBy(Member from);
//
// Conversation remove(String id);
//
// Conversation save(Conversation conversation);
//
// Collection<String> getAllIds();
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCSignals.java
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.cases.*;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.Signals;
import org.nextrtc.signalingserver.factory.ConversationFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.ConversationRepository;
import javax.inject.Singleton;
@IntoMap
@StringKey(Signals.JOIN_HANDLER)
static SignalHandler JoinConversation(ConversationRepository conversations,
CreateConversation create,
NextRTCProperties properties) {
return new JoinConversation(conversations, create, properties);
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.LEFT_HANDLER)
static SignalHandler LeftConversation(NextRTCEventBus eventBus,
ConversationRepository conversations) {
return new LeftConversation(eventBus, conversations);
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.OFFER_RESPONSE_HANDLER)
static SignalHandler OfferResponseHandler() {
return new OfferResponseHandler();
}
@Provides
@Singleton
@IntoMap
@StringKey(Signals.TEXT_HANDLER)
static SignalHandler TextMessage(NextRTCEventBus eventBus, | MessageSender sender) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java | // Path: src/main/java/org/nextrtc/signalingserver/domain/Conversation.java
// @Getter
// @Component
// @Scope("prototype")
// public abstract class Conversation implements NextRTCConversation {
// protected static final ExecutorService parallel = Executors.newCachedThreadPool();
// protected final String id;
//
// private LeftConversation leftConversation;
// protected MessageSender messageSender;
//
// public Conversation(String id) {
// this.id = id;
// }
//
// public Conversation(String id,
// LeftConversation leftConversation,
// MessageSender messageSender) {
// this.id = id;
// this.leftConversation = leftConversation;
// this.messageSender = messageSender;
// }
//
// public abstract void join(Member sender);
//
// public synchronized void left(Member sender) {
// if (remove(sender) && isWithoutMember()) {
// leftConversation.destroy(this, sender);
// }
// }
//
// protected abstract boolean remove(Member leaving);
//
// protected void assignSenderToConversation(Member sender) {
// sender.assign(this);
// }
//
// public abstract boolean isWithoutMember();
//
// public abstract boolean has(Member from);
//
// public abstract void exchangeSignals(InternalMessage message);
//
// protected void sendJoinedToConversation(Member sender, String id) {
// messageSender.send(InternalMessage.create()//
// .to(sender)//
// .content(id)//
// .signal(Signal.JOINED)//
// .build());
// }
//
// protected void sendJoinedFrom(Member sender, Member member) {
// messageSender.send(InternalMessage.create()//
// .from(sender)//
// .to(member)//
// .signal(Signal.NEW_JOINED)//
// .content(sender.getId())
// .build());
// }
//
// protected void sendLeftMessage(Member leaving, Member recipient) {
// messageSender.send(InternalMessage.create()//
// .from(leaving)//
// .to(recipient)//
// .signal(Signal.LEFT)//
// .build());
// }
//
// public abstract void broadcast(Member from, InternalMessage message);
//
// @Inject
// public void setLeftConversation(LeftConversation leftConversation) {
// this.leftConversation = leftConversation;
// }
//
// @Inject
// public void setMessageSender(MessageSender messageSender) {
// this.messageSender = messageSender;
// }
//
// @Override
// public String toString() {
// return this.getClass().getSimpleName() + ": " + id;
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
| import org.nextrtc.signalingserver.domain.Conversation;
import org.nextrtc.signalingserver.domain.Member;
import java.io.Closeable;
import java.util.Collection;
import java.util.Optional; | package org.nextrtc.signalingserver.repository;
public interface ConversationRepository extends Closeable {
Optional<Conversation> findBy(String id);
| // Path: src/main/java/org/nextrtc/signalingserver/domain/Conversation.java
// @Getter
// @Component
// @Scope("prototype")
// public abstract class Conversation implements NextRTCConversation {
// protected static final ExecutorService parallel = Executors.newCachedThreadPool();
// protected final String id;
//
// private LeftConversation leftConversation;
// protected MessageSender messageSender;
//
// public Conversation(String id) {
// this.id = id;
// }
//
// public Conversation(String id,
// LeftConversation leftConversation,
// MessageSender messageSender) {
// this.id = id;
// this.leftConversation = leftConversation;
// this.messageSender = messageSender;
// }
//
// public abstract void join(Member sender);
//
// public synchronized void left(Member sender) {
// if (remove(sender) && isWithoutMember()) {
// leftConversation.destroy(this, sender);
// }
// }
//
// protected abstract boolean remove(Member leaving);
//
// protected void assignSenderToConversation(Member sender) {
// sender.assign(this);
// }
//
// public abstract boolean isWithoutMember();
//
// public abstract boolean has(Member from);
//
// public abstract void exchangeSignals(InternalMessage message);
//
// protected void sendJoinedToConversation(Member sender, String id) {
// messageSender.send(InternalMessage.create()//
// .to(sender)//
// .content(id)//
// .signal(Signal.JOINED)//
// .build());
// }
//
// protected void sendJoinedFrom(Member sender, Member member) {
// messageSender.send(InternalMessage.create()//
// .from(sender)//
// .to(member)//
// .signal(Signal.NEW_JOINED)//
// .content(sender.getId())
// .build());
// }
//
// protected void sendLeftMessage(Member leaving, Member recipient) {
// messageSender.send(InternalMessage.create()//
// .from(leaving)//
// .to(recipient)//
// .signal(Signal.LEFT)//
// .build());
// }
//
// public abstract void broadcast(Member from, InternalMessage message);
//
// @Inject
// public void setLeftConversation(LeftConversation leftConversation) {
// this.leftConversation = leftConversation;
// }
//
// @Inject
// public void setMessageSender(MessageSender messageSender) {
// this.messageSender = messageSender;
// }
//
// @Override
// public String toString() {
// return this.getClass().getSimpleName() + ": " + id;
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/repository/ConversationRepository.java
import org.nextrtc.signalingserver.domain.Conversation;
import org.nextrtc.signalingserver.domain.Member;
import java.io.Closeable;
import java.util.Collection;
import java.util.Optional;
package org.nextrtc.signalingserver.repository;
public interface ConversationRepository extends Closeable {
Optional<Conversation> findBy(String id);
| Optional<Conversation> findBy(Member from); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/factory/AbstractConversationFactory.java | // Path: src/main/java/org/nextrtc/signalingserver/domain/Conversation.java
// @Getter
// @Component
// @Scope("prototype")
// public abstract class Conversation implements NextRTCConversation {
// protected static final ExecutorService parallel = Executors.newCachedThreadPool();
// protected final String id;
//
// private LeftConversation leftConversation;
// protected MessageSender messageSender;
//
// public Conversation(String id) {
// this.id = id;
// }
//
// public Conversation(String id,
// LeftConversation leftConversation,
// MessageSender messageSender) {
// this.id = id;
// this.leftConversation = leftConversation;
// this.messageSender = messageSender;
// }
//
// public abstract void join(Member sender);
//
// public synchronized void left(Member sender) {
// if (remove(sender) && isWithoutMember()) {
// leftConversation.destroy(this, sender);
// }
// }
//
// protected abstract boolean remove(Member leaving);
//
// protected void assignSenderToConversation(Member sender) {
// sender.assign(this);
// }
//
// public abstract boolean isWithoutMember();
//
// public abstract boolean has(Member from);
//
// public abstract void exchangeSignals(InternalMessage message);
//
// protected void sendJoinedToConversation(Member sender, String id) {
// messageSender.send(InternalMessage.create()//
// .to(sender)//
// .content(id)//
// .signal(Signal.JOINED)//
// .build());
// }
//
// protected void sendJoinedFrom(Member sender, Member member) {
// messageSender.send(InternalMessage.create()//
// .from(sender)//
// .to(member)//
// .signal(Signal.NEW_JOINED)//
// .content(sender.getId())
// .build());
// }
//
// protected void sendLeftMessage(Member leaving, Member recipient) {
// messageSender.send(InternalMessage.create()//
// .from(leaving)//
// .to(recipient)//
// .signal(Signal.LEFT)//
// .build());
// }
//
// public abstract void broadcast(Member from, InternalMessage message);
//
// @Inject
// public void setLeftConversation(LeftConversation leftConversation) {
// this.leftConversation = leftConversation;
// }
//
// @Inject
// public void setMessageSender(MessageSender messageSender) {
// this.messageSender = messageSender;
// }
//
// @Override
// public String toString() {
// return this.getClass().getSimpleName() + ": " + id;
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
| import org.nextrtc.signalingserver.domain.Conversation;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import static org.apache.commons.lang3.StringUtils.defaultString;
import static org.apache.commons.lang3.StringUtils.isBlank; | package org.nextrtc.signalingserver.factory;
public abstract class AbstractConversationFactory implements ConversationFactory {
private final Map<String, Function<String, Conversation>> supportedTypes = new ConcurrentHashMap<>(); | // Path: src/main/java/org/nextrtc/signalingserver/domain/Conversation.java
// @Getter
// @Component
// @Scope("prototype")
// public abstract class Conversation implements NextRTCConversation {
// protected static final ExecutorService parallel = Executors.newCachedThreadPool();
// protected final String id;
//
// private LeftConversation leftConversation;
// protected MessageSender messageSender;
//
// public Conversation(String id) {
// this.id = id;
// }
//
// public Conversation(String id,
// LeftConversation leftConversation,
// MessageSender messageSender) {
// this.id = id;
// this.leftConversation = leftConversation;
// this.messageSender = messageSender;
// }
//
// public abstract void join(Member sender);
//
// public synchronized void left(Member sender) {
// if (remove(sender) && isWithoutMember()) {
// leftConversation.destroy(this, sender);
// }
// }
//
// protected abstract boolean remove(Member leaving);
//
// protected void assignSenderToConversation(Member sender) {
// sender.assign(this);
// }
//
// public abstract boolean isWithoutMember();
//
// public abstract boolean has(Member from);
//
// public abstract void exchangeSignals(InternalMessage message);
//
// protected void sendJoinedToConversation(Member sender, String id) {
// messageSender.send(InternalMessage.create()//
// .to(sender)//
// .content(id)//
// .signal(Signal.JOINED)//
// .build());
// }
//
// protected void sendJoinedFrom(Member sender, Member member) {
// messageSender.send(InternalMessage.create()//
// .from(sender)//
// .to(member)//
// .signal(Signal.NEW_JOINED)//
// .content(sender.getId())
// .build());
// }
//
// protected void sendLeftMessage(Member leaving, Member recipient) {
// messageSender.send(InternalMessage.create()//
// .from(leaving)//
// .to(recipient)//
// .signal(Signal.LEFT)//
// .build());
// }
//
// public abstract void broadcast(Member from, InternalMessage message);
//
// @Inject
// public void setLeftConversation(LeftConversation leftConversation) {
// this.leftConversation = leftConversation;
// }
//
// @Inject
// public void setMessageSender(MessageSender messageSender) {
// this.messageSender = messageSender;
// }
//
// @Override
// public String toString() {
// return this.getClass().getSimpleName() + ": " + id;
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
// Path: src/main/java/org/nextrtc/signalingserver/factory/AbstractConversationFactory.java
import org.nextrtc.signalingserver.domain.Conversation;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import static org.apache.commons.lang3.StringUtils.defaultString;
import static org.apache.commons.lang3.StringUtils.isBlank;
package org.nextrtc.signalingserver.factory;
public abstract class AbstractConversationFactory implements ConversationFactory {
private final Map<String, Function<String, Conversation>> supportedTypes = new ConcurrentHashMap<>(); | private final NextRTCProperties properties; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java | // Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
| import org.nextrtc.signalingserver.domain.Member;
import java.io.Closeable;
import java.util.Collection;
import java.util.Optional; | package org.nextrtc.signalingserver.repository;
public interface MemberRepository extends Closeable{
Collection<String> getAllIds();
| // Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
import org.nextrtc.signalingserver.domain.Member;
import java.io.Closeable;
import java.util.Collection;
import java.util.Optional;
package org.nextrtc.signalingserver.repository;
public interface MemberRepository extends Closeable{
Collection<String> getAllIds();
| Optional<Member> findBy(String id); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/api/NextRTCServer.java | // Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Message.java
// @Getter
// @Builder(builderMethodName = "create")
// @AllArgsConstructor(access = AccessLevel.PRIVATE)
// public class Message {
// /**
// * Use Message.create(...) instead of new Message()
// */
// @Deprecated
// Message() {
// }
//
// @Expose
// private String from = EMPTY;
//
// @Expose
// private String to = EMPTY;
//
// @Expose
// private String signal = EMPTY;
//
// @Expose
// private String content = EMPTY;
//
// @Expose
// private Map<String, String> custom = Maps.newHashMap();
//
// @Override
// public String toString() {
// return String.format("(%s -> %s)[%s]: %s |%s", from, to, signal, content, custom);
// }
// }
| import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Message;
import java.io.Closeable;
import java.util.function.Function;
import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4; | package org.nextrtc.signalingserver.api;
public interface NextRTCServer extends Closeable {
void register(Connection connection);
| // Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Message.java
// @Getter
// @Builder(builderMethodName = "create")
// @AllArgsConstructor(access = AccessLevel.PRIVATE)
// public class Message {
// /**
// * Use Message.create(...) instead of new Message()
// */
// @Deprecated
// Message() {
// }
//
// @Expose
// private String from = EMPTY;
//
// @Expose
// private String to = EMPTY;
//
// @Expose
// private String signal = EMPTY;
//
// @Expose
// private String content = EMPTY;
//
// @Expose
// private Map<String, String> custom = Maps.newHashMap();
//
// @Override
// public String toString() {
// return String.format("(%s -> %s)[%s]: %s |%s", from, to, signal, content, custom);
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCServer.java
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Message;
import java.io.Closeable;
import java.util.function.Function;
import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4;
package org.nextrtc.signalingserver.api;
public interface NextRTCServer extends Closeable {
void register(Connection connection);
| void handle(Message external, Connection connection); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/NextRTCConfig.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
| import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean;
import java.util.concurrent.ScheduledExecutorService; | package org.nextrtc.signalingserver;
@Configuration
@ComponentScan(basePackageClasses = {NextRTCConfig.class})
public class NextRTCConfig {
@Autowired | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
// Path: src/main/java/org/nextrtc/signalingserver/NextRTCConfig.java
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean;
import java.util.concurrent.ScheduledExecutorService;
package org.nextrtc.signalingserver;
@Configuration
@ComponentScan(basePackageClasses = {NextRTCConfig.class})
public class NextRTCConfig {
@Autowired | private NextRTCProperties properties; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/NextRTCConfig.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
| import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean;
import java.util.concurrent.ScheduledExecutorService; | package org.nextrtc.signalingserver;
@Configuration
@ComponentScan(basePackageClasses = {NextRTCConfig.class})
public class NextRTCConfig {
@Autowired
private NextRTCProperties properties;
@Bean(name = Names.EVENT_BUS) | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
// Path: src/main/java/org/nextrtc/signalingserver/NextRTCConfig.java
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean;
import java.util.concurrent.ScheduledExecutorService;
package org.nextrtc.signalingserver;
@Configuration
@ComponentScan(basePackageClasses = {NextRTCConfig.class})
public class NextRTCConfig {
@Autowired
private NextRTCProperties properties;
@Bean(name = Names.EVENT_BUS) | public NextRTCEventBus eventBus() { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/api/annotation/NextRTCEventListener.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
| import org.nextrtc.signalingserver.api.NextRTCEvents;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME; | package org.nextrtc.signalingserver.api.annotation;
@Retention(RUNTIME)
@Target({TYPE})
public @interface NextRTCEventListener {
| // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/api/annotation/NextRTCEventListener.java
import org.nextrtc.signalingserver.api.NextRTCEvents;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
package org.nextrtc.signalingserver.api.annotation;
@Retention(RUNTIME)
@Target({TYPE})
public @interface NextRTCEventListener {
| NextRTCEvents[] value() default {}; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/Member.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/EventContext.java
// public static EventContextBuilder builder() {
// return new EventContextBuilder();
// }
| import lombok.Getter;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.Optional;
import java.util.concurrent.ScheduledFuture;
import static org.nextrtc.signalingserver.api.NextRTCEvents.MEMBER_JOINED;
import static org.nextrtc.signalingserver.api.NextRTCEvents.MEMBER_LEFT;
import static org.nextrtc.signalingserver.domain.EventContext.builder; | package org.nextrtc.signalingserver.domain;
@Getter
@Component
@Scope("prototype") | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/EventContext.java
// public static EventContextBuilder builder() {
// return new EventContextBuilder();
// }
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
import lombok.Getter;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.Optional;
import java.util.concurrent.ScheduledFuture;
import static org.nextrtc.signalingserver.api.NextRTCEvents.MEMBER_JOINED;
import static org.nextrtc.signalingserver.api.NextRTCEvents.MEMBER_LEFT;
import static org.nextrtc.signalingserver.domain.EventContext.builder;
package org.nextrtc.signalingserver.domain;
@Getter
@Component
@Scope("prototype") | public class Member implements NextRTCMember { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/Member.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/EventContext.java
// public static EventContextBuilder builder() {
// return new EventContextBuilder();
// }
| import lombok.Getter;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.Optional;
import java.util.concurrent.ScheduledFuture;
import static org.nextrtc.signalingserver.api.NextRTCEvents.MEMBER_JOINED;
import static org.nextrtc.signalingserver.api.NextRTCEvents.MEMBER_LEFT;
import static org.nextrtc.signalingserver.domain.EventContext.builder; | package org.nextrtc.signalingserver.domain;
@Getter
@Component
@Scope("prototype")
public class Member implements NextRTCMember {
private String id;
private Connection connection;
private Conversation conversation;
| // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/EventContext.java
// public static EventContextBuilder builder() {
// return new EventContextBuilder();
// }
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
import lombok.Getter;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.Optional;
import java.util.concurrent.ScheduledFuture;
import static org.nextrtc.signalingserver.api.NextRTCEvents.MEMBER_JOINED;
import static org.nextrtc.signalingserver.api.NextRTCEvents.MEMBER_LEFT;
import static org.nextrtc.signalingserver.domain.EventContext.builder;
package org.nextrtc.signalingserver.domain;
@Getter
@Component
@Scope("prototype")
public class Member implements NextRTCMember {
private String id;
private Connection connection;
private Conversation conversation;
| private NextRTCEventBus eventBus; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/Member.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/EventContext.java
// public static EventContextBuilder builder() {
// return new EventContextBuilder();
// }
| import lombok.Getter;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.Optional;
import java.util.concurrent.ScheduledFuture;
import static org.nextrtc.signalingserver.api.NextRTCEvents.MEMBER_JOINED;
import static org.nextrtc.signalingserver.api.NextRTCEvents.MEMBER_LEFT;
import static org.nextrtc.signalingserver.domain.EventContext.builder; | package org.nextrtc.signalingserver.domain;
@Getter
@Component
@Scope("prototype")
public class Member implements NextRTCMember {
private String id;
private Connection connection;
private Conversation conversation;
private NextRTCEventBus eventBus;
private ScheduledFuture<?> ping;
public Member(Connection connection, ScheduledFuture<?> ping) {
this.id = connection.getId();
this.connection = connection;
this.ping = ping;
}
public Optional<Conversation> getConversation() {
return Optional.ofNullable(conversation);
}
public void markLeft() {
ping.cancel(true);
}
void assign(Conversation conversation) {
this.conversation = conversation;
eventBus.post(MEMBER_JOINED.basedOn( | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/EventContext.java
// public static EventContextBuilder builder() {
// return new EventContextBuilder();
// }
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
import lombok.Getter;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.Optional;
import java.util.concurrent.ScheduledFuture;
import static org.nextrtc.signalingserver.api.NextRTCEvents.MEMBER_JOINED;
import static org.nextrtc.signalingserver.api.NextRTCEvents.MEMBER_LEFT;
import static org.nextrtc.signalingserver.domain.EventContext.builder;
package org.nextrtc.signalingserver.domain;
@Getter
@Component
@Scope("prototype")
public class Member implements NextRTCMember {
private String id;
private Connection connection;
private Conversation conversation;
private NextRTCEventBus eventBus;
private ScheduledFuture<?> ping;
public Member(Connection connection, ScheduledFuture<?> ping) {
this.id = connection.getId();
this.connection = connection;
this.ping = ping;
}
public Optional<Conversation> getConversation() {
return Optional.ofNullable(conversation);
}
public void markLeft() {
ping.cancel(true);
}
void assign(Conversation conversation) {
this.conversation = conversation;
eventBus.post(MEMBER_JOINED.basedOn( | builder() |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/eventbus/SpringEventDispatcher.java | // Path: src/main/java/org/nextrtc/signalingserver/Names.java
// public interface Names {
// String EVENT_BUS = "nextRTCEventBus";
// String EVENT_DISPATCHER = "nextRTCEventDispatcher";
//
// String SCHEDULER_SIZE = "${nextrtc.scheduler_size:10}";
// String SCHEDULER_NAME = "nextRTCPingScheduler";
// String SCHEDULED_PERIOD = "${nextrtc.ping_period:3}";
// String MAX_CONNECTION_SETUP_TIME = "${nextrtc.max_connection_setup_time:30}";
// String JOIN_ONLY_TO_EXISTING = "${nextrtc.join_only_to_existing:false}";
//
// String DEFAULT_CONVERSATION_TYPE = "${nextrtc.default_conversation_type:MESH}";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
| import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.Names;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.annotation.NextRTCEventListener;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.Map;
import static org.springframework.core.annotation.AnnotationUtils.getValue; | package org.nextrtc.signalingserver.eventbus;
@Slf4j
@Component(Names.EVENT_DISPATCHER)
@Scope("singleton")
@NextRTCEventListener
public class SpringEventDispatcher extends AbstractEventDispatcher {
@Autowired
private ApplicationContext context;
protected Collection<Object> getNextRTCEventListeners() {
Map<String, Object> beans = context.getBeansWithAnnotation(NextRTCEventListener.class);
beans.remove(Names.EVENT_DISPATCHER);
return beans.values();
}
@Override | // Path: src/main/java/org/nextrtc/signalingserver/Names.java
// public interface Names {
// String EVENT_BUS = "nextRTCEventBus";
// String EVENT_DISPATCHER = "nextRTCEventDispatcher";
//
// String SCHEDULER_SIZE = "${nextrtc.scheduler_size:10}";
// String SCHEDULER_NAME = "nextRTCPingScheduler";
// String SCHEDULED_PERIOD = "${nextrtc.ping_period:3}";
// String MAX_CONNECTION_SETUP_TIME = "${nextrtc.max_connection_setup_time:30}";
// String JOIN_ONLY_TO_EXISTING = "${nextrtc.join_only_to_existing:false}";
//
// String DEFAULT_CONVERSATION_TYPE = "${nextrtc.default_conversation_type:MESH}";
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/eventbus/SpringEventDispatcher.java
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.Names;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.annotation.NextRTCEventListener;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.Map;
import static org.springframework.core.annotation.AnnotationUtils.getValue;
package org.nextrtc.signalingserver.eventbus;
@Slf4j
@Component(Names.EVENT_DISPATCHER)
@Scope("singleton")
@NextRTCEventListener
public class SpringEventDispatcher extends AbstractEventDispatcher {
@Autowired
private ApplicationContext context;
protected Collection<Object> getNextRTCEventListeners() {
Map<String, Object> beans = context.getBeansWithAnnotation(NextRTCEventListener.class);
beans.remove(Names.EVENT_DISPATCHER);
return beans.values();
}
@Override | protected NextRTCEvents[] getSupportedEvents(Object listener) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/cases/RegisterMember.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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/PingTask.java
// public class PingTask implements Runnable {
//
// private MessageSender sender;
// private Member to;
//
// public PingTask(Connection to, MessageSender sender) {
// this.to = new Member(to, null);
// this.sender = sender;
// }
//
// @Override
// public void run() {
// if(Thread.interrupted()){
// return;
// }
// sender.send(InternalMessage.create()//
// .to(to)//
// .signal(Signal.PING)//
// .build()//
// );
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/MemberFactory.java
// public interface MemberFactory {
// Member create(Connection connection, ScheduledFuture<?> ping);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
| import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.PingTask;
import org.nextrtc.signalingserver.factory.MemberFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import static org.nextrtc.signalingserver.api.NextRTCEvents.SESSION_OPENED; | package org.nextrtc.signalingserver.cases;
@Component
public class RegisterMember {
| // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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/PingTask.java
// public class PingTask implements Runnable {
//
// private MessageSender sender;
// private Member to;
//
// public PingTask(Connection to, MessageSender sender) {
// this.to = new Member(to, null);
// this.sender = sender;
// }
//
// @Override
// public void run() {
// if(Thread.interrupted()){
// return;
// }
// sender.send(InternalMessage.create()//
// .to(to)//
// .signal(Signal.PING)//
// .build()//
// );
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/MemberFactory.java
// public interface MemberFactory {
// Member create(Connection connection, ScheduledFuture<?> ping);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/cases/RegisterMember.java
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.PingTask;
import org.nextrtc.signalingserver.factory.MemberFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import static org.nextrtc.signalingserver.api.NextRTCEvents.SESSION_OPENED;
package org.nextrtc.signalingserver.cases;
@Component
public class RegisterMember {
| private NextRTCEventBus eventBus; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/cases/RegisterMember.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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/PingTask.java
// public class PingTask implements Runnable {
//
// private MessageSender sender;
// private Member to;
//
// public PingTask(Connection to, MessageSender sender) {
// this.to = new Member(to, null);
// this.sender = sender;
// }
//
// @Override
// public void run() {
// if(Thread.interrupted()){
// return;
// }
// sender.send(InternalMessage.create()//
// .to(to)//
// .signal(Signal.PING)//
// .build()//
// );
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/MemberFactory.java
// public interface MemberFactory {
// Member create(Connection connection, ScheduledFuture<?> ping);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
| import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.PingTask;
import org.nextrtc.signalingserver.factory.MemberFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import static org.nextrtc.signalingserver.api.NextRTCEvents.SESSION_OPENED; | package org.nextrtc.signalingserver.cases;
@Component
public class RegisterMember {
private NextRTCEventBus eventBus; | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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/PingTask.java
// public class PingTask implements Runnable {
//
// private MessageSender sender;
// private Member to;
//
// public PingTask(Connection to, MessageSender sender) {
// this.to = new Member(to, null);
// this.sender = sender;
// }
//
// @Override
// public void run() {
// if(Thread.interrupted()){
// return;
// }
// sender.send(InternalMessage.create()//
// .to(to)//
// .signal(Signal.PING)//
// .build()//
// );
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/MemberFactory.java
// public interface MemberFactory {
// Member create(Connection connection, ScheduledFuture<?> ping);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/cases/RegisterMember.java
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.PingTask;
import org.nextrtc.signalingserver.factory.MemberFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import static org.nextrtc.signalingserver.api.NextRTCEvents.SESSION_OPENED;
package org.nextrtc.signalingserver.cases;
@Component
public class RegisterMember {
private NextRTCEventBus eventBus; | private NextRTCProperties properties; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/cases/RegisterMember.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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/PingTask.java
// public class PingTask implements Runnable {
//
// private MessageSender sender;
// private Member to;
//
// public PingTask(Connection to, MessageSender sender) {
// this.to = new Member(to, null);
// this.sender = sender;
// }
//
// @Override
// public void run() {
// if(Thread.interrupted()){
// return;
// }
// sender.send(InternalMessage.create()//
// .to(to)//
// .signal(Signal.PING)//
// .build()//
// );
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/MemberFactory.java
// public interface MemberFactory {
// Member create(Connection connection, ScheduledFuture<?> ping);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
| import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.PingTask;
import org.nextrtc.signalingserver.factory.MemberFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import static org.nextrtc.signalingserver.api.NextRTCEvents.SESSION_OPENED; | package org.nextrtc.signalingserver.cases;
@Component
public class RegisterMember {
private NextRTCEventBus eventBus;
private NextRTCProperties properties; | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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/PingTask.java
// public class PingTask implements Runnable {
//
// private MessageSender sender;
// private Member to;
//
// public PingTask(Connection to, MessageSender sender) {
// this.to = new Member(to, null);
// this.sender = sender;
// }
//
// @Override
// public void run() {
// if(Thread.interrupted()){
// return;
// }
// sender.send(InternalMessage.create()//
// .to(to)//
// .signal(Signal.PING)//
// .build()//
// );
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/MemberFactory.java
// public interface MemberFactory {
// Member create(Connection connection, ScheduledFuture<?> ping);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/cases/RegisterMember.java
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.PingTask;
import org.nextrtc.signalingserver.factory.MemberFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import static org.nextrtc.signalingserver.api.NextRTCEvents.SESSION_OPENED;
package org.nextrtc.signalingserver.cases;
@Component
public class RegisterMember {
private NextRTCEventBus eventBus;
private NextRTCProperties properties; | private MemberRepository members; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/cases/RegisterMember.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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/PingTask.java
// public class PingTask implements Runnable {
//
// private MessageSender sender;
// private Member to;
//
// public PingTask(Connection to, MessageSender sender) {
// this.to = new Member(to, null);
// this.sender = sender;
// }
//
// @Override
// public void run() {
// if(Thread.interrupted()){
// return;
// }
// sender.send(InternalMessage.create()//
// .to(to)//
// .signal(Signal.PING)//
// .build()//
// );
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/MemberFactory.java
// public interface MemberFactory {
// Member create(Connection connection, ScheduledFuture<?> ping);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
| import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.PingTask;
import org.nextrtc.signalingserver.factory.MemberFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import static org.nextrtc.signalingserver.api.NextRTCEvents.SESSION_OPENED; | package org.nextrtc.signalingserver.cases;
@Component
public class RegisterMember {
private NextRTCEventBus eventBus;
private NextRTCProperties properties;
private MemberRepository members;
private ScheduledExecutorService scheduler; | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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/PingTask.java
// public class PingTask implements Runnable {
//
// private MessageSender sender;
// private Member to;
//
// public PingTask(Connection to, MessageSender sender) {
// this.to = new Member(to, null);
// this.sender = sender;
// }
//
// @Override
// public void run() {
// if(Thread.interrupted()){
// return;
// }
// sender.send(InternalMessage.create()//
// .to(to)//
// .signal(Signal.PING)//
// .build()//
// );
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/MemberFactory.java
// public interface MemberFactory {
// Member create(Connection connection, ScheduledFuture<?> ping);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/cases/RegisterMember.java
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.PingTask;
import org.nextrtc.signalingserver.factory.MemberFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import static org.nextrtc.signalingserver.api.NextRTCEvents.SESSION_OPENED;
package org.nextrtc.signalingserver.cases;
@Component
public class RegisterMember {
private NextRTCEventBus eventBus;
private NextRTCProperties properties;
private MemberRepository members;
private ScheduledExecutorService scheduler; | private MemberFactory factory; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/cases/RegisterMember.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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/PingTask.java
// public class PingTask implements Runnable {
//
// private MessageSender sender;
// private Member to;
//
// public PingTask(Connection to, MessageSender sender) {
// this.to = new Member(to, null);
// this.sender = sender;
// }
//
// @Override
// public void run() {
// if(Thread.interrupted()){
// return;
// }
// sender.send(InternalMessage.create()//
// .to(to)//
// .signal(Signal.PING)//
// .build()//
// );
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/MemberFactory.java
// public interface MemberFactory {
// Member create(Connection connection, ScheduledFuture<?> ping);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
| import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.PingTask;
import org.nextrtc.signalingserver.factory.MemberFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import static org.nextrtc.signalingserver.api.NextRTCEvents.SESSION_OPENED; | package org.nextrtc.signalingserver.cases;
@Component
public class RegisterMember {
private NextRTCEventBus eventBus;
private NextRTCProperties properties;
private MemberRepository members;
private ScheduledExecutorService scheduler;
private MemberFactory factory; | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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/PingTask.java
// public class PingTask implements Runnable {
//
// private MessageSender sender;
// private Member to;
//
// public PingTask(Connection to, MessageSender sender) {
// this.to = new Member(to, null);
// this.sender = sender;
// }
//
// @Override
// public void run() {
// if(Thread.interrupted()){
// return;
// }
// sender.send(InternalMessage.create()//
// .to(to)//
// .signal(Signal.PING)//
// .build()//
// );
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/MemberFactory.java
// public interface MemberFactory {
// Member create(Connection connection, ScheduledFuture<?> ping);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/cases/RegisterMember.java
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.nextrtc.signalingserver.domain.PingTask;
import org.nextrtc.signalingserver.factory.MemberFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import static org.nextrtc.signalingserver.api.NextRTCEvents.SESSION_OPENED;
package org.nextrtc.signalingserver.cases;
@Component
public class RegisterMember {
private NextRTCEventBus eventBus;
private NextRTCProperties properties;
private MemberRepository members;
private ScheduledExecutorService scheduler;
private MemberFactory factory; | private MessageSender sender; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/property/SpringNextRTCProperties.java | // Path: src/main/java/org/nextrtc/signalingserver/Names.java
// public interface Names {
// String EVENT_BUS = "nextRTCEventBus";
// String EVENT_DISPATCHER = "nextRTCEventDispatcher";
//
// String SCHEDULER_SIZE = "${nextrtc.scheduler_size:10}";
// String SCHEDULER_NAME = "nextRTCPingScheduler";
// String SCHEDULED_PERIOD = "${nextrtc.ping_period:3}";
// String MAX_CONNECTION_SETUP_TIME = "${nextrtc.max_connection_setup_time:30}";
// String JOIN_ONLY_TO_EXISTING = "${nextrtc.join_only_to_existing:false}";
//
// String DEFAULT_CONVERSATION_TYPE = "${nextrtc.default_conversation_type:MESH}";
// }
| import lombok.Getter;
import org.nextrtc.signalingserver.Names;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; | package org.nextrtc.signalingserver.property;
@Getter
@Component
public class SpringNextRTCProperties implements NextRTCProperties {
| // Path: src/main/java/org/nextrtc/signalingserver/Names.java
// public interface Names {
// String EVENT_BUS = "nextRTCEventBus";
// String EVENT_DISPATCHER = "nextRTCEventDispatcher";
//
// String SCHEDULER_SIZE = "${nextrtc.scheduler_size:10}";
// String SCHEDULER_NAME = "nextRTCPingScheduler";
// String SCHEDULED_PERIOD = "${nextrtc.ping_period:3}";
// String MAX_CONNECTION_SETUP_TIME = "${nextrtc.max_connection_setup_time:30}";
// String JOIN_ONLY_TO_EXISTING = "${nextrtc.join_only_to_existing:false}";
//
// String DEFAULT_CONVERSATION_TYPE = "${nextrtc.default_conversation_type:MESH}";
// }
// Path: src/main/java/org/nextrtc/signalingserver/property/SpringNextRTCProperties.java
import lombok.Getter;
import org.nextrtc.signalingserver.Names;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
package org.nextrtc.signalingserver.property;
@Getter
@Component
public class SpringNextRTCProperties implements NextRTCProperties {
| @Value(Names.MAX_CONNECTION_SETUP_TIME) |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/EventContext.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCConversation.java
// public interface NextRTCConversation extends Closeable {
// String getId();
//
// NextRTCMember getCreator();
//
// Set<NextRTCMember> getMembers();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/exception/SignalingException.java
// public class SignalingException extends RuntimeException {
//
// private static final long serialVersionUID = 4171073365651049929L;
//
// private String customMessage;
//
// public SignalingException(Exceptions exception) {
// super(exception.name());
// }
//
// public SignalingException(Exceptions exception, Throwable t) {
// super(exception.name(), t);
// }
//
// public SignalingException(Exceptions exception, String customMessage) {
// super(exception.name());
// this.customMessage = customMessage;
// }
//
//
// public String getCustomMessage() {
// return StringUtils.defaultString(customMessage);
// }
//
// public void throwException() {
// throw this;
// }
//
// @Override
// public String toString() {
// return format("Signaling Exception %s [%s]", getMessage(), getCustomMessage());
// }
//
// }
| import com.google.common.collect.Maps;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.dto.NextRTCConversation;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.exception.SignalingException;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Optional;
import static java.util.Collections.unmodifiableMap;
import static java.util.Optional.ofNullable;
import static org.apache.commons.lang3.StringUtils.defaultString; | package org.nextrtc.signalingserver.domain;
public class EventContext implements NextRTCEvent {
private final NextRTCEvents type;
private final ZonedDateTime published = ZonedDateTime.now();
private final Map<String, String> custom = Maps.newHashMap(); | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCConversation.java
// public interface NextRTCConversation extends Closeable {
// String getId();
//
// NextRTCMember getCreator();
//
// Set<NextRTCMember> getMembers();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/exception/SignalingException.java
// public class SignalingException extends RuntimeException {
//
// private static final long serialVersionUID = 4171073365651049929L;
//
// private String customMessage;
//
// public SignalingException(Exceptions exception) {
// super(exception.name());
// }
//
// public SignalingException(Exceptions exception, Throwable t) {
// super(exception.name(), t);
// }
//
// public SignalingException(Exceptions exception, String customMessage) {
// super(exception.name());
// this.customMessage = customMessage;
// }
//
//
// public String getCustomMessage() {
// return StringUtils.defaultString(customMessage);
// }
//
// public void throwException() {
// throw this;
// }
//
// @Override
// public String toString() {
// return format("Signaling Exception %s [%s]", getMessage(), getCustomMessage());
// }
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/domain/EventContext.java
import com.google.common.collect.Maps;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.dto.NextRTCConversation;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.exception.SignalingException;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Optional;
import static java.util.Collections.unmodifiableMap;
import static java.util.Optional.ofNullable;
import static org.apache.commons.lang3.StringUtils.defaultString;
package org.nextrtc.signalingserver.domain;
public class EventContext implements NextRTCEvent {
private final NextRTCEvents type;
private final ZonedDateTime published = ZonedDateTime.now();
private final Map<String, String> custom = Maps.newHashMap(); | private final NextRTCMember from; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/EventContext.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCConversation.java
// public interface NextRTCConversation extends Closeable {
// String getId();
//
// NextRTCMember getCreator();
//
// Set<NextRTCMember> getMembers();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/exception/SignalingException.java
// public class SignalingException extends RuntimeException {
//
// private static final long serialVersionUID = 4171073365651049929L;
//
// private String customMessage;
//
// public SignalingException(Exceptions exception) {
// super(exception.name());
// }
//
// public SignalingException(Exceptions exception, Throwable t) {
// super(exception.name(), t);
// }
//
// public SignalingException(Exceptions exception, String customMessage) {
// super(exception.name());
// this.customMessage = customMessage;
// }
//
//
// public String getCustomMessage() {
// return StringUtils.defaultString(customMessage);
// }
//
// public void throwException() {
// throw this;
// }
//
// @Override
// public String toString() {
// return format("Signaling Exception %s [%s]", getMessage(), getCustomMessage());
// }
//
// }
| import com.google.common.collect.Maps;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.dto.NextRTCConversation;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.exception.SignalingException;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Optional;
import static java.util.Collections.unmodifiableMap;
import static java.util.Optional.ofNullable;
import static org.apache.commons.lang3.StringUtils.defaultString; | package org.nextrtc.signalingserver.domain;
public class EventContext implements NextRTCEvent {
private final NextRTCEvents type;
private final ZonedDateTime published = ZonedDateTime.now();
private final Map<String, String> custom = Maps.newHashMap();
private final NextRTCMember from;
private final NextRTCMember to; | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCConversation.java
// public interface NextRTCConversation extends Closeable {
// String getId();
//
// NextRTCMember getCreator();
//
// Set<NextRTCMember> getMembers();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/exception/SignalingException.java
// public class SignalingException extends RuntimeException {
//
// private static final long serialVersionUID = 4171073365651049929L;
//
// private String customMessage;
//
// public SignalingException(Exceptions exception) {
// super(exception.name());
// }
//
// public SignalingException(Exceptions exception, Throwable t) {
// super(exception.name(), t);
// }
//
// public SignalingException(Exceptions exception, String customMessage) {
// super(exception.name());
// this.customMessage = customMessage;
// }
//
//
// public String getCustomMessage() {
// return StringUtils.defaultString(customMessage);
// }
//
// public void throwException() {
// throw this;
// }
//
// @Override
// public String toString() {
// return format("Signaling Exception %s [%s]", getMessage(), getCustomMessage());
// }
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/domain/EventContext.java
import com.google.common.collect.Maps;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.dto.NextRTCConversation;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.exception.SignalingException;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Optional;
import static java.util.Collections.unmodifiableMap;
import static java.util.Optional.ofNullable;
import static org.apache.commons.lang3.StringUtils.defaultString;
package org.nextrtc.signalingserver.domain;
public class EventContext implements NextRTCEvent {
private final NextRTCEvents type;
private final ZonedDateTime published = ZonedDateTime.now();
private final Map<String, String> custom = Maps.newHashMap();
private final NextRTCMember from;
private final NextRTCMember to; | private final NextRTCConversation conversation; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/EventContext.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCConversation.java
// public interface NextRTCConversation extends Closeable {
// String getId();
//
// NextRTCMember getCreator();
//
// Set<NextRTCMember> getMembers();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/exception/SignalingException.java
// public class SignalingException extends RuntimeException {
//
// private static final long serialVersionUID = 4171073365651049929L;
//
// private String customMessage;
//
// public SignalingException(Exceptions exception) {
// super(exception.name());
// }
//
// public SignalingException(Exceptions exception, Throwable t) {
// super(exception.name(), t);
// }
//
// public SignalingException(Exceptions exception, String customMessage) {
// super(exception.name());
// this.customMessage = customMessage;
// }
//
//
// public String getCustomMessage() {
// return StringUtils.defaultString(customMessage);
// }
//
// public void throwException() {
// throw this;
// }
//
// @Override
// public String toString() {
// return format("Signaling Exception %s [%s]", getMessage(), getCustomMessage());
// }
//
// }
| import com.google.common.collect.Maps;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.dto.NextRTCConversation;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.exception.SignalingException;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Optional;
import static java.util.Collections.unmodifiableMap;
import static java.util.Optional.ofNullable;
import static org.apache.commons.lang3.StringUtils.defaultString; | package org.nextrtc.signalingserver.domain;
public class EventContext implements NextRTCEvent {
private final NextRTCEvents type;
private final ZonedDateTime published = ZonedDateTime.now();
private final Map<String, String> custom = Maps.newHashMap();
private final NextRTCMember from;
private final NextRTCMember to;
private final NextRTCConversation conversation; | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCConversation.java
// public interface NextRTCConversation extends Closeable {
// String getId();
//
// NextRTCMember getCreator();
//
// Set<NextRTCMember> getMembers();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
// public interface NextRTCMember {
// default String getId() {
// return getConnection().getId();
// }
//
// Connection getConnection();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/exception/SignalingException.java
// public class SignalingException extends RuntimeException {
//
// private static final long serialVersionUID = 4171073365651049929L;
//
// private String customMessage;
//
// public SignalingException(Exceptions exception) {
// super(exception.name());
// }
//
// public SignalingException(Exceptions exception, Throwable t) {
// super(exception.name(), t);
// }
//
// public SignalingException(Exceptions exception, String customMessage) {
// super(exception.name());
// this.customMessage = customMessage;
// }
//
//
// public String getCustomMessage() {
// return StringUtils.defaultString(customMessage);
// }
//
// public void throwException() {
// throw this;
// }
//
// @Override
// public String toString() {
// return format("Signaling Exception %s [%s]", getMessage(), getCustomMessage());
// }
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/domain/EventContext.java
import com.google.common.collect.Maps;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.dto.NextRTCConversation;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import org.nextrtc.signalingserver.api.dto.NextRTCMember;
import org.nextrtc.signalingserver.exception.SignalingException;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Optional;
import static java.util.Collections.unmodifiableMap;
import static java.util.Optional.ofNullable;
import static org.apache.commons.lang3.StringUtils.defaultString;
package org.nextrtc.signalingserver.domain;
public class EventContext implements NextRTCEvent {
private final NextRTCEvents type;
private final ZonedDateTime published = ZonedDateTime.now();
private final Map<String, String> custom = Maps.newHashMap();
private final NextRTCMember from;
private final NextRTCMember to;
private final NextRTCConversation conversation; | private final SignalingException exception; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/eventbus/AbstractEventDispatcher.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
| import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import java.util.Collection; | package org.nextrtc.signalingserver.eventbus;
@Slf4j
public abstract class AbstractEventDispatcher implements EventDispatcher {
@Override
@Subscribe
@AllowConcurrentEvents | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/eventbus/AbstractEventDispatcher.java
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import java.util.Collection;
package org.nextrtc.signalingserver.eventbus;
@Slf4j
public abstract class AbstractEventDispatcher implements EventDispatcher {
@Override
@Subscribe
@AllowConcurrentEvents | public void handle(NextRTCEvent event) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/eventbus/AbstractEventDispatcher.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
| import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import java.util.Collection; | package org.nextrtc.signalingserver.eventbus;
@Slf4j
public abstract class AbstractEventDispatcher implements EventDispatcher {
@Override
@Subscribe
@AllowConcurrentEvents
public void handle(NextRTCEvent event) {
getNextRTCEventListeners().parallelStream()
.filter(listener -> isNextRTCHandler(listener) && supportsCurrentEvent(listener, event)) | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/eventbus/AbstractEventDispatcher.java
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import java.util.Collection;
package org.nextrtc.signalingserver.eventbus;
@Slf4j
public abstract class AbstractEventDispatcher implements EventDispatcher {
@Override
@Subscribe
@AllowConcurrentEvents
public void handle(NextRTCEvent event) {
getNextRTCEventListeners().parallelStream()
.filter(listener -> isNextRTCHandler(listener) && supportsCurrentEvent(listener, event)) | .forEach(listener -> doTry(() -> ((NextRTCHandler) listener).handleEvent(event))); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/eventbus/AbstractEventDispatcher.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
| import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import java.util.Collection; | package org.nextrtc.signalingserver.eventbus;
@Slf4j
public abstract class AbstractEventDispatcher implements EventDispatcher {
@Override
@Subscribe
@AllowConcurrentEvents
public void handle(NextRTCEvent event) {
getNextRTCEventListeners().parallelStream()
.filter(listener -> isNextRTCHandler(listener) && supportsCurrentEvent(listener, event))
.forEach(listener -> doTry(() -> ((NextRTCHandler) listener).handleEvent(event)));
}
protected abstract Collection<Object> getNextRTCEventListeners();
private void doTry(Runnable action) {
try {
action.run();
} catch (Exception e) {
log.error("Handler throws an exception", e);
}
}
private boolean isNextRTCHandler(Object listener) {
return listener instanceof NextRTCHandler;
}
private boolean supportsCurrentEvent(Object listener, NextRTCEvent event) { | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEvents.java
// public enum NextRTCEvents {
// SESSION_OPENED,
// SESSION_CLOSED,
// CONVERSATION_CREATED,
// CONVERSATION_DESTROYED,
// UNEXPECTED_SITUATION,
// MEMBER_JOINED,
// MEMBER_LEFT,
// MEDIA_LOCAL_STREAM_REQUESTED,
// MEDIA_LOCAL_STREAM_CREATED,
// MEDIA_STREAMING,
// TEXT,
// MESSAGE;
//
// public NextRTCEvent basedOn(InternalMessage message, Conversation conversation) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .conversation(conversation)
// .type(this)
// .build();
// }
//
// public NextRTCEvent basedOn(EventContext.EventContextBuilder builder) {
// return builder
// .type(this)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection, String reason) {
// return EventContext.builder()
// .from(new InternalMember(connection))
// .type(this)
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .content(reason)
// .build();
// }
//
// public NextRTCEvent occurFor(Connection connection) {
// return EventContext.builder()
// .type(this)
// .from(new InternalMember(connection))
// .exception(Exceptions.UNKNOWN_ERROR.exception())
// .build();
// }
//
// public NextRTCEvent basedOn(InternalMessage message) {
// return EventContext.builder()
// .from(message.getFrom())
// .to(message.getTo())
// .custom(message.getCustom())
// .content(message.getContent())
// .conversation(message.getFrom().getConversation().orElse(null))
// .type(this)
// .build();
// }
//
// private static class InternalMember implements NextRTCMember {
//
// private final Connection connection;
//
// InternalMember(Connection connection) {
// this.connection = connection;
// }
//
// @Override
// public Connection getConnection() {
// return connection;
// }
//
// @Override
// public String getId() {
// if (connection == null) {
// return null;
// }
// return connection.getId();
// }
//
// @Override
// public String toString() {
// return getId();
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/eventbus/AbstractEventDispatcher.java
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.api.NextRTCEvents;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import java.util.Collection;
package org.nextrtc.signalingserver.eventbus;
@Slf4j
public abstract class AbstractEventDispatcher implements EventDispatcher {
@Override
@Subscribe
@AllowConcurrentEvents
public void handle(NextRTCEvent event) {
getNextRTCEventListeners().parallelStream()
.filter(listener -> isNextRTCHandler(listener) && supportsCurrentEvent(listener, event))
.forEach(listener -> doTry(() -> ((NextRTCHandler) listener).handleEvent(event)));
}
protected abstract Collection<Object> getNextRTCEventListeners();
private void doTry(Runnable action) {
try {
action.run();
} catch (Exception e) {
log.error("Handler throws an exception", e);
}
}
private boolean isNextRTCHandler(Object listener) {
return listener instanceof NextRTCHandler;
}
private boolean supportsCurrentEvent(Object listener, NextRTCEvent event) { | NextRTCEvents[] events = getSupportedEvents(listener); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/resolver/SpringSignalResolver.java | // Path: src/main/java/org/nextrtc/signalingserver/cases/SignalHandler.java
// public interface SignalHandler {
// void execute(InternalMessage message);
// }
| import org.nextrtc.signalingserver.cases.SignalHandler;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.Map; | package org.nextrtc.signalingserver.domain.resolver;
@Component
@Scope("singleton")
public class SpringSignalResolver extends AbstractSignalResolver implements InitializingBean {
@Autowired | // Path: src/main/java/org/nextrtc/signalingserver/cases/SignalHandler.java
// public interface SignalHandler {
// void execute(InternalMessage message);
// }
// Path: src/main/java/org/nextrtc/signalingserver/domain/resolver/SpringSignalResolver.java
import org.nextrtc.signalingserver.cases.SignalHandler;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.Map;
package org.nextrtc.signalingserver.domain.resolver;
@Component
@Scope("singleton")
public class SpringSignalResolver extends AbstractSignalResolver implements InitializingBean {
@Autowired | public SpringSignalResolver(Map<String, SignalHandler> handlers) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/conversation/MeshWithMasterConversation.java | // 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/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.HashSet; | package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public class MeshWithMasterConversation extends AbstractMeshConversation { | // 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/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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/MeshWithMasterConversation.java
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.HashSet;
package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public class MeshWithMasterConversation extends AbstractMeshConversation { | private Member owner; |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/conversation/MeshWithMasterConversation.java | // 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/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.HashSet; | package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public class MeshWithMasterConversation extends AbstractMeshConversation {
private Member owner;
public MeshWithMasterConversation(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/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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/MeshWithMasterConversation.java
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.HashSet;
package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public class MeshWithMasterConversation extends AbstractMeshConversation {
private Member owner;
public MeshWithMasterConversation(String id) {
super(id);
}
| public MeshWithMasterConversation(String id, LeftConversation left, MessageSender sender, ExchangeSignalsBetweenMembers exchange) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/conversation/MeshWithMasterConversation.java | // 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/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.HashSet; | package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public class MeshWithMasterConversation extends AbstractMeshConversation {
private Member owner;
public MeshWithMasterConversation(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/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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/MeshWithMasterConversation.java
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.HashSet;
package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public class MeshWithMasterConversation extends AbstractMeshConversation {
private Member owner;
public MeshWithMasterConversation(String id) {
super(id);
}
| public MeshWithMasterConversation(String id, LeftConversation left, MessageSender sender, ExchangeSignalsBetweenMembers exchange) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/conversation/MeshWithMasterConversation.java | // 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/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.HashSet; | package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public class MeshWithMasterConversation extends AbstractMeshConversation {
private Member owner;
public MeshWithMasterConversation(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/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
//
// 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/MeshWithMasterConversation.java
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.nextrtc.signalingserver.domain.Member;
import org.nextrtc.signalingserver.domain.MessageSender;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.HashSet;
package org.nextrtc.signalingserver.domain.conversation;
@Component
@Scope("prototype")
public class MeshWithMasterConversation extends AbstractMeshConversation {
private Member owner;
public MeshWithMasterConversation(String id) {
super(id);
}
| public MeshWithMasterConversation(String id, LeftConversation left, MessageSender sender, ExchangeSignalsBetweenMembers exchange) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/factory/ManualMemberFactory.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
| import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import javax.inject.Inject;
import java.util.concurrent.ScheduledFuture; | package org.nextrtc.signalingserver.factory;
public class ManualMemberFactory implements MemberFactory {
private NextRTCEventBus eventBus;
@Inject
public ManualMemberFactory(NextRTCEventBus eventBus) {
this.eventBus = eventBus;
}
@Override | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/factory/ManualMemberFactory.java
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import javax.inject.Inject;
import java.util.concurrent.ScheduledFuture;
package org.nextrtc.signalingserver.factory;
public class ManualMemberFactory implements MemberFactory {
private NextRTCEventBus eventBus;
@Inject
public ManualMemberFactory(NextRTCEventBus eventBus) {
this.eventBus = eventBus;
}
@Override | public Member create(Connection connection, ScheduledFuture<?> ping) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/factory/ManualMemberFactory.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
| import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import javax.inject.Inject;
import java.util.concurrent.ScheduledFuture; | package org.nextrtc.signalingserver.factory;
public class ManualMemberFactory implements MemberFactory {
private NextRTCEventBus eventBus;
@Inject
public ManualMemberFactory(NextRTCEventBus eventBus) {
this.eventBus = eventBus;
}
@Override | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/factory/ManualMemberFactory.java
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.nextrtc.signalingserver.domain.Connection;
import org.nextrtc.signalingserver.domain.Member;
import javax.inject.Inject;
import java.util.concurrent.ScheduledFuture;
package org.nextrtc.signalingserver.factory;
public class ManualMemberFactory implements MemberFactory {
private NextRTCEventBus eventBus;
@Inject
public ManualMemberFactory(NextRTCEventBus eventBus) {
this.eventBus = eventBus;
}
@Override | public Member create(Connection connection, ScheduledFuture<?> ping) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/Conversation.java | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCConversation.java
// public interface NextRTCConversation extends Closeable {
// String getId();
//
// NextRTCMember getCreator();
//
// Set<NextRTCMember> getMembers();
// }
//
// 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();
// }
//
// }
| import lombok.Getter;
import org.nextrtc.signalingserver.api.dto.NextRTCConversation;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; | package org.nextrtc.signalingserver.domain;
@Getter
@Component
@Scope("prototype") | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCConversation.java
// public interface NextRTCConversation extends Closeable {
// String getId();
//
// NextRTCMember getCreator();
//
// Set<NextRTCMember> getMembers();
// }
//
// 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/Conversation.java
import lombok.Getter;
import org.nextrtc.signalingserver.api.dto.NextRTCConversation;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
package org.nextrtc.signalingserver.domain;
@Getter
@Component
@Scope("prototype") | public abstract class Conversation implements NextRTCConversation { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/Conversation.java | // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCConversation.java
// public interface NextRTCConversation extends Closeable {
// String getId();
//
// NextRTCMember getCreator();
//
// Set<NextRTCMember> getMembers();
// }
//
// 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();
// }
//
// }
| import lombok.Getter;
import org.nextrtc.signalingserver.api.dto.NextRTCConversation;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; | package org.nextrtc.signalingserver.domain;
@Getter
@Component
@Scope("prototype")
public abstract class Conversation implements NextRTCConversation {
protected static final ExecutorService parallel = Executors.newCachedThreadPool();
protected final String id;
| // Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCConversation.java
// public interface NextRTCConversation extends Closeable {
// String getId();
//
// NextRTCMember getCreator();
//
// Set<NextRTCMember> getMembers();
// }
//
// 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/Conversation.java
import lombok.Getter;
import org.nextrtc.signalingserver.api.dto.NextRTCConversation;
import org.nextrtc.signalingserver.cases.LeftConversation;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
package org.nextrtc.signalingserver.domain;
@Getter
@Component
@Scope("prototype")
public abstract class Conversation implements NextRTCConversation {
protected static final ExecutorService parallel = Executors.newCachedThreadPool();
protected final String id;
| private LeftConversation leftConversation; |
mslosarz/nextrtc-signaling-server | src/test/java/org/nextrtc/signalingserver/TestConfig.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
| import org.mockito.Answers;
import org.mockito.Mockito;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.springframework.context.annotation.*;
import java.util.concurrent.ScheduledExecutorService; | package org.nextrtc.signalingserver;
@Configuration
@ComponentScan(basePackages = "org.nextrtc.signalingserver")
@PropertySource("classpath:nextrtc.properties")
public class TestConfig {
@Primary
@Bean(name = Names.EVENT_BUS) | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCEventBus.java
// @Slf4j
// @Service(Names.EVENT_BUS)
// @Scope("singleton")
// public class NextRTCEventBus {
// private EventBus eventBus;
//
// public NextRTCEventBus() {
// this.eventBus = new EventBus();
// }
//
// public void post(NextRTCEvent event) {
// if (event.type() != NextRTCEvents.MESSAGE) {
// log.info("POSTED EVENT: " + event);
// }
// eventBus.post(event);
// }
//
// @Deprecated
// public void post(Object o) {
// eventBus.post(o);
// }
//
// public void register(Object listeners) {
// log.info("REGISTERED LISTENER: " + listeners);
// eventBus.register(listeners);
// }
//
// }
// Path: src/test/java/org/nextrtc/signalingserver/TestConfig.java
import org.mockito.Answers;
import org.mockito.Mockito;
import org.nextrtc.signalingserver.api.NextRTCEventBus;
import org.springframework.context.annotation.*;
import java.util.concurrent.ScheduledExecutorService;
package org.nextrtc.signalingserver;
@Configuration
@ComponentScan(basePackages = "org.nextrtc.signalingserver")
@PropertySource("classpath:nextrtc.properties")
public class TestConfig {
@Primary
@Bean(name = Names.EVENT_BUS) | public NextRTCEventBus eventBus() { |
mslosarz/nextrtc-signaling-server | src/test/java/org/nextrtc/signalingserver/EventChecker.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
| import com.google.common.collect.Lists;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.List; | package org.nextrtc.signalingserver;
@Component
@Scope("prototype") | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
// Path: src/test/java/org/nextrtc/signalingserver/EventChecker.java
import com.google.common.collect.Lists;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.List;
package org.nextrtc.signalingserver;
@Component
@Scope("prototype") | public class EventChecker implements NextRTCHandler { |
mslosarz/nextrtc-signaling-server | src/test/java/org/nextrtc/signalingserver/EventChecker.java | // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
| import com.google.common.collect.Lists;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.List; | package org.nextrtc.signalingserver;
@Component
@Scope("prototype")
public class EventChecker implements NextRTCHandler {
| // Path: src/main/java/org/nextrtc/signalingserver/api/NextRTCHandler.java
// public interface NextRTCHandler {
//
// void handleEvent(NextRTCEvent event);
//
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCEvent.java
// public interface NextRTCEvent {
//
// NextRTCEvents type();
//
// ZonedDateTime published();
//
// Optional<NextRTCMember> from();
//
// Optional<NextRTCMember> to();
//
// Optional<NextRTCConversation> conversation();
//
// Optional<SignalingException> exception();
//
// Map<String, String> custom();
//
// String content();
//
// }
// Path: src/test/java/org/nextrtc/signalingserver/EventChecker.java
import com.google.common.collect.Lists;
import org.nextrtc.signalingserver.api.NextRTCHandler;
import org.nextrtc.signalingserver.api.dto.NextRTCEvent;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.List;
package org.nextrtc.signalingserver;
@Component
@Scope("prototype")
public class EventChecker implements NextRTCHandler {
| List<NextRTCEvent> events = Lists.newArrayList(); |
mslosarz/nextrtc-signaling-server | src/test/java/org/nextrtc/signalingserver/api/DecoderTest.java | // Path: src/main/java/org/nextrtc/signalingserver/domain/Message.java
// @Getter
// @Builder(builderMethodName = "create")
// @AllArgsConstructor(access = AccessLevel.PRIVATE)
// public class Message {
// /**
// * Use Message.create(...) instead of new Message()
// */
// @Deprecated
// Message() {
// }
//
// @Expose
// private String from = EMPTY;
//
// @Expose
// private String to = EMPTY;
//
// @Expose
// private String signal = EMPTY;
//
// @Expose
// private String content = EMPTY;
//
// @Expose
// private Map<String, String> custom = Maps.newHashMap();
//
// @Override
// public String toString() {
// return String.format("(%s -> %s)[%s]: %s |%s", from, to, signal, content, custom);
// }
// }
| import org.junit.Test;
import org.nextrtc.signalingserver.domain.Message;
import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat; | package org.nextrtc.signalingserver.api;
public class DecoderTest {
private NextRTCServer.MessageDecoder decoder = new NextRTCServer.MessageDecoder();
@Test
public void shouldParseBasicObject() {
// given
String validJson = "{'from' : 'Alice',"//
+ "'to' : 'Bob',"//
+ "'signal' : 'join',"//
+ "'content' : 'something'}";
// when | // Path: src/main/java/org/nextrtc/signalingserver/domain/Message.java
// @Getter
// @Builder(builderMethodName = "create")
// @AllArgsConstructor(access = AccessLevel.PRIVATE)
// public class Message {
// /**
// * Use Message.create(...) instead of new Message()
// */
// @Deprecated
// Message() {
// }
//
// @Expose
// private String from = EMPTY;
//
// @Expose
// private String to = EMPTY;
//
// @Expose
// private String signal = EMPTY;
//
// @Expose
// private String content = EMPTY;
//
// @Expose
// private Map<String, String> custom = Maps.newHashMap();
//
// @Override
// public String toString() {
// return String.format("(%s -> %s)[%s]: %s |%s", from, to, signal, content, custom);
// }
// }
// Path: src/test/java/org/nextrtc/signalingserver/api/DecoderTest.java
import org.junit.Test;
import org.nextrtc.signalingserver.domain.Message;
import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
package org.nextrtc.signalingserver.api;
public class DecoderTest {
private NextRTCServer.MessageDecoder decoder = new NextRTCServer.MessageDecoder();
@Test
public void shouldParseBasicObject() {
// given
String validJson = "{'from' : 'Alice',"//
+ "'to' : 'Bob',"//
+ "'signal' : 'join',"//
+ "'content' : 'something'}";
// when | Message result = decoder.decode(validJson); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/DefaultMessageSender.java | // Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
| import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject; | package org.nextrtc.signalingserver.domain;
@Component
@Scope("singleton")
@Slf4j
public class DefaultMessageSender implements MessageSender {
| // Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/domain/DefaultMessageSender.java
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.repository.MemberRepository;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
package org.nextrtc.signalingserver.domain;
@Component
@Scope("singleton")
@Slf4j
public class DefaultMessageSender implements MessageSender {
| private MemberRepository members; |
GoogleContainerTools/jib-extensions | first-party/jib-native-image-extension-maven/src/main/java/com/google/cloud/tools/jib/maven/extension/nativeimage/JibNativeImageExtension.java | // Path: first-party/jib-native-image-extension-maven/src/main/java/com/google/cloud/tools/jib/maven/extension/nativeimage/ConfigValueLocation.java
// static enum ValueContainer {
// CONFIGURATION,
// EXECUTIONS
// }
| import com.google.cloud.tools.jib.api.JavaContainerBuilder;
import com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath;
import com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan;
import com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer;
import com.google.cloud.tools.jib.api.buildplan.FilePermissions;
import com.google.cloud.tools.jib.maven.extension.JibMavenPluginExtension;
import com.google.cloud.tools.jib.maven.extension.MavenData;
import com.google.cloud.tools.jib.maven.extension.nativeimage.ConfigValueLocation.ValueContainer;
import com.google.cloud.tools.jib.plugins.extension.ExtensionLogger;
import com.google.cloud.tools.jib.plugins.extension.ExtensionLogger.LogLevel;
import com.google.cloud.tools.jib.plugins.extension.JibPluginExtensionException;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;
import org.apache.maven.model.Plugin;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.xml.Xpp3Dom; | /*
* Copyright 2020 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.cloud.tools.jib.maven.extension.nativeimage;
public class JibNativeImageExtension implements JibMavenPluginExtension<Void> {
private static final ConfigValueLocation JIB_APP_ROOT =
new ConfigValueLocation(
"com.google.cloud.tools:jib-maven-plugin", | // Path: first-party/jib-native-image-extension-maven/src/main/java/com/google/cloud/tools/jib/maven/extension/nativeimage/ConfigValueLocation.java
// static enum ValueContainer {
// CONFIGURATION,
// EXECUTIONS
// }
// Path: first-party/jib-native-image-extension-maven/src/main/java/com/google/cloud/tools/jib/maven/extension/nativeimage/JibNativeImageExtension.java
import com.google.cloud.tools.jib.api.JavaContainerBuilder;
import com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath;
import com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan;
import com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer;
import com.google.cloud.tools.jib.api.buildplan.FilePermissions;
import com.google.cloud.tools.jib.maven.extension.JibMavenPluginExtension;
import com.google.cloud.tools.jib.maven.extension.MavenData;
import com.google.cloud.tools.jib.maven.extension.nativeimage.ConfigValueLocation.ValueContainer;
import com.google.cloud.tools.jib.plugins.extension.ExtensionLogger;
import com.google.cloud.tools.jib.plugins.extension.ExtensionLogger.LogLevel;
import com.google.cloud.tools.jib.plugins.extension.JibPluginExtensionException;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;
import org.apache.maven.model.Plugin;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/*
* Copyright 2020 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.cloud.tools.jib.maven.extension.nativeimage;
public class JibNativeImageExtension implements JibMavenPluginExtension<Void> {
private static final ConfigValueLocation JIB_APP_ROOT =
new ConfigValueLocation(
"com.google.cloud.tools:jib-maven-plugin", | ValueContainer.CONFIGURATION, |
easyJsonApi/easyJsonApi | src/test/java/com/github/easyjsonapi/entities/DataTest.java | // Path: src/main/java/com/github/easyjsonapi/entities/Data.java
// public final class Data implements Cloneable {
//
// @SerializedName(value = "attributes")
// private final Object attr;
//
// @SerializedName(value = "id")
// private final String id;
//
// // @SerializedName(value = "links")
// // private final Object links;
//
// @SerializedName(value = "relationships")
// private Relationships rels;
//
// @SerializedName(value = "type")
// private final String type;
//
// public Data(String id, String type, Object attr) {
// Validation.checkValidObject(attr);
// this.id = id;
// this.type = type;
// this.attr = attr;
// this.rels = null;
// }
//
// public Data(String id, String type, Object attr, Relationships rels) {
// Validation.checkValidObject(attr);
// this.id = id;
// this.type = type;
// this.attr = attr;
// this.rels = rels;
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Object#clone()
// */
// @Override
// protected Object clone() throws CloneNotSupportedException {
// return super.clone();
// }
//
// /**
// * @return the attr
// */
// public Object getAttr() {
// return attr;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @return the rels
// */
// public Relationships getRels() {
// if (Assert.isNull(rels)) {
// this.rels = new Relationships();
// }
// return rels;
// }
//
// /**
// * @return the type
// */
// public String getType() {
// return type;
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/entities/Nullable.java
// public interface Nullable {
//
// public static Data DATA = null;
//
// public static DataLinkage DATA_LINKAGE = null;
//
// public static Error ERROR = null;
//
// public static Link LINK = null;
//
// public static LinkRelated LINK_RELATED = null;
//
// public static Object OBJECT = null;
//
// public static Relationship RELATIONSHIP = null;
//
// public static Relationships RELATIONSHIPS = null;
//
// public static Source SOURCE = null;
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiEntityException.java
// public class EasyJsonApiEntityException extends EasyJsonApiRuntimeException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = 5052459447438977284L;
//
// public EasyJsonApiEntityException(String message) {
// super(message);
// }
//
// public EasyJsonApiEntityException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
| import java.util.ArrayList;
import java.util.LinkedList;
import org.junit.Assert;
import org.junit.Test;
import com.github.easyjsonapi.entities.Data;
import com.github.easyjsonapi.entities.Nullable;
import com.github.easyjsonapi.exceptions.EasyJsonApiEntityException; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
public class DataTest {
@Test
public void closeDataTest() throws CloneNotSupportedException {
| // Path: src/main/java/com/github/easyjsonapi/entities/Data.java
// public final class Data implements Cloneable {
//
// @SerializedName(value = "attributes")
// private final Object attr;
//
// @SerializedName(value = "id")
// private final String id;
//
// // @SerializedName(value = "links")
// // private final Object links;
//
// @SerializedName(value = "relationships")
// private Relationships rels;
//
// @SerializedName(value = "type")
// private final String type;
//
// public Data(String id, String type, Object attr) {
// Validation.checkValidObject(attr);
// this.id = id;
// this.type = type;
// this.attr = attr;
// this.rels = null;
// }
//
// public Data(String id, String type, Object attr, Relationships rels) {
// Validation.checkValidObject(attr);
// this.id = id;
// this.type = type;
// this.attr = attr;
// this.rels = rels;
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Object#clone()
// */
// @Override
// protected Object clone() throws CloneNotSupportedException {
// return super.clone();
// }
//
// /**
// * @return the attr
// */
// public Object getAttr() {
// return attr;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @return the rels
// */
// public Relationships getRels() {
// if (Assert.isNull(rels)) {
// this.rels = new Relationships();
// }
// return rels;
// }
//
// /**
// * @return the type
// */
// public String getType() {
// return type;
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/entities/Nullable.java
// public interface Nullable {
//
// public static Data DATA = null;
//
// public static DataLinkage DATA_LINKAGE = null;
//
// public static Error ERROR = null;
//
// public static Link LINK = null;
//
// public static LinkRelated LINK_RELATED = null;
//
// public static Object OBJECT = null;
//
// public static Relationship RELATIONSHIP = null;
//
// public static Relationships RELATIONSHIPS = null;
//
// public static Source SOURCE = null;
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiEntityException.java
// public class EasyJsonApiEntityException extends EasyJsonApiRuntimeException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = 5052459447438977284L;
//
// public EasyJsonApiEntityException(String message) {
// super(message);
// }
//
// public EasyJsonApiEntityException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: src/test/java/com/github/easyjsonapi/entities/DataTest.java
import java.util.ArrayList;
import java.util.LinkedList;
import org.junit.Assert;
import org.junit.Test;
import com.github.easyjsonapi.entities.Data;
import com.github.easyjsonapi.entities.Nullable;
import com.github.easyjsonapi.exceptions.EasyJsonApiEntityException;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
public class DataTest {
@Test
public void closeDataTest() throws CloneNotSupportedException {
| Data dataType = new Data("1", "books", Nullable.OBJECT); |
easyJsonApi/easyJsonApi | src/test/java/com/github/easyjsonapi/entities/DataTest.java | // Path: src/main/java/com/github/easyjsonapi/entities/Data.java
// public final class Data implements Cloneable {
//
// @SerializedName(value = "attributes")
// private final Object attr;
//
// @SerializedName(value = "id")
// private final String id;
//
// // @SerializedName(value = "links")
// // private final Object links;
//
// @SerializedName(value = "relationships")
// private Relationships rels;
//
// @SerializedName(value = "type")
// private final String type;
//
// public Data(String id, String type, Object attr) {
// Validation.checkValidObject(attr);
// this.id = id;
// this.type = type;
// this.attr = attr;
// this.rels = null;
// }
//
// public Data(String id, String type, Object attr, Relationships rels) {
// Validation.checkValidObject(attr);
// this.id = id;
// this.type = type;
// this.attr = attr;
// this.rels = rels;
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Object#clone()
// */
// @Override
// protected Object clone() throws CloneNotSupportedException {
// return super.clone();
// }
//
// /**
// * @return the attr
// */
// public Object getAttr() {
// return attr;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @return the rels
// */
// public Relationships getRels() {
// if (Assert.isNull(rels)) {
// this.rels = new Relationships();
// }
// return rels;
// }
//
// /**
// * @return the type
// */
// public String getType() {
// return type;
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/entities/Nullable.java
// public interface Nullable {
//
// public static Data DATA = null;
//
// public static DataLinkage DATA_LINKAGE = null;
//
// public static Error ERROR = null;
//
// public static Link LINK = null;
//
// public static LinkRelated LINK_RELATED = null;
//
// public static Object OBJECT = null;
//
// public static Relationship RELATIONSHIP = null;
//
// public static Relationships RELATIONSHIPS = null;
//
// public static Source SOURCE = null;
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiEntityException.java
// public class EasyJsonApiEntityException extends EasyJsonApiRuntimeException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = 5052459447438977284L;
//
// public EasyJsonApiEntityException(String message) {
// super(message);
// }
//
// public EasyJsonApiEntityException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
| import java.util.ArrayList;
import java.util.LinkedList;
import org.junit.Assert;
import org.junit.Test;
import com.github.easyjsonapi.entities.Data;
import com.github.easyjsonapi.entities.Nullable;
import com.github.easyjsonapi.exceptions.EasyJsonApiEntityException; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
public class DataTest {
@Test
public void closeDataTest() throws CloneNotSupportedException {
| // Path: src/main/java/com/github/easyjsonapi/entities/Data.java
// public final class Data implements Cloneable {
//
// @SerializedName(value = "attributes")
// private final Object attr;
//
// @SerializedName(value = "id")
// private final String id;
//
// // @SerializedName(value = "links")
// // private final Object links;
//
// @SerializedName(value = "relationships")
// private Relationships rels;
//
// @SerializedName(value = "type")
// private final String type;
//
// public Data(String id, String type, Object attr) {
// Validation.checkValidObject(attr);
// this.id = id;
// this.type = type;
// this.attr = attr;
// this.rels = null;
// }
//
// public Data(String id, String type, Object attr, Relationships rels) {
// Validation.checkValidObject(attr);
// this.id = id;
// this.type = type;
// this.attr = attr;
// this.rels = rels;
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Object#clone()
// */
// @Override
// protected Object clone() throws CloneNotSupportedException {
// return super.clone();
// }
//
// /**
// * @return the attr
// */
// public Object getAttr() {
// return attr;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @return the rels
// */
// public Relationships getRels() {
// if (Assert.isNull(rels)) {
// this.rels = new Relationships();
// }
// return rels;
// }
//
// /**
// * @return the type
// */
// public String getType() {
// return type;
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/entities/Nullable.java
// public interface Nullable {
//
// public static Data DATA = null;
//
// public static DataLinkage DATA_LINKAGE = null;
//
// public static Error ERROR = null;
//
// public static Link LINK = null;
//
// public static LinkRelated LINK_RELATED = null;
//
// public static Object OBJECT = null;
//
// public static Relationship RELATIONSHIP = null;
//
// public static Relationships RELATIONSHIPS = null;
//
// public static Source SOURCE = null;
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiEntityException.java
// public class EasyJsonApiEntityException extends EasyJsonApiRuntimeException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = 5052459447438977284L;
//
// public EasyJsonApiEntityException(String message) {
// super(message);
// }
//
// public EasyJsonApiEntityException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: src/test/java/com/github/easyjsonapi/entities/DataTest.java
import java.util.ArrayList;
import java.util.LinkedList;
import org.junit.Assert;
import org.junit.Test;
import com.github.easyjsonapi.entities.Data;
import com.github.easyjsonapi.entities.Nullable;
import com.github.easyjsonapi.exceptions.EasyJsonApiEntityException;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
public class DataTest {
@Test
public void closeDataTest() throws CloneNotSupportedException {
| Data dataType = new Data("1", "books", Nullable.OBJECT); |
easyJsonApi/easyJsonApi | src/test/java/com/github/easyjsonapi/entities/DataTest.java | // Path: src/main/java/com/github/easyjsonapi/entities/Data.java
// public final class Data implements Cloneable {
//
// @SerializedName(value = "attributes")
// private final Object attr;
//
// @SerializedName(value = "id")
// private final String id;
//
// // @SerializedName(value = "links")
// // private final Object links;
//
// @SerializedName(value = "relationships")
// private Relationships rels;
//
// @SerializedName(value = "type")
// private final String type;
//
// public Data(String id, String type, Object attr) {
// Validation.checkValidObject(attr);
// this.id = id;
// this.type = type;
// this.attr = attr;
// this.rels = null;
// }
//
// public Data(String id, String type, Object attr, Relationships rels) {
// Validation.checkValidObject(attr);
// this.id = id;
// this.type = type;
// this.attr = attr;
// this.rels = rels;
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Object#clone()
// */
// @Override
// protected Object clone() throws CloneNotSupportedException {
// return super.clone();
// }
//
// /**
// * @return the attr
// */
// public Object getAttr() {
// return attr;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @return the rels
// */
// public Relationships getRels() {
// if (Assert.isNull(rels)) {
// this.rels = new Relationships();
// }
// return rels;
// }
//
// /**
// * @return the type
// */
// public String getType() {
// return type;
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/entities/Nullable.java
// public interface Nullable {
//
// public static Data DATA = null;
//
// public static DataLinkage DATA_LINKAGE = null;
//
// public static Error ERROR = null;
//
// public static Link LINK = null;
//
// public static LinkRelated LINK_RELATED = null;
//
// public static Object OBJECT = null;
//
// public static Relationship RELATIONSHIP = null;
//
// public static Relationships RELATIONSHIPS = null;
//
// public static Source SOURCE = null;
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiEntityException.java
// public class EasyJsonApiEntityException extends EasyJsonApiRuntimeException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = 5052459447438977284L;
//
// public EasyJsonApiEntityException(String message) {
// super(message);
// }
//
// public EasyJsonApiEntityException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
| import java.util.ArrayList;
import java.util.LinkedList;
import org.junit.Assert;
import org.junit.Test;
import com.github.easyjsonapi.entities.Data;
import com.github.easyjsonapi.entities.Nullable;
import com.github.easyjsonapi.exceptions.EasyJsonApiEntityException; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
public class DataTest {
@Test
public void closeDataTest() throws CloneNotSupportedException {
Data dataType = new Data("1", "books", Nullable.OBJECT);
Data dataClone = (Data) dataType.clone();
Assert.assertEquals(dataType.getId(), dataClone.getId());
Assert.assertEquals(dataType.getType(), dataClone.getType());
Assert.assertNotEquals(System.identityHashCode(dataType.hashCode()), System.identityHashCode(dataClone.hashCode()));
}
| // Path: src/main/java/com/github/easyjsonapi/entities/Data.java
// public final class Data implements Cloneable {
//
// @SerializedName(value = "attributes")
// private final Object attr;
//
// @SerializedName(value = "id")
// private final String id;
//
// // @SerializedName(value = "links")
// // private final Object links;
//
// @SerializedName(value = "relationships")
// private Relationships rels;
//
// @SerializedName(value = "type")
// private final String type;
//
// public Data(String id, String type, Object attr) {
// Validation.checkValidObject(attr);
// this.id = id;
// this.type = type;
// this.attr = attr;
// this.rels = null;
// }
//
// public Data(String id, String type, Object attr, Relationships rels) {
// Validation.checkValidObject(attr);
// this.id = id;
// this.type = type;
// this.attr = attr;
// this.rels = rels;
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Object#clone()
// */
// @Override
// protected Object clone() throws CloneNotSupportedException {
// return super.clone();
// }
//
// /**
// * @return the attr
// */
// public Object getAttr() {
// return attr;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @return the rels
// */
// public Relationships getRels() {
// if (Assert.isNull(rels)) {
// this.rels = new Relationships();
// }
// return rels;
// }
//
// /**
// * @return the type
// */
// public String getType() {
// return type;
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/entities/Nullable.java
// public interface Nullable {
//
// public static Data DATA = null;
//
// public static DataLinkage DATA_LINKAGE = null;
//
// public static Error ERROR = null;
//
// public static Link LINK = null;
//
// public static LinkRelated LINK_RELATED = null;
//
// public static Object OBJECT = null;
//
// public static Relationship RELATIONSHIP = null;
//
// public static Relationships RELATIONSHIPS = null;
//
// public static Source SOURCE = null;
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiEntityException.java
// public class EasyJsonApiEntityException extends EasyJsonApiRuntimeException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = 5052459447438977284L;
//
// public EasyJsonApiEntityException(String message) {
// super(message);
// }
//
// public EasyJsonApiEntityException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: src/test/java/com/github/easyjsonapi/entities/DataTest.java
import java.util.ArrayList;
import java.util.LinkedList;
import org.junit.Assert;
import org.junit.Test;
import com.github.easyjsonapi.entities.Data;
import com.github.easyjsonapi.entities.Nullable;
import com.github.easyjsonapi.exceptions.EasyJsonApiEntityException;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
public class DataTest {
@Test
public void closeDataTest() throws CloneNotSupportedException {
Data dataType = new Data("1", "books", Nullable.OBJECT);
Data dataClone = (Data) dataType.clone();
Assert.assertEquals(dataType.getId(), dataClone.getId());
Assert.assertEquals(dataType.getType(), dataClone.getType());
Assert.assertNotEquals(System.identityHashCode(dataType.hashCode()), System.identityHashCode(dataClone.hashCode()));
}
| @Test(expected = EasyJsonApiEntityException.class) |
easyJsonApi/easyJsonApi | src/main/java/com/github/easyjsonapi/tools/JsonTools.java | // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiRuntimeException.java
// public class EasyJsonApiRuntimeException extends RuntimeException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = 6382099926165220367L;
//
// public EasyJsonApiRuntimeException(String message) {
// super(message);
// }
//
// public EasyJsonApiRuntimeException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
| import com.google.gson.JsonObject;
import com.github.easyjsonapi.asserts.Assert;
import com.github.easyjsonapi.exceptions.EasyJsonApiRuntimeException;
import com.google.gson.JsonElement; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.tools;
/**
* Tool helps with json, it has all method need to validate json structure and wrap objects
*
* @author Nuno Bento (nbento.neves@gmail.com)
*/
public class JsonTools {
/**
* Get string inside json
*
* @param name
* the name of attribute
* @param json
* the json object
* @return string with json object value
*/
public static String getStringInsideJson(String name, JsonObject json) {
| // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiRuntimeException.java
// public class EasyJsonApiRuntimeException extends RuntimeException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = 6382099926165220367L;
//
// public EasyJsonApiRuntimeException(String message) {
// super(message);
// }
//
// public EasyJsonApiRuntimeException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: src/main/java/com/github/easyjsonapi/tools/JsonTools.java
import com.google.gson.JsonObject;
import com.github.easyjsonapi.asserts.Assert;
import com.github.easyjsonapi.exceptions.EasyJsonApiRuntimeException;
import com.google.gson.JsonElement;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.tools;
/**
* Tool helps with json, it has all method need to validate json structure and wrap objects
*
* @author Nuno Bento (nbento.neves@gmail.com)
*/
public class JsonTools {
/**
* Get string inside json
*
* @param name
* the name of attribute
* @param json
* the json object
* @return string with json object value
*/
public static String getStringInsideJson(String name, JsonObject json) {
| if (Assert.isNull(json.get(name))) { |
easyJsonApi/easyJsonApi | src/main/java/com/github/easyjsonapi/tools/JsonTools.java | // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiRuntimeException.java
// public class EasyJsonApiRuntimeException extends RuntimeException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = 6382099926165220367L;
//
// public EasyJsonApiRuntimeException(String message) {
// super(message);
// }
//
// public EasyJsonApiRuntimeException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
| import com.google.gson.JsonObject;
import com.github.easyjsonapi.asserts.Assert;
import com.github.easyjsonapi.exceptions.EasyJsonApiRuntimeException;
import com.google.gson.JsonElement; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.tools;
/**
* Tool helps with json, it has all method need to validate json structure and wrap objects
*
* @author Nuno Bento (nbento.neves@gmail.com)
*/
public class JsonTools {
/**
* Get string inside json
*
* @param name
* the name of attribute
* @param json
* the json object
* @return string with json object value
*/
public static String getStringInsideJson(String name, JsonObject json) {
if (Assert.isNull(json.get(name))) {
return null;
}
return json.get(name).getAsString();
}
/**
* Put json object inside the json structure submitted
*
* @param jsonObj
* the concat json structure
* @param name
* the name of json attribute
* @param objectInsert
* the json object needs to insert inside json structure, you must choose two types:
* String or JsonElement otherwise you will get {@link EasyJsonApiRuntimeException} exception.
*/
public static void insertObject(JsonObject jsonObj, String name, Object objectInsert) {
if (Assert.notNull(jsonObj)) {
if (Assert.notNull(objectInsert)) {
if (objectInsert instanceof String) {
if (Assert.notEmpty((String) objectInsert)) {
jsonObj.addProperty(name, (String) objectInsert);
}
} else if (objectInsert instanceof JsonElement) {
jsonObj.add(name, (JsonElement) objectInsert);
} else { | // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiRuntimeException.java
// public class EasyJsonApiRuntimeException extends RuntimeException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = 6382099926165220367L;
//
// public EasyJsonApiRuntimeException(String message) {
// super(message);
// }
//
// public EasyJsonApiRuntimeException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: src/main/java/com/github/easyjsonapi/tools/JsonTools.java
import com.google.gson.JsonObject;
import com.github.easyjsonapi.asserts.Assert;
import com.github.easyjsonapi.exceptions.EasyJsonApiRuntimeException;
import com.google.gson.JsonElement;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.tools;
/**
* Tool helps with json, it has all method need to validate json structure and wrap objects
*
* @author Nuno Bento (nbento.neves@gmail.com)
*/
public class JsonTools {
/**
* Get string inside json
*
* @param name
* the name of attribute
* @param json
* the json object
* @return string with json object value
*/
public static String getStringInsideJson(String name, JsonObject json) {
if (Assert.isNull(json.get(name))) {
return null;
}
return json.get(name).getAsString();
}
/**
* Put json object inside the json structure submitted
*
* @param jsonObj
* the concat json structure
* @param name
* the name of json attribute
* @param objectInsert
* the json object needs to insert inside json structure, you must choose two types:
* String or JsonElement otherwise you will get {@link EasyJsonApiRuntimeException} exception.
*/
public static void insertObject(JsonObject jsonObj, String name, Object objectInsert) {
if (Assert.notNull(jsonObj)) {
if (Assert.notNull(objectInsert)) {
if (objectInsert instanceof String) {
if (Assert.notEmpty((String) objectInsert)) {
jsonObj.addProperty(name, (String) objectInsert);
}
} else if (objectInsert instanceof JsonElement) {
jsonObj.add(name, (JsonElement) objectInsert);
} else { | throw new EasyJsonApiRuntimeException("Invalid object inserted!"); |
easyJsonApi/easyJsonApi | src/main/java/com/github/easyjsonapi/entities/JsonApi.java | // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
| import com.github.easyjsonapi.asserts.Assert;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.List; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
/**
* Entity represents the contract object in json api specification
*
* @author Nuno Bento (nbento.neves@gmail.com)
* @see {@link Data}
* @see {@link Error}
*/
public class JsonApi {
@SerializedName(value = "data")
private List<Data> data;
@SerializedName(value = "errors")
private List<Error> errors;
/**
* Add {@link Data} inside the data list objects inside {@link JsonApi}
*
* @param data
* the data to insert into {@link JsonApi}
*/
public void addData(Data data) {
| // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
// Path: src/main/java/com/github/easyjsonapi/entities/JsonApi.java
import com.github.easyjsonapi.asserts.Assert;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.List;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
/**
* Entity represents the contract object in json api specification
*
* @author Nuno Bento (nbento.neves@gmail.com)
* @see {@link Data}
* @see {@link Error}
*/
public class JsonApi {
@SerializedName(value = "data")
private List<Data> data;
@SerializedName(value = "errors")
private List<Error> errors;
/**
* Add {@link Data} inside the data list objects inside {@link JsonApi}
*
* @param data
* the data to insert into {@link JsonApi}
*/
public void addData(Data data) {
| if (Assert.isNull(this.data)) { |
easyJsonApi/easyJsonApi | src/main/java/com/github/easyjsonapi/asserts/Validation.java | // Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiEntityException.java
// public class EasyJsonApiEntityException extends EasyJsonApiRuntimeException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = 5052459447438977284L;
//
// public EasyJsonApiEntityException(String message) {
// super(message);
// }
//
// public EasyJsonApiEntityException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
| import java.util.Map;
import com.github.easyjsonapi.annotations.Attributes;
import com.github.easyjsonapi.annotations.Meta;
import com.github.easyjsonapi.annotations.MetaRelationship;
import com.github.easyjsonapi.exceptions.EasyJsonApiEntityException; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.asserts;
public class Validation {
/**
* Check if object is valid. One object is valid when has one of the rules
* below:
*
* - is an instance of {@link Map}
* - has the annotation {@link Attributes}
* - has the annotation {@link Meta}
*
* @param objectAnnotated
* the object needs validate
*/
public static void checkValidObject(Object objectAnnotated) {
boolean notAnnotated = true;
if (Assert.isNull(objectAnnotated)) {
notAnnotated = false;
} else if (objectAnnotated instanceof Map) {
notAnnotated = false;
} else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Attributes.class))) {
notAnnotated = false;
} else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Meta.class))) {
notAnnotated = false;
} else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(MetaRelationship.class))) {
notAnnotated = false;
}
if (notAnnotated) { | // Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiEntityException.java
// public class EasyJsonApiEntityException extends EasyJsonApiRuntimeException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = 5052459447438977284L;
//
// public EasyJsonApiEntityException(String message) {
// super(message);
// }
//
// public EasyJsonApiEntityException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: src/main/java/com/github/easyjsonapi/asserts/Validation.java
import java.util.Map;
import com.github.easyjsonapi.annotations.Attributes;
import com.github.easyjsonapi.annotations.Meta;
import com.github.easyjsonapi.annotations.MetaRelationship;
import com.github.easyjsonapi.exceptions.EasyJsonApiEntityException;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.asserts;
public class Validation {
/**
* Check if object is valid. One object is valid when has one of the rules
* below:
*
* - is an instance of {@link Map}
* - has the annotation {@link Attributes}
* - has the annotation {@link Meta}
*
* @param objectAnnotated
* the object needs validate
*/
public static void checkValidObject(Object objectAnnotated) {
boolean notAnnotated = true;
if (Assert.isNull(objectAnnotated)) {
notAnnotated = false;
} else if (objectAnnotated instanceof Map) {
notAnnotated = false;
} else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Attributes.class))) {
notAnnotated = false;
} else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Meta.class))) {
notAnnotated = false;
} else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(MetaRelationship.class))) {
notAnnotated = false;
}
if (notAnnotated) { | throw new EasyJsonApiEntityException("Invalid object inserted! Please check the annotation inside the pojo!"); |
easyJsonApi/easyJsonApi | src/test/java/com/github/easyjsonapi/core/EasyJsonApiConfigTest.java | // Path: src/main/java/com/github/easyjsonapi/core/EasyJsonApiConfig.java
// public class EasyJsonApiConfig {
//
// private Map<EasyJsonApiTypeToken, List<Class<?>>> classesParsed = new HashMap<>();
//
// private String[] packagesSearched;
//
// /**
// * The default constructor
// */
// public EasyJsonApiConfig() {}
//
// /**
// * The constructor with packages attributes
// *
// * @param packages
// * the packages needs to be search and parsing
// * @throws EasyJsonApiInvalidPackageException
// */
// public EasyJsonApiConfig(String... packages) throws EasyJsonApiInvalidPackageException {
// setPackagesToSearch(packages);
// }
//
// /**
// * Get the array with all classes parsed
// *
// * @return the classesParsed the classes parsed
// */
// public Map<EasyJsonApiTypeToken, List<Class<?>>> getClassesParsed() {
// return classesParsed;
// }
//
// /**
// * Get the array with packages searched
// *
// * @return the packagesSearched the packages searched
// */
// public String[] getPackagesSearched() {
// return packagesSearched;
// }
//
// /**
// * Set the packages to search
// *
// * @param packages
// * the packages needs to be search and parsing
// * @throws EasyJsonApiInvalidPackageException
// */
// public void setPackagesToSearch(String... packages) throws EasyJsonApiInvalidPackageException {
//
// this.packagesSearched = packages;
//
// for (String packageToSearch : packages) {
// try {
// ClassPath classpath = ClassPath.from(getClass().getClassLoader());
//
// List<Class<?>> attrClasses = new ArrayList<>();
// List<Class<?>> metaClasses = new ArrayList<>();
// List<Class<?>> metaRelationshipsClasses = new ArrayList<>();
//
// for (ClassPath.ClassInfo classInfo : classpath.getTopLevelClasses(packageToSearch)) {
//
// Class<?> clazz = classInfo.load();
//
// if (Assert.notNull(clazz.getAnnotation(Attributes.class))) {
// attrClasses.add(clazz);
// } else if (Assert.notNull(clazz.getAnnotation(Meta.class))) {
// metaClasses.add(clazz);
// } else if (Assert.notNull(clazz.getAnnotation(MetaRelationship.class))) {
// metaRelationshipsClasses.add(clazz);
// }
// }
//
// this.classesParsed.put(EasyJsonApiTypeToken.TOKEN_ATTR, attrClasses);
// this.classesParsed.put(EasyJsonApiTypeToken.TOKEN_META, metaClasses);
// this.classesParsed.put(EasyJsonApiTypeToken.TOKEN_META_RELATIONSHIP, metaRelationshipsClasses);
//
// } catch (IOException ex) {
// throw new EasyJsonApiInvalidPackageException("Invalid packages inserted!", ex);
// }
// }
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiInvalidPackageException.java
// public class EasyJsonApiInvalidPackageException extends EasyJsonApiException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = -1850836160599521183L;
//
// public EasyJsonApiInvalidPackageException(String message) {
// super(message);
// }
//
// public EasyJsonApiInvalidPackageException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
| import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import com.github.easyjsonapi.core.EasyJsonApiConfig;
import com.github.easyjsonapi.exceptions.EasyJsonApiInvalidPackageException; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.core;
public class EasyJsonApiConfigTest {
@Test | // Path: src/main/java/com/github/easyjsonapi/core/EasyJsonApiConfig.java
// public class EasyJsonApiConfig {
//
// private Map<EasyJsonApiTypeToken, List<Class<?>>> classesParsed = new HashMap<>();
//
// private String[] packagesSearched;
//
// /**
// * The default constructor
// */
// public EasyJsonApiConfig() {}
//
// /**
// * The constructor with packages attributes
// *
// * @param packages
// * the packages needs to be search and parsing
// * @throws EasyJsonApiInvalidPackageException
// */
// public EasyJsonApiConfig(String... packages) throws EasyJsonApiInvalidPackageException {
// setPackagesToSearch(packages);
// }
//
// /**
// * Get the array with all classes parsed
// *
// * @return the classesParsed the classes parsed
// */
// public Map<EasyJsonApiTypeToken, List<Class<?>>> getClassesParsed() {
// return classesParsed;
// }
//
// /**
// * Get the array with packages searched
// *
// * @return the packagesSearched the packages searched
// */
// public String[] getPackagesSearched() {
// return packagesSearched;
// }
//
// /**
// * Set the packages to search
// *
// * @param packages
// * the packages needs to be search and parsing
// * @throws EasyJsonApiInvalidPackageException
// */
// public void setPackagesToSearch(String... packages) throws EasyJsonApiInvalidPackageException {
//
// this.packagesSearched = packages;
//
// for (String packageToSearch : packages) {
// try {
// ClassPath classpath = ClassPath.from(getClass().getClassLoader());
//
// List<Class<?>> attrClasses = new ArrayList<>();
// List<Class<?>> metaClasses = new ArrayList<>();
// List<Class<?>> metaRelationshipsClasses = new ArrayList<>();
//
// for (ClassPath.ClassInfo classInfo : classpath.getTopLevelClasses(packageToSearch)) {
//
// Class<?> clazz = classInfo.load();
//
// if (Assert.notNull(clazz.getAnnotation(Attributes.class))) {
// attrClasses.add(clazz);
// } else if (Assert.notNull(clazz.getAnnotation(Meta.class))) {
// metaClasses.add(clazz);
// } else if (Assert.notNull(clazz.getAnnotation(MetaRelationship.class))) {
// metaRelationshipsClasses.add(clazz);
// }
// }
//
// this.classesParsed.put(EasyJsonApiTypeToken.TOKEN_ATTR, attrClasses);
// this.classesParsed.put(EasyJsonApiTypeToken.TOKEN_META, metaClasses);
// this.classesParsed.put(EasyJsonApiTypeToken.TOKEN_META_RELATIONSHIP, metaRelationshipsClasses);
//
// } catch (IOException ex) {
// throw new EasyJsonApiInvalidPackageException("Invalid packages inserted!", ex);
// }
// }
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiInvalidPackageException.java
// public class EasyJsonApiInvalidPackageException extends EasyJsonApiException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = -1850836160599521183L;
//
// public EasyJsonApiInvalidPackageException(String message) {
// super(message);
// }
//
// public EasyJsonApiInvalidPackageException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: src/test/java/com/github/easyjsonapi/core/EasyJsonApiConfigTest.java
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import com.github.easyjsonapi.core.EasyJsonApiConfig;
import com.github.easyjsonapi.exceptions.EasyJsonApiInvalidPackageException;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.core;
public class EasyJsonApiConfigTest {
@Test | public void constructionTest() throws EasyJsonApiInvalidPackageException { |
easyJsonApi/easyJsonApi | src/test/java/com/github/easyjsonapi/core/EasyJsonApiConfigTest.java | // Path: src/main/java/com/github/easyjsonapi/core/EasyJsonApiConfig.java
// public class EasyJsonApiConfig {
//
// private Map<EasyJsonApiTypeToken, List<Class<?>>> classesParsed = new HashMap<>();
//
// private String[] packagesSearched;
//
// /**
// * The default constructor
// */
// public EasyJsonApiConfig() {}
//
// /**
// * The constructor with packages attributes
// *
// * @param packages
// * the packages needs to be search and parsing
// * @throws EasyJsonApiInvalidPackageException
// */
// public EasyJsonApiConfig(String... packages) throws EasyJsonApiInvalidPackageException {
// setPackagesToSearch(packages);
// }
//
// /**
// * Get the array with all classes parsed
// *
// * @return the classesParsed the classes parsed
// */
// public Map<EasyJsonApiTypeToken, List<Class<?>>> getClassesParsed() {
// return classesParsed;
// }
//
// /**
// * Get the array with packages searched
// *
// * @return the packagesSearched the packages searched
// */
// public String[] getPackagesSearched() {
// return packagesSearched;
// }
//
// /**
// * Set the packages to search
// *
// * @param packages
// * the packages needs to be search and parsing
// * @throws EasyJsonApiInvalidPackageException
// */
// public void setPackagesToSearch(String... packages) throws EasyJsonApiInvalidPackageException {
//
// this.packagesSearched = packages;
//
// for (String packageToSearch : packages) {
// try {
// ClassPath classpath = ClassPath.from(getClass().getClassLoader());
//
// List<Class<?>> attrClasses = new ArrayList<>();
// List<Class<?>> metaClasses = new ArrayList<>();
// List<Class<?>> metaRelationshipsClasses = new ArrayList<>();
//
// for (ClassPath.ClassInfo classInfo : classpath.getTopLevelClasses(packageToSearch)) {
//
// Class<?> clazz = classInfo.load();
//
// if (Assert.notNull(clazz.getAnnotation(Attributes.class))) {
// attrClasses.add(clazz);
// } else if (Assert.notNull(clazz.getAnnotation(Meta.class))) {
// metaClasses.add(clazz);
// } else if (Assert.notNull(clazz.getAnnotation(MetaRelationship.class))) {
// metaRelationshipsClasses.add(clazz);
// }
// }
//
// this.classesParsed.put(EasyJsonApiTypeToken.TOKEN_ATTR, attrClasses);
// this.classesParsed.put(EasyJsonApiTypeToken.TOKEN_META, metaClasses);
// this.classesParsed.put(EasyJsonApiTypeToken.TOKEN_META_RELATIONSHIP, metaRelationshipsClasses);
//
// } catch (IOException ex) {
// throw new EasyJsonApiInvalidPackageException("Invalid packages inserted!", ex);
// }
// }
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiInvalidPackageException.java
// public class EasyJsonApiInvalidPackageException extends EasyJsonApiException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = -1850836160599521183L;
//
// public EasyJsonApiInvalidPackageException(String message) {
// super(message);
// }
//
// public EasyJsonApiInvalidPackageException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
| import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import com.github.easyjsonapi.core.EasyJsonApiConfig;
import com.github.easyjsonapi.exceptions.EasyJsonApiInvalidPackageException; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.core;
public class EasyJsonApiConfigTest {
@Test
public void constructionTest() throws EasyJsonApiInvalidPackageException {
| // Path: src/main/java/com/github/easyjsonapi/core/EasyJsonApiConfig.java
// public class EasyJsonApiConfig {
//
// private Map<EasyJsonApiTypeToken, List<Class<?>>> classesParsed = new HashMap<>();
//
// private String[] packagesSearched;
//
// /**
// * The default constructor
// */
// public EasyJsonApiConfig() {}
//
// /**
// * The constructor with packages attributes
// *
// * @param packages
// * the packages needs to be search and parsing
// * @throws EasyJsonApiInvalidPackageException
// */
// public EasyJsonApiConfig(String... packages) throws EasyJsonApiInvalidPackageException {
// setPackagesToSearch(packages);
// }
//
// /**
// * Get the array with all classes parsed
// *
// * @return the classesParsed the classes parsed
// */
// public Map<EasyJsonApiTypeToken, List<Class<?>>> getClassesParsed() {
// return classesParsed;
// }
//
// /**
// * Get the array with packages searched
// *
// * @return the packagesSearched the packages searched
// */
// public String[] getPackagesSearched() {
// return packagesSearched;
// }
//
// /**
// * Set the packages to search
// *
// * @param packages
// * the packages needs to be search and parsing
// * @throws EasyJsonApiInvalidPackageException
// */
// public void setPackagesToSearch(String... packages) throws EasyJsonApiInvalidPackageException {
//
// this.packagesSearched = packages;
//
// for (String packageToSearch : packages) {
// try {
// ClassPath classpath = ClassPath.from(getClass().getClassLoader());
//
// List<Class<?>> attrClasses = new ArrayList<>();
// List<Class<?>> metaClasses = new ArrayList<>();
// List<Class<?>> metaRelationshipsClasses = new ArrayList<>();
//
// for (ClassPath.ClassInfo classInfo : classpath.getTopLevelClasses(packageToSearch)) {
//
// Class<?> clazz = classInfo.load();
//
// if (Assert.notNull(clazz.getAnnotation(Attributes.class))) {
// attrClasses.add(clazz);
// } else if (Assert.notNull(clazz.getAnnotation(Meta.class))) {
// metaClasses.add(clazz);
// } else if (Assert.notNull(clazz.getAnnotation(MetaRelationship.class))) {
// metaRelationshipsClasses.add(clazz);
// }
// }
//
// this.classesParsed.put(EasyJsonApiTypeToken.TOKEN_ATTR, attrClasses);
// this.classesParsed.put(EasyJsonApiTypeToken.TOKEN_META, metaClasses);
// this.classesParsed.put(EasyJsonApiTypeToken.TOKEN_META_RELATIONSHIP, metaRelationshipsClasses);
//
// } catch (IOException ex) {
// throw new EasyJsonApiInvalidPackageException("Invalid packages inserted!", ex);
// }
// }
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/exceptions/EasyJsonApiInvalidPackageException.java
// public class EasyJsonApiInvalidPackageException extends EasyJsonApiException {
//
// /**
// * UID Generated
// */
// private static final long serialVersionUID = -1850836160599521183L;
//
// public EasyJsonApiInvalidPackageException(String message) {
// super(message);
// }
//
// public EasyJsonApiInvalidPackageException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: src/test/java/com/github/easyjsonapi/core/EasyJsonApiConfigTest.java
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import com.github.easyjsonapi.core.EasyJsonApiConfig;
import com.github.easyjsonapi.exceptions.EasyJsonApiInvalidPackageException;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.core;
public class EasyJsonApiConfigTest {
@Test
public void constructionTest() throws EasyJsonApiInvalidPackageException {
| EasyJsonApiConfig configDefaultConstruct = new EasyJsonApiConfig(); |
easyJsonApi/easyJsonApi | src/main/java/com/github/easyjsonapi/entities/Relationship.java | // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/asserts/Validation.java
// public class Validation {
//
// /**
// * Check if object is valid. One object is valid when has one of the rules
// * below:
// *
// * - is an instance of {@link Map}
// * - has the annotation {@link Attributes}
// * - has the annotation {@link Meta}
// *
// * @param objectAnnotated
// * the object needs validate
// */
// public static void checkValidObject(Object objectAnnotated) {
//
// boolean notAnnotated = true;
//
// if (Assert.isNull(objectAnnotated)) {
// notAnnotated = false;
// } else if (objectAnnotated instanceof Map) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Attributes.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Meta.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(MetaRelationship.class))) {
// notAnnotated = false;
// }
//
// if (notAnnotated) {
// throw new EasyJsonApiEntityException("Invalid object inserted! Please check the annotation inside the pojo!");
// }
//
// }
//
// }
| import java.util.HashSet;
import java.util.Set;
import com.github.easyjsonapi.asserts.Assert;
import com.github.easyjsonapi.asserts.Validation;
import com.google.gson.annotations.SerializedName; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
/**
* Entity represents relationship resource object in json api specification
*
* @author Nuno Bento (nbento.neves@gmail.com)
* @see {@link Relationships}
* @see {@link DataLinkage}
* @see {@link Link}
*/
public class Relationship {
@SerializedName(value = "data")
private final Set<DataLinkage> dataLinkage;
@SerializedName(value = "links")
private final Link links;
@SerializedName(value = "meta")
private final Object meta;
private final String name;
public Relationship(String name, Link links, Object meta) {
super(); | // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/asserts/Validation.java
// public class Validation {
//
// /**
// * Check if object is valid. One object is valid when has one of the rules
// * below:
// *
// * - is an instance of {@link Map}
// * - has the annotation {@link Attributes}
// * - has the annotation {@link Meta}
// *
// * @param objectAnnotated
// * the object needs validate
// */
// public static void checkValidObject(Object objectAnnotated) {
//
// boolean notAnnotated = true;
//
// if (Assert.isNull(objectAnnotated)) {
// notAnnotated = false;
// } else if (objectAnnotated instanceof Map) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Attributes.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Meta.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(MetaRelationship.class))) {
// notAnnotated = false;
// }
//
// if (notAnnotated) {
// throw new EasyJsonApiEntityException("Invalid object inserted! Please check the annotation inside the pojo!");
// }
//
// }
//
// }
// Path: src/main/java/com/github/easyjsonapi/entities/Relationship.java
import java.util.HashSet;
import java.util.Set;
import com.github.easyjsonapi.asserts.Assert;
import com.github.easyjsonapi.asserts.Validation;
import com.google.gson.annotations.SerializedName;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
/**
* Entity represents relationship resource object in json api specification
*
* @author Nuno Bento (nbento.neves@gmail.com)
* @see {@link Relationships}
* @see {@link DataLinkage}
* @see {@link Link}
*/
public class Relationship {
@SerializedName(value = "data")
private final Set<DataLinkage> dataLinkage;
@SerializedName(value = "links")
private final Link links;
@SerializedName(value = "meta")
private final Object meta;
private final String name;
public Relationship(String name, Link links, Object meta) {
super(); | Validation.checkValidObject(meta); |
easyJsonApi/easyJsonApi | src/main/java/com/github/easyjsonapi/entities/Relationship.java | // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/asserts/Validation.java
// public class Validation {
//
// /**
// * Check if object is valid. One object is valid when has one of the rules
// * below:
// *
// * - is an instance of {@link Map}
// * - has the annotation {@link Attributes}
// * - has the annotation {@link Meta}
// *
// * @param objectAnnotated
// * the object needs validate
// */
// public static void checkValidObject(Object objectAnnotated) {
//
// boolean notAnnotated = true;
//
// if (Assert.isNull(objectAnnotated)) {
// notAnnotated = false;
// } else if (objectAnnotated instanceof Map) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Attributes.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Meta.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(MetaRelationship.class))) {
// notAnnotated = false;
// }
//
// if (notAnnotated) {
// throw new EasyJsonApiEntityException("Invalid object inserted! Please check the annotation inside the pojo!");
// }
//
// }
//
// }
| import java.util.HashSet;
import java.util.Set;
import com.github.easyjsonapi.asserts.Assert;
import com.github.easyjsonapi.asserts.Validation;
import com.google.gson.annotations.SerializedName; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
/**
* Entity represents relationship resource object in json api specification
*
* @author Nuno Bento (nbento.neves@gmail.com)
* @see {@link Relationships}
* @see {@link DataLinkage}
* @see {@link Link}
*/
public class Relationship {
@SerializedName(value = "data")
private final Set<DataLinkage> dataLinkage;
@SerializedName(value = "links")
private final Link links;
@SerializedName(value = "meta")
private final Object meta;
private final String name;
public Relationship(String name, Link links, Object meta) {
super();
Validation.checkValidObject(meta);
this.dataLinkage = new HashSet<>();
this.name = name;
this.links = links;
this.meta = meta;
}
/**
* Add one {@link DataLinkage}
*
* @param dataLinkage
* the data linkage
*/
public void addDataLinkage(DataLinkage dataLinkage) { | // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/asserts/Validation.java
// public class Validation {
//
// /**
// * Check if object is valid. One object is valid when has one of the rules
// * below:
// *
// * - is an instance of {@link Map}
// * - has the annotation {@link Attributes}
// * - has the annotation {@link Meta}
// *
// * @param objectAnnotated
// * the object needs validate
// */
// public static void checkValidObject(Object objectAnnotated) {
//
// boolean notAnnotated = true;
//
// if (Assert.isNull(objectAnnotated)) {
// notAnnotated = false;
// } else if (objectAnnotated instanceof Map) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Attributes.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Meta.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(MetaRelationship.class))) {
// notAnnotated = false;
// }
//
// if (notAnnotated) {
// throw new EasyJsonApiEntityException("Invalid object inserted! Please check the annotation inside the pojo!");
// }
//
// }
//
// }
// Path: src/main/java/com/github/easyjsonapi/entities/Relationship.java
import java.util.HashSet;
import java.util.Set;
import com.github.easyjsonapi.asserts.Assert;
import com.github.easyjsonapi.asserts.Validation;
import com.google.gson.annotations.SerializedName;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
/**
* Entity represents relationship resource object in json api specification
*
* @author Nuno Bento (nbento.neves@gmail.com)
* @see {@link Relationships}
* @see {@link DataLinkage}
* @see {@link Link}
*/
public class Relationship {
@SerializedName(value = "data")
private final Set<DataLinkage> dataLinkage;
@SerializedName(value = "links")
private final Link links;
@SerializedName(value = "meta")
private final Object meta;
private final String name;
public Relationship(String name, Link links, Object meta) {
super();
Validation.checkValidObject(meta);
this.dataLinkage = new HashSet<>();
this.name = name;
this.links = links;
this.meta = meta;
}
/**
* Add one {@link DataLinkage}
*
* @param dataLinkage
* the data linkage
*/
public void addDataLinkage(DataLinkage dataLinkage) { | if (Assert.notNull(this.dataLinkage)) { |
easyJsonApi/easyJsonApi | src/test/java/com/github/easyjsonapi/asserts/AssertTest.java | // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
| import org.junit.Test;
import com.github.easyjsonapi.asserts.Assert;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.asserts;
public class AssertTest {
@Test
public void isEmptyTest() {
| // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
// Path: src/test/java/com/github/easyjsonapi/asserts/AssertTest.java
import org.junit.Test;
import com.github.easyjsonapi.asserts.Assert;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.asserts;
public class AssertTest {
@Test
public void isEmptyTest() {
| assertTrue(Assert.isEmpty("")); |
easyJsonApi/easyJsonApi | src/main/java/com/github/easyjsonapi/entities/Error.java | // Path: src/main/java/com/github/easyjsonapi/asserts/Validation.java
// public class Validation {
//
// /**
// * Check if object is valid. One object is valid when has one of the rules
// * below:
// *
// * - is an instance of {@link Map}
// * - has the annotation {@link Attributes}
// * - has the annotation {@link Meta}
// *
// * @param objectAnnotated
// * the object needs validate
// */
// public static void checkValidObject(Object objectAnnotated) {
//
// boolean notAnnotated = true;
//
// if (Assert.isNull(objectAnnotated)) {
// notAnnotated = false;
// } else if (objectAnnotated instanceof Map) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Attributes.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Meta.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(MetaRelationship.class))) {
// notAnnotated = false;
// }
//
// if (notAnnotated) {
// throw new EasyJsonApiEntityException("Invalid object inserted! Please check the annotation inside the pojo!");
// }
//
// }
//
// }
| import com.github.easyjsonapi.asserts.Validation;
import com.google.gson.annotations.SerializedName; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
/**
* Entity represents error resource object in json api specification
*
* @author Nuno Bento (nbento.neves@gmail.com)
* @see {@link JsonApi}
* @see {@link Source}
* @see {@link HttpStatus}
*/
public final class Error implements Cloneable {
@SerializedName(value = "code")
private final String code;
@SerializedName(value = "detail")
private final String detail;
@SerializedName(value = "id")
private final String id;
@SerializedName(value = "meta")
private final Object meta;
@SerializedName(value = "source")
private final Source source;
@SerializedName(value = "status")
private final HttpStatus status;
@SerializedName(value = "title")
private final String title;
public Error(String id, String title, HttpStatus status, Object meta, Source source) { | // Path: src/main/java/com/github/easyjsonapi/asserts/Validation.java
// public class Validation {
//
// /**
// * Check if object is valid. One object is valid when has one of the rules
// * below:
// *
// * - is an instance of {@link Map}
// * - has the annotation {@link Attributes}
// * - has the annotation {@link Meta}
// *
// * @param objectAnnotated
// * the object needs validate
// */
// public static void checkValidObject(Object objectAnnotated) {
//
// boolean notAnnotated = true;
//
// if (Assert.isNull(objectAnnotated)) {
// notAnnotated = false;
// } else if (objectAnnotated instanceof Map) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Attributes.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Meta.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(MetaRelationship.class))) {
// notAnnotated = false;
// }
//
// if (notAnnotated) {
// throw new EasyJsonApiEntityException("Invalid object inserted! Please check the annotation inside the pojo!");
// }
//
// }
//
// }
// Path: src/main/java/com/github/easyjsonapi/entities/Error.java
import com.github.easyjsonapi.asserts.Validation;
import com.google.gson.annotations.SerializedName;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
/**
* Entity represents error resource object in json api specification
*
* @author Nuno Bento (nbento.neves@gmail.com)
* @see {@link JsonApi}
* @see {@link Source}
* @see {@link HttpStatus}
*/
public final class Error implements Cloneable {
@SerializedName(value = "code")
private final String code;
@SerializedName(value = "detail")
private final String detail;
@SerializedName(value = "id")
private final String id;
@SerializedName(value = "meta")
private final Object meta;
@SerializedName(value = "source")
private final Source source;
@SerializedName(value = "status")
private final HttpStatus status;
@SerializedName(value = "title")
private final String title;
public Error(String id, String title, HttpStatus status, Object meta, Source source) { | Validation.checkValidObject(meta); |
easyJsonApi/easyJsonApi | src/main/java/com/github/easyjsonapi/entities/Data.java | // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/asserts/Validation.java
// public class Validation {
//
// /**
// * Check if object is valid. One object is valid when has one of the rules
// * below:
// *
// * - is an instance of {@link Map}
// * - has the annotation {@link Attributes}
// * - has the annotation {@link Meta}
// *
// * @param objectAnnotated
// * the object needs validate
// */
// public static void checkValidObject(Object objectAnnotated) {
//
// boolean notAnnotated = true;
//
// if (Assert.isNull(objectAnnotated)) {
// notAnnotated = false;
// } else if (objectAnnotated instanceof Map) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Attributes.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Meta.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(MetaRelationship.class))) {
// notAnnotated = false;
// }
//
// if (notAnnotated) {
// throw new EasyJsonApiEntityException("Invalid object inserted! Please check the annotation inside the pojo!");
// }
//
// }
//
// }
| import com.github.easyjsonapi.asserts.Assert;
import com.github.easyjsonapi.asserts.Validation;
import com.google.gson.annotations.SerializedName; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
/**
* Entity represents data resource object in json api specification
*
* @author Nuno Bento (nbento.neves@gmail.com)
* @see {@link JsonApi}
* @see {@link Relationships}
*/
public final class Data implements Cloneable {
@SerializedName(value = "attributes")
private final Object attr;
@SerializedName(value = "id")
private final String id;
// @SerializedName(value = "links")
// private final Object links;
@SerializedName(value = "relationships")
private Relationships rels;
@SerializedName(value = "type")
private final String type;
public Data(String id, String type, Object attr) { | // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/asserts/Validation.java
// public class Validation {
//
// /**
// * Check if object is valid. One object is valid when has one of the rules
// * below:
// *
// * - is an instance of {@link Map}
// * - has the annotation {@link Attributes}
// * - has the annotation {@link Meta}
// *
// * @param objectAnnotated
// * the object needs validate
// */
// public static void checkValidObject(Object objectAnnotated) {
//
// boolean notAnnotated = true;
//
// if (Assert.isNull(objectAnnotated)) {
// notAnnotated = false;
// } else if (objectAnnotated instanceof Map) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Attributes.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Meta.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(MetaRelationship.class))) {
// notAnnotated = false;
// }
//
// if (notAnnotated) {
// throw new EasyJsonApiEntityException("Invalid object inserted! Please check the annotation inside the pojo!");
// }
//
// }
//
// }
// Path: src/main/java/com/github/easyjsonapi/entities/Data.java
import com.github.easyjsonapi.asserts.Assert;
import com.github.easyjsonapi.asserts.Validation;
import com.google.gson.annotations.SerializedName;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
/**
* Entity represents data resource object in json api specification
*
* @author Nuno Bento (nbento.neves@gmail.com)
* @see {@link JsonApi}
* @see {@link Relationships}
*/
public final class Data implements Cloneable {
@SerializedName(value = "attributes")
private final Object attr;
@SerializedName(value = "id")
private final String id;
// @SerializedName(value = "links")
// private final Object links;
@SerializedName(value = "relationships")
private Relationships rels;
@SerializedName(value = "type")
private final String type;
public Data(String id, String type, Object attr) { | Validation.checkValidObject(attr); |
easyJsonApi/easyJsonApi | src/main/java/com/github/easyjsonapi/entities/Data.java | // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/asserts/Validation.java
// public class Validation {
//
// /**
// * Check if object is valid. One object is valid when has one of the rules
// * below:
// *
// * - is an instance of {@link Map}
// * - has the annotation {@link Attributes}
// * - has the annotation {@link Meta}
// *
// * @param objectAnnotated
// * the object needs validate
// */
// public static void checkValidObject(Object objectAnnotated) {
//
// boolean notAnnotated = true;
//
// if (Assert.isNull(objectAnnotated)) {
// notAnnotated = false;
// } else if (objectAnnotated instanceof Map) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Attributes.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Meta.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(MetaRelationship.class))) {
// notAnnotated = false;
// }
//
// if (notAnnotated) {
// throw new EasyJsonApiEntityException("Invalid object inserted! Please check the annotation inside the pojo!");
// }
//
// }
//
// }
| import com.github.easyjsonapi.asserts.Assert;
import com.github.easyjsonapi.asserts.Validation;
import com.google.gson.annotations.SerializedName; | this.rels = rels;
}
/*
* (non-Javadoc)
* @see java.lang.Object#clone()
*/
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
/**
* @return the attr
*/
public Object getAttr() {
return attr;
}
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @return the rels
*/
public Relationships getRels() { | // Path: src/main/java/com/github/easyjsonapi/asserts/Assert.java
// public class Assert {
//
// /**
// * Check if string is null or empty
// *
// * @param value the string value
// * @return true if string is null or empty and false when occur the opposite
// */
// public static boolean isEmpty(String value) {
//
// if (value != null && !value.isEmpty()) {
// return false;
// }
// return true;
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object is null and false when occur the opposite
// */
// public static boolean isNull(Object value) {
// if (value == null) {
// return true;
// }
//
// return false;
// }
//
// /**
// * Check if list of objects are null
// *
// * @param values the list with objects
// * @return true if list with objects are null and false when occur the
// * opposite
// */
// public static boolean isNull(Object... values) {
//
// boolean anyNotNullable = false;
//
// int index = 0;
//
// while (index < values.length && !anyNotNullable) {
// if (notNull(values[index])) {
// anyNotNullable = true;
// }
// index++;
// }
//
// return !anyNotNullable;
// }
//
// /**
// * Check if string is not null or empty
// *
// * @param value the string value
// * @return true if string has value and false when string is null or empty
// */
// public static boolean notEmpty(String value) {
// return !isEmpty(value);
// }
//
// /**
// * Check if object is null
// *
// * @param value the object value
// * @return true if object has value and false when object is null
// */
// public static boolean notNull(Object value) {
// return !isNull(value);
// }
//
// }
//
// Path: src/main/java/com/github/easyjsonapi/asserts/Validation.java
// public class Validation {
//
// /**
// * Check if object is valid. One object is valid when has one of the rules
// * below:
// *
// * - is an instance of {@link Map}
// * - has the annotation {@link Attributes}
// * - has the annotation {@link Meta}
// *
// * @param objectAnnotated
// * the object needs validate
// */
// public static void checkValidObject(Object objectAnnotated) {
//
// boolean notAnnotated = true;
//
// if (Assert.isNull(objectAnnotated)) {
// notAnnotated = false;
// } else if (objectAnnotated instanceof Map) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Attributes.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Meta.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(MetaRelationship.class))) {
// notAnnotated = false;
// }
//
// if (notAnnotated) {
// throw new EasyJsonApiEntityException("Invalid object inserted! Please check the annotation inside the pojo!");
// }
//
// }
//
// }
// Path: src/main/java/com/github/easyjsonapi/entities/Data.java
import com.github.easyjsonapi.asserts.Assert;
import com.github.easyjsonapi.asserts.Validation;
import com.google.gson.annotations.SerializedName;
this.rels = rels;
}
/*
* (non-Javadoc)
* @see java.lang.Object#clone()
*/
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
/**
* @return the attr
*/
public Object getAttr() {
return attr;
}
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @return the rels
*/
public Relationships getRels() { | if (Assert.isNull(rels)) { |
easyJsonApi/easyJsonApi | src/main/java/com/github/easyjsonapi/entities/LinkRelated.java | // Path: src/main/java/com/github/easyjsonapi/asserts/Validation.java
// public class Validation {
//
// /**
// * Check if object is valid. One object is valid when has one of the rules
// * below:
// *
// * - is an instance of {@link Map}
// * - has the annotation {@link Attributes}
// * - has the annotation {@link Meta}
// *
// * @param objectAnnotated
// * the object needs validate
// */
// public static void checkValidObject(Object objectAnnotated) {
//
// boolean notAnnotated = true;
//
// if (Assert.isNull(objectAnnotated)) {
// notAnnotated = false;
// } else if (objectAnnotated instanceof Map) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Attributes.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Meta.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(MetaRelationship.class))) {
// notAnnotated = false;
// }
//
// if (notAnnotated) {
// throw new EasyJsonApiEntityException("Invalid object inserted! Please check the annotation inside the pojo!");
// }
//
// }
//
// }
| import com.github.easyjsonapi.asserts.Validation;
import com.google.gson.annotations.SerializedName; | /*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
/**
* Entity represents related resource object in json api specification
*
* @author Nuno Bento (nbento.neves@gmail.com)
* @see {@link Link}
*/
public final class LinkRelated {
@SerializedName(value = "href")
private final String href;
@SerializedName(value = "meta")
private final Object meta;
public LinkRelated(String href, Object meta) {
super(); | // Path: src/main/java/com/github/easyjsonapi/asserts/Validation.java
// public class Validation {
//
// /**
// * Check if object is valid. One object is valid when has one of the rules
// * below:
// *
// * - is an instance of {@link Map}
// * - has the annotation {@link Attributes}
// * - has the annotation {@link Meta}
// *
// * @param objectAnnotated
// * the object needs validate
// */
// public static void checkValidObject(Object objectAnnotated) {
//
// boolean notAnnotated = true;
//
// if (Assert.isNull(objectAnnotated)) {
// notAnnotated = false;
// } else if (objectAnnotated instanceof Map) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Attributes.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(Meta.class))) {
// notAnnotated = false;
// } else if (Assert.notNull(objectAnnotated.getClass().getAnnotation(MetaRelationship.class))) {
// notAnnotated = false;
// }
//
// if (notAnnotated) {
// throw new EasyJsonApiEntityException("Invalid object inserted! Please check the annotation inside the pojo!");
// }
//
// }
//
// }
// Path: src/main/java/com/github/easyjsonapi/entities/LinkRelated.java
import com.github.easyjsonapi.asserts.Validation;
import com.google.gson.annotations.SerializedName;
/*
* #%L
* EasyJsonApi
* %%
* Copyright (C) 2016 EasyJsonApi
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.github.easyjsonapi.entities;
/**
* Entity represents related resource object in json api specification
*
* @author Nuno Bento (nbento.neves@gmail.com)
* @see {@link Link}
*/
public final class LinkRelated {
@SerializedName(value = "href")
private final String href;
@SerializedName(value = "meta")
private final Object meta;
public LinkRelated(String href, Object meta) {
super(); | Validation.checkValidObject(meta); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.