package com.anyun.exam.lib.net
|
|
import android.util.Base64
|
import android.util.Log
|
import java.nio.charset.StandardCharsets
|
|
class NtripTcpClient(session: TcpSession) : NettyTcpClient(session) {
|
companion object {
|
|
}
|
|
fun sendNtripRequest(clientName: String, mountPoint: String,
|
username: String, password: String) {
|
val request = "GET /" + mountPoint + " HTTP/1.1\r\n" + "Host: " +
|
clientName + "\r\n" + "User-Agent: NTRIP " +
|
clientName + "\r\n" + "Authorization: Basic " +
|
encodeBase64(username + ":" + password) + "\r\n" +
|
"Ntrip-Version: Ntrip/2.0\r\n" + "Connection: keep-alive\r\n\r\n"
|
|
writeAndFlush(request)
|
}
|
|
private fun encodeBase64(value: String): String? {
|
return Base64.encodeToString(value.toByteArray(StandardCharsets.UTF_8), Base64.NO_WRAP)
|
}
|
}
|