Commit 29/07/2025
This commit is contained in:
2
.idea/inspectionProfiles/Project_Default.xml
generated
2
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -2,11 +2,13 @@
|
|||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
<inspection_tool class="AiaStyle" enabled="false" level="TYPO" enabled_by_default="false" />
|
<inspection_tool class="AiaStyle" enabled="false" level="TYPO" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="FunctionName" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||||
<inspection_tool class="GrazieInspection" enabled="false" level="GRAMMAR_ERROR" enabled_by_default="false" />
|
<inspection_tool class="GrazieInspection" enabled="false" level="GRAMMAR_ERROR" enabled_by_default="false" />
|
||||||
<inspection_tool class="LanguageDetectionInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
<inspection_tool class="LanguageDetectionInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||||
<inspection_tool class="LocalVariableName" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
<inspection_tool class="LocalVariableName" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||||
<inspection_tool class="MethodNameSameAsClassName" enabled="false" level="WARNING" enabled_by_default="false" />
|
<inspection_tool class="MethodNameSameAsClassName" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
<inspection_tool class="PrivatePropertyName" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
<inspection_tool class="PrivatePropertyName" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="PropertyName" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||||
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
||||||
<option name="processCode" value="true" />
|
<option name="processCode" value="true" />
|
||||||
<option name="processLiterals" value="true" />
|
<option name="processLiterals" value="true" />
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ import zello.ZelloClient
|
|||||||
fun main() {
|
fun main() {
|
||||||
val z = ZelloClient.fromConsumerZello()
|
val z = ZelloClient.fromConsumerZello()
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
64
src/zello/LogonCommand.kt
Normal file
64
src/zello/LogonCommand.kt
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
package zello
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonPropertyOrder
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
@JsonPropertyOrder(value=["command","seq","auth_token","refresh_token","username","password","channels","listen_only","version","platform_type","platform_name"])
|
||||||
|
class LogonCommand(val seq: Int, val auth_token: String?, val refresh_token: String?, val username: String?, val password: String?, val channels: Array<String>, val listen_only: Boolean?, val version: String?, val platform_type: String?, val platform_name:String?) {
|
||||||
|
val command: String = "logon"
|
||||||
|
companion object {
|
||||||
|
/**
|
||||||
|
* Creates a LogonCommand with the specified sequence number and channels.
|
||||||
|
* auth_token, refresh_token, username, password, listen_only, version, platform_type, platform_name are omitted
|
||||||
|
* @param seq The sequence number for the command.
|
||||||
|
* @param channels An array of channel names to log on to.
|
||||||
|
* @return A new instance of LogonCommand.
|
||||||
|
*/
|
||||||
|
fun create(seq: Int, channels: Array<String>): LogonCommand {
|
||||||
|
return LogonCommand(seq, null, null, null, null, channels, null, null, null, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a LogonCommand with the specified sequence number, channels, and auth_token.
|
||||||
|
* refresh_token, username, password, listen_only, version, platform_type, platform_name are omitted
|
||||||
|
* @param seq The sequence number for the command.
|
||||||
|
* @param channels An array of channel names to log on to.
|
||||||
|
* @param auth_token API authentication token. If omitted refresh_token is required when connecting to consumer Zello
|
||||||
|
*
|
||||||
|
* See [Zello API](https://github.com/zelloptt/zello-channel-api/blob/master/API.md#authentication)
|
||||||
|
* @return A new instance of LogonCommand.
|
||||||
|
*/
|
||||||
|
fun create(seq: Int, channels: Array<String>, auth_token: String?): LogonCommand {
|
||||||
|
return LogonCommand(seq, auth_token, null, null, null, channels, null, null, null, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a LogonCommand with the specified sequence number, channels, auth_token, username, and password.
|
||||||
|
* refresh_token, listen_only, version, platform_type, platform_name are omitted
|
||||||
|
* @param seq The sequence number for the command.
|
||||||
|
* @param channels An array of channel names to log on to.
|
||||||
|
* @param auth_token API authentication token. If omitted refresh_token is required when connecting to consumer Zello
|
||||||
|
* @param username Username for authentication.
|
||||||
|
* @param password Password for authentication.
|
||||||
|
* @return A new instance of LogonCommand.
|
||||||
|
*/
|
||||||
|
fun create(seq: Int, channels: Array<String>, auth_token: String?, username: String?, password: String?): LogonCommand {
|
||||||
|
return LogonCommand(seq, auth_token, null, username, password, channels, null, null, null, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a LogonCommand with the specified sequence number, channels, auth_token, refresh_token, username, and password.
|
||||||
|
* listen_only, version, platform_type, platform_name are omitted
|
||||||
|
* @param seq The sequence number for the command.
|
||||||
|
* @param channels An array of channel names to log on to.
|
||||||
|
* @param auth_token API authentication token. If omitted refresh_token is required when connecting to consumer Zello
|
||||||
|
* @param refresh_token API refresh token. If omitted auth_token is required when connecting to consumer Zello.
|
||||||
|
* @param username Username for authentication.
|
||||||
|
* @param password Password for authentication.
|
||||||
|
* @return A new instance of LogonCommand.
|
||||||
|
*/
|
||||||
|
fun create(seq: Int, channels: Array<String>, auth_token: String?, refresh_token: String?, username: String?, password: String?): LogonCommand {
|
||||||
|
return LogonCommand(seq, auth_token, refresh_token, username, password, channels, null, null, null, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/zello/LogonReply.kt
Normal file
9
src/zello/LogonReply.kt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package zello
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
class LogonReply {
|
||||||
|
var seq: Int = 0
|
||||||
|
var success : Boolean? = null
|
||||||
|
var refresh_token: String? = null
|
||||||
|
var error: String? = null
|
||||||
|
}
|
||||||
@@ -2,11 +2,18 @@ package zello
|
|||||||
|
|
||||||
import org.java_websocket.client.WebSocketClient
|
import org.java_websocket.client.WebSocketClient
|
||||||
import org.java_websocket.handshake.ServerHandshake
|
import org.java_websocket.handshake.ServerHandshake
|
||||||
|
import org.slf4j.Logger
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
class ZelloClient(address : URI) : WebSocketClient(address) {
|
/**
|
||||||
|
* ZelloClient is a WebSocket client for connecting to Zello services.
|
||||||
|
* [Source](https://github.com/zelloptt/zello-channel-api/blob/master/API.md)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class ZelloClient(val address : URI) {
|
||||||
companion object {
|
companion object {
|
||||||
fun fromConsumerZello() : ZelloClient {
|
fun fromConsumerZello() : ZelloClient {
|
||||||
return ZelloClient(URI.create("wss://zello.io/ws"))
|
return ZelloClient(URI.create("wss://zello.io/ws"))
|
||||||
@@ -21,25 +28,44 @@ class ZelloClient(address : URI) : WebSocketClient(address) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var client : WebSocketClient? = null
|
||||||
|
|
||||||
// this key is temporary, valid only 30 days from 2025-07-29
|
// this key is temporary, valid only 30 days from 2025-07-29
|
||||||
// if need to create, from https://developers.zello.com/keys
|
// if need to create, from https://developers.zello.com/keys
|
||||||
private val developerKey : String = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJXa002Y21ScllYSjBiMjV2T2pFLi1yYjJ2THFRbUhYV3dKY2I2azl2TDdUMEtzRWZMRjcxZm5jcktTZ0s2ZE0iLCJleHAiOjE3NTY0MzIyMTIsImF6cCI6ImRldiJ9.ANK7BIS6WVVWsQRjcZXyGWrV2RodCUQD4WXWaA6E4Dlyy8bBCMFdbiKN2D7B_x729HQULailnfRhbXF4Avfg14qONdc1XE_0iGiPUO1kfUSgdd11QylOzjxy6FTKSeZmHOh65JZq2dIWxobCcva-RPvbR8TA656upHh32xrWv9zlU0N707FTca04kze0Iq-q-uC5EL82yK10FEvOPDX88MYy71QRYi8Qh_KbSyMcYAhe2bTsiyjm51ZH9ntkRHd0HNiaijNZI6-qXkkp5Soqmzh-bTtbbgmbX4BT3Qpz_IP3epaX3jl_Aq5DHxXwCsJ9FThif9um5D0TWVGQteR0cQ"
|
private val developerKey : String = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJXa002Y21ScllYSjBiMjV2T2pFLi1yYjJ2THFRbUhYV3dKY2I2azl2TDdUMEtzRWZMRjcxZm5jcktTZ0s2ZE0iLCJleHAiOjE3NTY0MzIyMTIsImF6cCI6ImRldiJ9.ANK7BIS6WVVWsQRjcZXyGWrV2RodCUQD4WXWaA6E4Dlyy8bBCMFdbiKN2D7B_x729HQULailnfRhbXF4Avfg14qONdc1XE_0iGiPUO1kfUSgdd11QylOzjxy6FTKSeZmHOh65JZq2dIWxobCcva-RPvbR8TA656upHh32xrWv9zlU0N707FTca04kze0Iq-q-uC5EL82yK10FEvOPDX88MYy71QRYi8Qh_KbSyMcYAhe2bTsiyjm51ZH9ntkRHd0HNiaijNZI6-qXkkp5Soqmzh-bTtbbgmbX4BT3Qpz_IP3epaX3jl_Aq5DHxXwCsJ9FThif9um5D0TWVGQteR0cQ"
|
||||||
|
private val logger : Logger = LoggerFactory.getLogger(ZelloClient::class.java)
|
||||||
|
var isConnected : Boolean = false
|
||||||
|
|
||||||
|
fun Start(){
|
||||||
|
client = object : WebSocketClient(address) {
|
||||||
override fun onOpen(handshakedata: ServerHandshake?) {
|
override fun onOpen(handshakedata: ServerHandshake?) {
|
||||||
TODO("Not yet implemented")
|
logger.info("Connected to $address")
|
||||||
|
isConnected = true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMessage(message: String?) {
|
override fun onMessage(message: String?) {
|
||||||
TODO("Not yet implemented")
|
logger.info("Message received: $message")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClose(code: Int, reason: String?, remote: Boolean) {
|
override fun onClose(code: Int, reason: String?, remote: Boolean) {
|
||||||
TODO("Not yet implemented")
|
logger.info("Closed from ${if (remote) "Remote side" else "Local side"}, Code=$code, Reason=$reason")
|
||||||
|
isConnected = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(ex: Exception?) {
|
override fun onError(ex: Exception?) {
|
||||||
TODO("Not yet implemented")
|
logger.error("Error occurred: ${ex?.message}")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
client?.connect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Stop(){
|
||||||
|
client?.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user