Skip to content

Commit

Permalink
add ConnectCheckerEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Mar 13, 2024
1 parent 2b03e8f commit 1c9ab0d
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
62 changes: 62 additions & 0 deletions common/src/main/java/com/pedro/common/ConnectCheckerEvent.java
@@ -0,0 +1,62 @@
/*
* Copyright (C) 2023 pedroSG94.
*
* 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.pedro.common;

import org.jetbrains.annotations.NotNull;

/**
* Created by pedro on 8/3/24.
*/
public interface ConnectCheckerEvent extends ConnectChecker {

void onStreamEvent(StreamEvent event, String message);

@Override
default void onConnectionStarted(@NotNull String url) {
onStreamEvent(StreamEvent.STARTED, url);
}

@Override
default void onConnectionSuccess() {
onStreamEvent(StreamEvent.CONNECTED, "");
}

@Override
default void onConnectionFailed(@NotNull String reason) {
onStreamEvent(StreamEvent.FAILED, reason);
}

@Override
default void onNewBitrate(long bitrate) {
onStreamEvent(StreamEvent.NEW_BITRATE, Long.toString(bitrate));
}

@Override
default void onDisconnect() {
onStreamEvent(StreamEvent.DISCONNECTED, "");
}

@Override
default void onAuthError() {
onStreamEvent(StreamEvent.AUTH_ERROR, "");
}

@Override
default void onAuthSuccess() {
onStreamEvent(StreamEvent.AUTH_SUCCESS, "");
}
}
25 changes: 25 additions & 0 deletions common/src/main/java/com/pedro/common/StreamEvent.kt
@@ -0,0 +1,25 @@
/*
* Copyright (C) 2023 pedroSG94.
*
* 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.pedro.common

/**
* Created by pedro on 8/3/24.
*/
enum class StreamEvent {

STARTED, CONNECTED, DISCONNECTED, FAILED, NEW_BITRATE, AUTH_ERROR, AUTH_SUCCESS
}

0 comments on commit 1c9ab0d

Please sign in to comment.