Skip to content

Commit 80dd5b2

Browse files
committed
More data in the broker message
- add docs for the new data types and properties - new DialPolicy data type
1 parent ae6a10e commit 80dd5b2

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

src/main/kotlin/com/coder/gateway/models/BrokerMessage.kt

+41-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,44 @@ import com.google.gson.annotations.SerializedName
44
import dev.onvoid.webrtc.RTCIceServer
55
import dev.onvoid.webrtc.RTCSessionDescription
66

7-
data class BrokerMessage(@SerializedName("offer") val offer: RTCSessionDescription, @SerializedName("servers") val servers: List<RTCIceServer>, @SerializedName("turn_proxy_url") val turnProxyUrl: String)
7+
/**
8+
* BrokerMessage is used for brokering a dialer and listener.
9+
*
10+
* Dialers initiate an exchange by providing an Offer, along with a list of ICE servers for the listener to peer with.
11+
* The listener should respond with an offer, then both sides can begin exchanging candidates.
12+
*
13+
*/
14+
data class BrokerMessage(
15+
// Dialer -> Listener
16+
@SerializedName("offer") val offer: RTCSessionDescription,
17+
@SerializedName("servers") val servers: List<RTCIceServer>,
18+
@SerializedName("turn_proxy_url") val turnProxyUrl: String,
19+
@SerializedName("ports") val ports: Array<DialPolicy>? = null,
20+
// Listener -> Dialer
21+
@SerializedName("error") val error: String? = "",
22+
@SerializedName("answer") val answer: RTCSessionDescription? = null,
23+
// Bidirectional
24+
@SerializedName("candidate") val candidate: String? = ""
25+
) {
26+
override fun equals(other: Any?): Boolean {
27+
if (this === other) return true
28+
if (javaClass != other?.javaClass) return false
29+
30+
other as BrokerMessage
31+
32+
if (offer != other.offer) return false
33+
if (servers != other.servers) return false
34+
if (turnProxyUrl != other.turnProxyUrl) return false
35+
if (!ports.contentEquals(other.ports)) return false
36+
37+
return true
38+
}
39+
40+
override fun hashCode(): Int {
41+
var result = offer.hashCode()
42+
result = 31 * result + servers.hashCode()
43+
result = 31 * result + turnProxyUrl.hashCode()
44+
result = 31 * result + ports.contentHashCode()
45+
return result
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.coder.gateway.models
2+
3+
import com.google.gson.annotations.SerializedName
4+
5+
/**
6+
* DialPolicy a single network + address + port combinations that a connection is permitted to use.
7+
* @param network if empty it applies to all networks
8+
* @param host the IP or hostname of the address. It should not contain the port. If empty, it applies to all hosts. "localhost", [::1], and any IPv4
9+
* address under "127.0.0.0/8" can be used interchangeably.
10+
* @param port it applies to all ports if value is 0
11+
*/
12+
data class DialPolicy(@SerializedName("network") val network: String?, @SerializedName("address") val host: String?, @SerializedName("port") val port: UShort?)

0 commit comments

Comments
 (0)