Skip to content

Commit

Permalink
2.0.2 干掉log
Browse files Browse the repository at this point in the history
  • Loading branch information
sunqihong committed Nov 23, 2021
1 parent 9da1376 commit ce7d8c0
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion blive-danmaku-client-jvm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

val projectGroup: String = "com.ggemo.va"
val projectVersion: String = "2.0.1-SNAPSHOT"
val projectVersion: String = "2.0.2-RELEASE"
val projectName: String = "blive-danmaku-client"

group = projectGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@ package com.ggemo.va.blivedanmakuclient.handler

import com.alibaba.fastjson.JSON
import com.alibaba.fastjson.JSONObject
import com.ggemo.va.blivedanmakuclient.inner.handlers.impl.msgLoopManagerImpl
import org.slf4j.LoggerFactory
import java.io.ByteArrayInputStream
import java.io.DataInputStream
import java.nio.charset.StandardCharsets
import java.util.zip.Inflater

open class MsgHandler: MsgHandlerItfc {
private val log = LoggerFactory.getLogger(msgLoopManagerImpl::class.java)

override suspend fun handleRaw(data: ByteArray) {
val dataLength = data.size
if (dataLength < 16) {
log.warn("wrong data")
println("wrong data")
} else {
val inputStream = DataInputStream(ByteArrayInputStream(data))
val msgLength = inputStream.readInt()
if (msgLength < 16) {
log.warn("maybe need expand size of cache")
println("maybe need expand size of cache")
} else if (msgLength > 16 && msgLength == dataLength) {
val headerLength = inputStream.readShort()
val version = inputStream.readShort()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@ import com.ggemo.va.blivedanmakuclient.handler.MsgHandlerItfc
import com.ggemo.va.blivedanmakuclient.inner.util.readStreamUtil
import com.ggemo.va.blivedanmakuclientkt.BLiveDanmakuApplication
import com.ggemo.va.blivedanmakuclientkt.handlers.MsgLoopManager
import org.slf4j.LoggerFactory
import java.io.DataInputStream
import java.io.InputStream
import java.net.Socket
import java.util.concurrent.atomic.AtomicBoolean

object msgLoopManagerImpl : MsgLoopManager {
private val log = LoggerFactory.getLogger(msgLoopManagerImpl::class.java)
private val task2CancelMap = HashMap<BLiveDanmakuApplication, AtomicBoolean>()

override fun cancel(app: BLiveDanmakuApplication) {
task2CancelMap.getOrPut(app) { AtomicBoolean(true) }.set(true)
}

override suspend fun start(socket: Socket, msgHandler: MsgHandlerItfc, app: BLiveDanmakuApplication) {
log.info("start!")
println("start!")
var socketInputStream: InputStream
val bufferSize = 10 * 1024
while (socket.getInputStream().also { socketInputStream = it } != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ object socketIniterImpl : SocketIniter {
socket.connect(address)
return socket
}
// todo: @sunqihong
throw RuntimeException()
throw RuntimeException("no danmaku server can reach")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.ggemo.va.blivedanmakuclientkt.Config
fun main() {
BLiveDanmakuApplication(
Config(
6,
4767523,
object : GivenMsgHandler() {
override suspend fun userCount(userCount: Int) {
println("气人值: $userCount")
Expand Down

0 comments on commit ce7d8c0

Please sign in to comment.