Scarlet icon indicating copy to clipboard operation
Scarlet copied to clipboard

[Question]send text

Open JakeWoki opened this issue 4 years ago • 1 comments

20210511110135 help me

JakeWoki avatar May 11 '21 03:05 JakeWoki

override fun toMessage(data: T): Message {
        if (data is String)
            return Message.Text(data)

        val buffer = Buffer()
        val writer = OutputStreamWriter(buffer.outputStream(), StandardCharsets.UTF_8)
        val jsonWriter = gson.newJsonWriter(writer)
        typeAdapter.write(jsonWriter, data)
        jsonWriter.close()
        val stringValue = buffer.readByteString().utf8()
        return Message.Text(stringValue)
    }

JakeWoki avatar May 11 '21 03:05 JakeWoki