// Path: ddp-client/src/main/java/io/advantageous/ddp/ConnectedMessage.java
// public class ConnectedMessage {
// 
//     private String session;
// 
//     public String getSession() {
//         return session;
//     }
// 
//     public void setSession(String session) {
//         this.session = session;
//     }
// }
// 
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
//     void disconnect() throws IOException;
// 
//     void connect(String address) throws IOException, InterruptedException;
// 
//     <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
// 
//     <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
// 
//     void await() throws InterruptedException;
// 
//     void send(Object message) throws IOException;
// 
// }
// 
// Path: ddp-client/src/main/java/io/advantageous/ddp/ErrorMessage.java
// public class ErrorMessage {
// 
//     private String reason;
// 
//     private Object offendingMessage;
// 
//     public String getReason() {
//         return reason;
//     }
// 
//     public void setReason(String reason) {
//         this.reason = reason;
//     }
// 
//     public Object getOffendingMessage() {
//         return offendingMessage;
//     }
// 
//     public void setOffendingMessage(Object offendingMessage) {
//         this.offendingMessage = offendingMessage;
//     }
// 
//     @Override
//     public String toString() {
//         return "Error{" +
//                 "reason='" + reason + '\'' +
//                 ", offendingMessage=" + offendingMessage +
//                 '}';
//     }
// }
// 
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/Subscription.java
// public class Subscription {
// 
//     private final String subscriptionName;
// 
//     private final Object[] params;
// 
//     private final Class clazz;
// 
//     private final Callback callback;
// 
//     public Subscription(String subscriptionName, Object[] params, Class clazz, Callback callback) {
//         this.subscriptionName = subscriptionName;
//         this.params = params;
//         this.clazz = clazz;
//         this.callback = callback;
//     }
// 
//     public Subscription(String subscriptionName) {
//         this(subscriptionName, null, Object.class, null);
//     }
// 
//     public Subscription(String subscriptionName, Object[] params) {
//         this(subscriptionName, params, Object.class, null);
//     }
// 
//     public Subscription(String subscriptionName, Class clazz) {
//         this(subscriptionName, null, clazz, null);
//     }
// 
//     public Subscription(String subscriptionName, Object[] params, Class clazz) {
//         this(subscriptionName, params, clazz, null);
//     }
// 
//     public Subscription(String subscriptionName, Class clazz, Callback callback) {
//         this(subscriptionName, null, clazz, callback);
//     }
// 
//     public Subscription(String subscriptionName, Object[] params, Callback callback) {
//         this(subscriptionName, params, Object.class, callback);
//     }
// 
//     public String getSubscriptionName() {
//         return subscriptionName;
//     }
// 
//     public Object[] getParams() {
//         return params;
//     }
// 
//     public Class getClazz() {
//         return clazz;
//     }
// 
//     public Callback getCallback() {
//         return callback;
//     }
// 
//     /**
//      * Callback run when a subscription is handled.
//      */
//     public interface Callback {
// 
//         void onReady(String subscriptionId);
// 
//         void onFailure(String subscriptionId, DDPError error);
//     }
// }
// 
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/SubscriptionAdapter.java
// public interface SubscriptionAdapter {
// 
//     void subscribe(Subscription subscription) throws IOException;
// 
//     void unsubscribe(String subscriptionId) throws IOException;
// 
// }


import javax.inject.Inject;
import java.io.IOException;
import com.google.inject.Guice;
import io.advantageous.ddp.ConnectedMessage;
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.ErrorMessage;
import io.advantageous.ddp.subscription.Subscription;
import io.advantageous.ddp.subscription.SubscriptionAdapter;
import javafx.application.Application;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
 * Copyright (C) 2014. Geoffrey Chandler.
 *
 * 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 io.advantageous.ddp.example;



public class SampleApplication extends Application {

    private static final Logger LOGGER = LoggerFactory.getLogger(SampleApplication.class);

    @Inject
    private DDPMessageEndpoint endpoint;

    @Inject
    private MainViewController mainController;

    @Inject
    private SubscriptionAdapter adapter;

    {
        Guice.createInjector(new SampleApplicationModule()).injectMembers(this);
// Path: ddp-client/src/main/java/io/advantageous/ddp/ConnectedMessage.java
// public class ConnectedMessage {
// 
//     private String session;
// 
//     public String getSession() {
//         return session;
//     }
// 
//     public void setSession(String session) {
//         this.session = session;
//     }
// }
// 
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
//     void disconnect() throws IOException;
// 
//     void connect(String address) throws IOException, InterruptedException;
// 
//     <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
// 
//     <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
// 
//     void await() throws InterruptedException;
// 
//     void send(Object message) throws IOException;
// 
// }
// 
// Path: ddp-client/src/main/java/io/advantageous/ddp/ErrorMessage.java
// public class ErrorMessage {
// 
//     private String reason;
// 
//     private Object offendingMessage;
// 
//     public String getReason() {
//         return reason;
//     }
// 
//     public void setReason(String reason) {
//         this.reason = reason;
//     }
// 
//     public Object getOffendingMessage() {
//         return offendingMessage;
//     }
// 
//     public void setOffendingMessage(Object offendingMessage) {
//         this.offendingMessage = offendingMessage;
//     }
// 
//     @Override
//     public String toString() {
//         return "Error{" +
//                 "reason='" + reason + '\'' +
//                 ", offendingMessage=" + offendingMessage +
//                 '}';
//     }
// }
// 
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/Subscription.java
// public class Subscription {
// 
//     private final String subscriptionName;
// 
//     private final Object[] params;
// 
//     private final Class clazz;
// 
//     private final Callback callback;
// 
//     public Subscription(String subscriptionName, Object[] params, Class clazz, Callback callback) {
//         this.subscriptionName = subscriptionName;
//         this.params = params;
//         this.clazz = clazz;
//         this.callback = callback;
//     }
// 
//     public Subscription(String subscriptionName) {
//         this(subscriptionName, null, Object.class, null);
//     }
// 
//     public Subscription(String subscriptionName, Object[] params) {
//         this(subscriptionName, params, Object.class, null);
//     }
// 
//     public Subscription(String subscriptionName, Class clazz) {
//         this(subscriptionName, null, clazz, null);
//     }
// 
//     public Subscription(String subscriptionName, Object[] params, Class clazz) {
//         this(subscriptionName, params, clazz, null);
//     }
// 
//     public Subscription(String subscriptionName, Class clazz, Callback callback) {
//         this(subscriptionName, null, clazz, callback);
//     }
// 
//     public Subscription(String subscriptionName, Object[] params, Callback callback) {
//         this(subscriptionName, params, Object.class, callback);
//     }
// 
//     public String getSubscriptionName() {
//         return subscriptionName;
//     }
// 
//     public Object[] getParams() {
//         return params;
//     }
// 
//     public Class getClazz() {
//         return clazz;
//     }
// 
//     public Callback getCallback() {
//         return callback;
//     }
// 
//     /**
//      * Callback run when a subscription is handled.
//      */
//     public interface Callback {
// 
//         void onReady(String subscriptionId);
// 
//         void onFailure(String subscriptionId, DDPError error);
//     }
// }
// 
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/SubscriptionAdapter.java
// public interface SubscriptionAdapter {
// 
//     void subscribe(Subscription subscription) throws IOException;
// 
//     void unsubscribe(String subscriptionId) throws IOException;
// 
// }


// Path: examples/java-fx/src/main/java/io/advantageous/ddp/example/SampleApplication.java
import javax.inject.Inject;
import java.io.IOException;
import com.google.inject.Guice;
import io.advantageous.ddp.ConnectedMessage;
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.ErrorMessage;
import io.advantageous.ddp.subscription.Subscription;
import io.advantageous.ddp.subscription.SubscriptionAdapter;
import javafx.application.Application;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/*
 * Copyright (C) 2014. Geoffrey Chandler.
 *
 * 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 io.advantageous.ddp.example;



public class SampleApplication extends Application {

    private static final Logger LOGGER = LoggerFactory.getLogger(SampleApplication.class);

    @Inject
    private DDPMessageEndpoint endpoint;

    @Inject
    private MainViewController mainController;

    @Inject
    private SubscriptionAdapter adapter;

    {
        Guice.createInjector(new SampleApplicationModule()).injectMembers(this);
        endpoint.registerHandler(ErrorMessage.class, message -> LOGGER.error(message.getReason()));