Skip to content

Commit

Permalink
fix: pub get error on flutter 2.5 #98
Browse files Browse the repository at this point in the history
  • Loading branch information
LichKing-2234 committed Sep 27, 2021
1 parent 62ab0f4 commit 5beb5f7
Show file tree
Hide file tree
Showing 10 changed files with 641 additions and 459 deletions.
774 changes: 439 additions & 335 deletions android/src/main/kotlin/io/agora/agorartm/AgoraRtmPlugin.kt

Large diffs are not rendered by default.

48 changes: 31 additions & 17 deletions android/src/main/kotlin/io/agora/agorartm/RTMChannel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@ import io.flutter.plugin.common.BinaryMessenger
import io.flutter.plugin.common.EventChannel

class RTMChannel : RtmChannelListener, EventChannel.StreamHandler {

val messenger: BinaryMessenger
val eventChannel: EventChannel
val clientIndex: Long
val eventHandler: Handler

var eventSink: EventChannel.EventSink?


constructor(clientIndex: Long, channelId: String, messenger: BinaryMessenger, eventHandler: Handler) {
constructor(
clientIndex: Long,
channelId: String,
messenger: BinaryMessenger,
eventHandler: Handler
) {
this.clientIndex = clientIndex
this.messenger = messenger
this.eventChannel = EventChannel(this.messenger, "io.agora.rtm.client${clientIndex}.channel${channelId}")
this.eventChannel =
EventChannel(this.messenger, "io.agora.rtm.client${clientIndex}.channel${channelId}")
this.eventChannel.setStreamHandler(this)
this.eventSink = null
this.eventHandler = eventHandler
Expand All @@ -31,29 +35,35 @@ class RTMChannel : RtmChannelListener, EventChannel.StreamHandler {
override fun onAttributesUpdated(attributes: MutableList<RtmChannelAttribute>?) {
var attributeList = ArrayList<Map<String, Any>>()
for (attribute in attributes.orEmpty()) {
attributeList.add(hashMapOf(
attributeList.add(
hashMapOf(
"key" to attribute.key,
"value" to attribute.value,
"userId" to attribute.getLastUpdateUserId(),
"updateTs" to attribute.getLastUpdateTs()
))
)
)
}
sendChannelEvent("onAttributesUpdated", hashMapOf(
sendChannelEvent(
"onAttributesUpdated", hashMapOf(
"attributes" to attributeList
))
)
)
}

override
fun onMessageReceived(message: RtmMessage, member: RtmChannelMember) {
sendChannelEvent("onMessageReceived", hashMapOf(
sendChannelEvent(
"onMessageReceived", hashMapOf(
"userId" to member.userId,
"channelId" to member.channelId,
"message" to hashMapOf(
"text" to message.text,
"offline" to message.isOfflineMessage,
"ts" to message.serverReceivedTs
"text" to message.text,
"offline" to message.isOfflineMessage,
"ts" to message.serverReceivedTs
)
))
)
)
}

override fun onImageMessageReceived(p0: RtmImageMessage?, p1: RtmChannelMember?) {
Expand All @@ -66,18 +76,22 @@ class RTMChannel : RtmChannelListener, EventChannel.StreamHandler {

override
fun onMemberJoined(member: RtmChannelMember) {
sendChannelEvent("onMemberJoined", hashMapOf(
sendChannelEvent(
"onMemberJoined", hashMapOf(
"userId" to member.userId,
"channelId" to member.channelId
))
)
)
}

override
fun onMemberLeft(member: RtmChannelMember) {
sendChannelEvent("onMemberLeft", hashMapOf(
sendChannelEvent(
"onMemberLeft", hashMapOf(
"userId" to member.userId,
"channelId" to member.channelId
))
)
)
}

override fun onMemberCountUpdated(count: Int) {
Expand Down
184 changes: 106 additions & 78 deletions android/src/main/kotlin/io/agora/agorartm/RTMClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import io.flutter.plugin.common.BinaryMessenger
import io.flutter.plugin.common.EventChannel

class RTMClient : RtmClientListener, EventChannel.StreamHandler, RtmCallEventListener {

val messenger: BinaryMessenger
val eventChannel: EventChannel
val appId: String
Expand All @@ -21,8 +20,13 @@ class RTMClient : RtmClientListener, EventChannel.StreamHandler, RtmCallEventLis
var remoteInvitations: MutableMap<String, RemoteInvitation>
var localInvitations: MutableMap<String, LocalInvitation>


constructor(context: Context, appId: String, clientIndex: Long, messenger: BinaryMessenger, eventHandler: Handler) {
constructor(
context: Context,
appId: String,
clientIndex: Long,
messenger: BinaryMessenger,
eventHandler: Handler
) {
this.appId = appId
this.clientIndex = clientIndex
this.messenger = messenger
Expand Down Expand Up @@ -56,139 +60,159 @@ class RTMClient : RtmClientListener, EventChannel.StreamHandler, RtmCallEventLis
override
fun onLocalInvitationReceivedByPeer(localInvitation: LocalInvitation) {
localInvitations[localInvitation.calleeId] = localInvitation
sendClientEvent("onLocalInvitationReceivedByPeer", hashMapOf(
sendClientEvent(
"onLocalInvitationReceivedByPeer", hashMapOf(
"localInvitation" to hashMapOf(
"calleeId" to localInvitation.calleeId,
"content" to localInvitation.content,
"channelId" to localInvitation.channelId,
"state" to localInvitation.state,
"response" to localInvitation.response
"calleeId" to localInvitation.calleeId,
"content" to localInvitation.content,
"channelId" to localInvitation.channelId,
"state" to localInvitation.state,
"response" to localInvitation.response
)
))
)
)
}

override
fun onLocalInvitationAccepted(localInvitation: LocalInvitation, response: String) {
sendClientEvent("onLocalInvitationAccepted", hashMapOf(
sendClientEvent(
"onLocalInvitationAccepted", hashMapOf(
"localInvitation" to hashMapOf(
"calleeId" to localInvitation.calleeId,
"content" to localInvitation.content,
"channelId" to localInvitation.channelId,
"state" to localInvitation.state,
"response" to localInvitation.response
"calleeId" to localInvitation.calleeId,
"content" to localInvitation.content,
"channelId" to localInvitation.channelId,
"state" to localInvitation.state,
"response" to localInvitation.response
)
))
)
)
}

override
fun onLocalInvitationRefused(localInvitation: LocalInvitation, response: String) {
sendClientEvent("onLocalInvitationRefused", hashMapOf(
sendClientEvent(
"onLocalInvitationRefused", hashMapOf(
"localInvitation" to hashMapOf(
"calleeId" to localInvitation.calleeId,
"content" to localInvitation.content,
"channelId" to localInvitation.channelId,
"state" to localInvitation.state,
"response" to localInvitation.response
"calleeId" to localInvitation.calleeId,
"content" to localInvitation.content,
"channelId" to localInvitation.channelId,
"state" to localInvitation.state,
"response" to localInvitation.response
)
))
)
)
}

override
fun onLocalInvitationCanceled(localInvitation: LocalInvitation) {
sendClientEvent("onLocalInvitationCanceled", hashMapOf(
sendClientEvent(
"onLocalInvitationCanceled", hashMapOf(
"localInvitation" to hashMapOf(
"calleeId" to localInvitation.calleeId,
"content" to localInvitation.content,
"channelId" to localInvitation.channelId,
"state" to localInvitation.state,
"response" to localInvitation.response
"calleeId" to localInvitation.calleeId,
"content" to localInvitation.content,
"channelId" to localInvitation.channelId,
"state" to localInvitation.state,
"response" to localInvitation.response
)
))
)
)
}

override
fun onLocalInvitationFailure(localInvitation: LocalInvitation, errorCode: Int) {
sendClientEvent("onLocalInvitationFailure", hashMapOf(
sendClientEvent(
"onLocalInvitationFailure", hashMapOf(
"errorCode" to errorCode,
"localInvitation" to hashMapOf(
"calleeId" to localInvitation.calleeId,
"content" to localInvitation.content,
"channelId" to localInvitation.channelId,
"state" to localInvitation.state,
"response" to localInvitation.response
"calleeId" to localInvitation.calleeId,
"content" to localInvitation.content,
"channelId" to localInvitation.channelId,
"state" to localInvitation.state,
"response" to localInvitation.response
)
))
)
)
}

override
fun onRemoteInvitationReceived(remoteInvitation: RemoteInvitation) {
remoteInvitations[remoteInvitation.callerId] = remoteInvitation
sendClientEvent("onRemoteInvitationReceivedByPeer", hashMapOf(
sendClientEvent(
"onRemoteInvitationReceivedByPeer", hashMapOf(
"remoteInvitation" to hashMapOf(
"callerId" to remoteInvitation.callerId,
"content" to remoteInvitation.content,
"channelId" to remoteInvitation.channelId,
"state" to remoteInvitation.state,
"response" to remoteInvitation.response
"callerId" to remoteInvitation.callerId,
"content" to remoteInvitation.content,
"channelId" to remoteInvitation.channelId,
"state" to remoteInvitation.state,
"response" to remoteInvitation.response
)
))
)
)
}

override
fun onRemoteInvitationAccepted(remoteInvitation: RemoteInvitation) {
remoteInvitations.remove(remoteInvitation.callerId)
sendClientEvent("onRemoteInvitationAccepted", hashMapOf(
sendClientEvent(
"onRemoteInvitationAccepted", hashMapOf(
"remoteInvitation" to hashMapOf(
"callerId" to remoteInvitation.callerId,
"content" to remoteInvitation.content,
"channelId" to remoteInvitation.channelId,
"state" to remoteInvitation.state,
"response" to remoteInvitation.response
"callerId" to remoteInvitation.callerId,
"content" to remoteInvitation.content,
"channelId" to remoteInvitation.channelId,
"state" to remoteInvitation.state,
"response" to remoteInvitation.response
)
))
)
)
}

override
fun onRemoteInvitationRefused(remoteInvitation: RemoteInvitation) {
remoteInvitations.remove(remoteInvitation.callerId)
sendClientEvent("onRemoteInvitationRefused", hashMapOf(
sendClientEvent(
"onRemoteInvitationRefused", hashMapOf(
"remoteInvitation" to hashMapOf(
"callerId" to remoteInvitation.callerId,
"content" to remoteInvitation.content,
"channelId" to remoteInvitation.channelId,
"state" to remoteInvitation.state,
"response" to remoteInvitation.response
"callerId" to remoteInvitation.callerId,
"content" to remoteInvitation.content,
"channelId" to remoteInvitation.channelId,
"state" to remoteInvitation.state,
"response" to remoteInvitation.response
)
))
)
)
}

override
fun onRemoteInvitationCanceled(remoteInvitation: RemoteInvitation) {
remoteInvitations.remove(remoteInvitation.callerId)
sendClientEvent("onRemoteInvitationCanceled", hashMapOf(
sendClientEvent(
"onRemoteInvitationCanceled", hashMapOf(
"remoteInvitation" to hashMapOf(
"callerId" to remoteInvitation.callerId,
"content" to remoteInvitation.content,
"channelId" to remoteInvitation.channelId,
"state" to remoteInvitation.state,
"response" to remoteInvitation.response
"callerId" to remoteInvitation.callerId,
"content" to remoteInvitation.content,
"channelId" to remoteInvitation.channelId,
"state" to remoteInvitation.state,
"response" to remoteInvitation.response
)
))
)
)
}

override
fun onRemoteInvitationFailure(remoteInvitation: RemoteInvitation, errorCode: Int) {
remoteInvitations.remove(remoteInvitation.callerId)
sendClientEvent("onRemoteInvitationFailure", hashMapOf(
sendClientEvent(
"onRemoteInvitationFailure", hashMapOf(
"errorCode" to errorCode,
"remoteInvitation" to hashMapOf(
"callerId" to remoteInvitation.callerId,
"content" to remoteInvitation.content,
"channelId" to remoteInvitation.channelId,
"state" to remoteInvitation.state,
"response" to remoteInvitation.response
"callerId" to remoteInvitation.callerId,
"content" to remoteInvitation.content,
"channelId" to remoteInvitation.channelId,
"state" to remoteInvitation.state,
"response" to remoteInvitation.response
)
))
)
)
}

override
Expand All @@ -198,12 +222,16 @@ class RTMClient : RtmClientListener, EventChannel.StreamHandler, RtmCallEventLis

override
fun onMessageReceived(message: RtmMessage, peerId: String) {
sendClientEvent("onMessageReceived", hashMapOf("peerId" to peerId,
sendClientEvent(
"onMessageReceived", hashMapOf(
"peerId" to peerId,
"message" to hashMapOf(
"text" to message.text,
"offline" to message.isOfflineMessage,
"ts" to message.serverReceivedTs
)))
"text" to message.text,
"offline" to message.isOfflineMessage,
"ts" to message.serverReceivedTs
)
)
)
}

override fun onImageMessageReceivedFromPeer(p0: RtmImageMessage?, p1: String?) {
Expand Down
Loading

0 comments on commit 5beb5f7

Please sign in to comment.