Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
p x
SuZhouAvp
Commits
fecf07e4
Commit
fecf07e4
authored
Jun 13, 2025
by
pxl
Browse files
proto
parent
e32fe570
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
fecf07e4
# SuZhouAvp
# SuZhouAvp
停车场泊车 苏州 约等于(长春) AVP
停车场泊车 苏州 约等于(长春) AVP
\ No newline at end of file
https://protobuf.dev/getting-started/javatutorial/
protoc --java_out=app
\s
rc
\m
ain
\j
ava
\
-I d:
\W
orkSpace
\s
uzhouavp
\a
pp
\s
rc
\m
ain
\p
roto
\
d:
\W
orkSpace
\s
uzhouavp
\a
pp
\s
rc
\m
ain
\p
roto
\r
esponse.proto
\ No newline at end of file
app/build.gradle.kts
View file @
fecf07e4
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-
java
lite:
4.31.1
")
// implementation("com.google.protobuf:proto
buf-lite
:3.0.0")
// implementation("com.google.protobuf:proto
c
: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
...
...
app/src/main/java/com/sd/cavphmi/viewmodels/MainVm.kt
View file @
fecf07e4
...
@@ -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
)
{
...
...
app/src/main/java/com/sd/cavphmi/websockets/MyWebSocketClient.kt
View file @
fecf07e4
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
)
}
}
...
...
app/src/main/java/protocol/Response.java
0 → 100644
View file @
fecf07e4
This diff is collapsed.
Click to expand it.
app/src/main/proto/response.proto
View file @
fecf07e4
syntax
=
"proto3"
;
syntax
=
"proto3"
;
package
com
.
sd.cavphmi
;
package
protocol
;
message
SocketResponse
{
message
SocketResponse
{
int32
code
=
1
;
int32
code
=
1
;
...
...
protoc-31.1-win64.zip
0 → 100644
View file @
fecf07e4
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment