// Path: erlymon-monitor-app/src/main/java/com/appunite/websocket/rx/object/GsonObjectSerializer.java
// public class GsonObjectSerializer implements ObjectSerializer {
// 
//     @Nonnull
//     private final Gson gson;
//     @Nonnull
//     private final Type typeOfT;
// 
//     public GsonObjectSerializer(@Nonnull Gson gson, @Nonnull Type typeOfT) {
//         this.gson = gson;
//         this.typeOfT = typeOfT;
//     }
// 
//     @Nonnull
//     @Override
//     public Object serialize(@Nonnull String message) throws ObjectParseException {
//         try {
//             return gson.fromJson(message, typeOfT);
//         } catch (JsonParseException e) {
//             throw new ObjectParseException("Could not parse", e);
//         }
//     }
// 
//     @Nonnull
//     @Override
//     public Object serialize(@Nonnull byte[] message) throws ObjectParseException {
//         throw new ObjectParseException("Could not parse binary messages");
//     }
// 
//     @Nonnull
//     @Override
//     public byte[] deserializeBinary(@Nonnull Object message) throws ObjectParseException {
//         throw new IllegalStateException("Only serialization to string is available");
//     }
// 
//     @Nonnull
//     @Override
//     public String deserializeString(@Nonnull Object message) throws ObjectParseException {
//         try {
//             return gson.toJson(message);
//         } catch (JsonParseException e) {
//             throw new ObjectParseException("Could not parse", e);
//         }
//     }
// 
//     @Override
//     public boolean isBinary(@Nonnull Object message) {
//         return false;
//     }
// }
// 
// Path: erlymon-monitor-app/src/main/java/org/erlymon/monitor/mvp/model/Event.java
// public class Event {
//     private List<Device> devices;
//     private List<Position> positions;
// 
//     public Event() {}
// 
//     public Event(List<Device> devices, List<Position> positions) {
//         this.devices = devices;
//         this.positions = positions;
//     }
//     public List<Device> getDevices() {
//         return devices;
//     }
// 
//     public List<Position> getPositions() {
//         return positions;
//     }
// 
//     @Override
//     public String toString() {
//         return "Event{" +
//                 "devices=" + devices +
//                 ", positions=" + positions +
//                 '}';
//     }
// }


import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import android.content.SharedPreferences;
import com.appunite.websocket.rx.RxWebSockets;
import com.appunite.websocket.rx.object.GsonObjectSerializer;
import com.appunite.websocket.rx.object.ObjectSerializer;
import com.appunite.websocket.rx.object.RxObjectWebSockets;
import com.google.gson.Gson;
import org.erlymon.monitor.mvp.model.Event;
import javax.inject.Singleton;
/*
 * Copyright (c) 2016, Sergey Penkovsky <sergey.penkovsky@gmail.com>
 *
 * This file is part of Erlymon Monitor.
 *
 * Erlymon Monitor is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Erlymon Monitor is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Erlymon Monitor.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.erlymon.monitor.dagger.module;







/**
 * Created by sergey on 17.03.17.
 */

@Module(includes = {HttpClientModule.class, GsonModule.class})
public class WebSocketModule {
    @Provides
    @Singleton
    public RxObjectWebSockets provideRxObjectWebSockets(RxWebSockets rxWebSockets, ObjectSerializer serializer) {
        return new RxObjectWebSockets(rxWebSockets, serializer);
    }

    @Provides
    @Singleton
// Path: erlymon-monitor-app/src/main/java/com/appunite/websocket/rx/object/GsonObjectSerializer.java
// public class GsonObjectSerializer implements ObjectSerializer {
// 
//     @Nonnull
//     private final Gson gson;
//     @Nonnull
//     private final Type typeOfT;
// 
//     public GsonObjectSerializer(@Nonnull Gson gson, @Nonnull Type typeOfT) {
//         this.gson = gson;
//         this.typeOfT = typeOfT;
//     }
// 
//     @Nonnull
//     @Override
//     public Object serialize(@Nonnull String message) throws ObjectParseException {
//         try {
//             return gson.fromJson(message, typeOfT);
//         } catch (JsonParseException e) {
//             throw new ObjectParseException("Could not parse", e);
//         }
//     }
// 
//     @Nonnull
//     @Override
//     public Object serialize(@Nonnull byte[] message) throws ObjectParseException {
//         throw new ObjectParseException("Could not parse binary messages");
//     }
// 
//     @Nonnull
//     @Override
//     public byte[] deserializeBinary(@Nonnull Object message) throws ObjectParseException {
//         throw new IllegalStateException("Only serialization to string is available");
//     }
// 
//     @Nonnull
//     @Override
//     public String deserializeString(@Nonnull Object message) throws ObjectParseException {
//         try {
//             return gson.toJson(message);
//         } catch (JsonParseException e) {
//             throw new ObjectParseException("Could not parse", e);
//         }
//     }
// 
//     @Override
//     public boolean isBinary(@Nonnull Object message) {
//         return false;
//     }
// }
// 
// Path: erlymon-monitor-app/src/main/java/org/erlymon/monitor/mvp/model/Event.java
// public class Event {
//     private List<Device> devices;
//     private List<Position> positions;
// 
//     public Event() {}
// 
//     public Event(List<Device> devices, List<Position> positions) {
//         this.devices = devices;
//         this.positions = positions;
//     }
//     public List<Device> getDevices() {
//         return devices;
//     }
// 
//     public List<Position> getPositions() {
//         return positions;
//     }
// 
//     @Override
//     public String toString() {
//         return "Event{" +
//                 "devices=" + devices +
//                 ", positions=" + positions +
//                 '}';
//     }
// }


// Path: erlymon-monitor-app/src/main/java/org/erlymon/monitor/dagger/module/WebSocketModule.java
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import android.content.SharedPreferences;
import com.appunite.websocket.rx.RxWebSockets;
import com.appunite.websocket.rx.object.GsonObjectSerializer;
import com.appunite.websocket.rx.object.ObjectSerializer;
import com.appunite.websocket.rx.object.RxObjectWebSockets;
import com.google.gson.Gson;
import org.erlymon.monitor.mvp.model.Event;
import javax.inject.Singleton;

/*
 * Copyright (c) 2016, Sergey Penkovsky <sergey.penkovsky@gmail.com>
 *
 * This file is part of Erlymon Monitor.
 *
 * Erlymon Monitor is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Erlymon Monitor is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Erlymon Monitor.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.erlymon.monitor.dagger.module;







/**
 * Created by sergey on 17.03.17.
 */

@Module(includes = {HttpClientModule.class, GsonModule.class})
public class WebSocketModule {
    @Provides
    @Singleton
    public RxObjectWebSockets provideRxObjectWebSockets(RxWebSockets rxWebSockets, ObjectSerializer serializer) {
        return new RxObjectWebSockets(rxWebSockets, serializer);
    }

    @Provides
    @Singleton
    public RxWebSockets provideRxWebSockets(OkHttpClient client, SharedPreferences sharedPreferences) {