Commit fecf07e4 authored by pxl's avatar pxl
Browse files

proto

parent e32fe570
# SuZhouAvp # SuZhouAvp
停车场泊车 苏州 约等于(长春) AVP 停车场泊车 苏州 约等于(长春) AVP
https://protobuf.dev/getting-started/javatutorial/
protoc --java_out=app\src\main\java\ -I d:\WorkSpace\suzhouavp\app\src\main\proto\ d:\WorkSpace\suzhouavp\app\src\main\proto\response.proto
\ No newline at end of file
import org.gradle.internal.declarativedsl.parsing.main
import org.jetbrains.kotlin.gradle.internal.wrapPluginOptions
plugins { plugins {
alias(libs.plugins.android.application) alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.android)
id("dagger.hilt.android.plugin") id("dagger.hilt.android.plugin")
id("kotlin-kapt") id("kotlin-kapt")
id("com.google.protobuf") // id("com.google.protobuf")
// alias(libs.plugins.proto.google)
} }
android { android {
...@@ -46,39 +45,8 @@ android { ...@@ -46,39 +45,8 @@ android {
abortOnError=false abortOnError=false
checkReleaseBuilds=false checkReleaseBuilds=false
} }
sourceSets {
//配置 protoc 编译器
}
} }
protobuf {
//配置 protoc 编译器
// protoc {
// artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
// }
plugins {
// The codegen for lite comes as a separate artifact
// artifacts {
// "com.google.protobuf:protoc-gen-javalite:3.0.0"
// }
}
//配置生成目录,编译后会在 build 的目录下生成对应的java文件
generateProtoTasks {
all().forEach { task->
task.builtins {
// remove(com.google.protobuf.gradle.ProtobufPlugin.j)
// remove(java)
}
task.builtins {
java {
}
}
}
}
}
dependencies { dependencies {
implementation(fileTree(mapOf("dir" to "libs","include" to listOf("*.jar", "*.aar")))) implementation(fileTree(mapOf("dir" to "libs","include" to listOf("*.jar", "*.aar"))))
...@@ -91,9 +59,9 @@ dependencies { ...@@ -91,9 +59,9 @@ dependencies {
androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core) androidTestImplementation(libs.androidx.espresso.core)
implementation("com.google.protobuf:protobuf-java:3.19.2") implementation("com.google.protobuf:protobuf-java:4.31.1")
// implementation("com.google.protobuf:protobuf-lite:3.0.0") // implementation("com.google.protobuf:protobuf-javalite:4.31.1")
// implementation("com.google.protobuf:protobuf-lite:3.0.0") // implementation("com.google.protobuf:protoc:3.0.0")
// implementation("com.google.protobuf:protobuf-kotlin-lite:4.31.1") // implementation("com.google.protobuf:protobuf-kotlin-lite:4.31.1")
//java web socket //java web socket
......
...@@ -61,7 +61,7 @@ class MainVm @Inject constructor( ...@@ -61,7 +61,7 @@ class MainVm @Inject constructor(
} }
override fun onMessage(bytes: ByteBuffer?) { override fun onMessage(bytes: ByteBuffer?) {
// SocketResponse.parseFrom(bytes)
} }
override fun onClose(code: Int, reason: String?, remote: Boolean) { override fun onClose(code: Int, reason: String?, remote: Boolean) {
......
package com.sd.cavphmi.websockets package com.sd.cavphmi.websockets
import org.java_websocket.client.WebSocketClient import org.java_websocket.client.WebSocketClient
import org.java_websocket.drafts.Draft import org.java_websocket.drafts.Draft
import org.java_websocket.handshake.ServerHandshake import org.java_websocket.handshake.ServerHandshake
import protocol.Response.SocketResponse
import java.net.URI import java.net.URI
import java.nio.ByteBuffer import java.nio.ByteBuffer
...@@ -49,6 +51,8 @@ class MyWebSocketClient : WebSocketClient { ...@@ -49,6 +51,8 @@ class MyWebSocketClient : WebSocketClient {
override fun onMessage(bytes: ByteBuffer?) { override fun onMessage(bytes: ByteBuffer?) {
System.out.println(TAG + " received ByteBuffer") System.out.println(TAG + " received ByteBuffer")
var socketResponse=SocketResponse.parseFrom(bytes)
// socketResponse.
onSocketCb?.onMessage(bytes) onSocketCb?.onMessage(bytes)
} }
......
This diff is collapsed.
syntax = "proto3"; syntax = "proto3";
package com.sd.cavphmi; package protocol;
message SocketResponse { message SocketResponse {
int32 code = 1; int32 code = 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment