Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccim_sdk_android
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
ccim_sdk_android
Commits
9aa23093
Commit
9aa23093
authored
Sep 21, 2022
by
sheteng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
语音房间 禁言
parent
4aae5817
Changes
21
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
222 additions
and
136 deletions
+222
-136
.idea/deploymentTargetDropDown.xml
.idea/deploymentTargetDropDown.xml
+0
-17
.idea/misc.xml
.idea/misc.xml
+1
-0
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+7
-7
app/src/main/java/com/ccwangluo/im/MainActivity2.java
app/src/main/java/com/ccwangluo/im/MainActivity2.java
+10
-0
app/src/main/java/com/ccwangluo/im/ui/dashboard/ConnectActivity.java
...n/java/com/ccwangluo/im/ui/dashboard/ConnectActivity.java
+37
-37
app/src/main/java/com/ccwangluo/im/ui/login/LoginActivity.java
...rc/main/java/com/ccwangluo/im/ui/login/LoginActivity.java
+3
-2
app/src/main/java/com/ccwangluo/im/ui/notifications/ConnectChannelActivity.java
...ccwangluo/im/ui/notifications/ConnectChannelActivity.java
+39
-39
app/src/main/java/com/ccwangluo/im/ui/notifications/NotificationsFragment.java
.../ccwangluo/im/ui/notifications/NotificationsFragment.java
+2
-0
app/src/main/res/layout/activity_connect.xml
app/src/main/res/layout/activity_connect.xml
+6
-2
app/src/main/res/layout/activity_connect_channel.xml
app/src/main/res/layout/activity_connect_channel.xml
+6
-2
app/src/main/res/layout/activity_login.xml
app/src/main/res/layout/activity_login.xml
+1
-1
app/src/main/res/layout/fragment_first.xml
app/src/main/res/layout/fragment_first.xml
+1
-1
ccim/src/main/java/com/ccwangluo/ccim/CCIMClient.java
ccim/src/main/java/com/ccwangluo/ccim/CCIMClient.java
+81
-8
ccim/src/main/java/com/ccwangluo/ccim/audio/JanusService.java
.../src/main/java/com/ccwangluo/ccim/audio/JanusService.java
+3
-0
ccim/src/main/java/com/ccwangluo/ccim/database/MessageDao.java
...src/main/java/com/ccwangluo/ccim/database/MessageDao.java
+4
-4
ccim/src/main/java/com/ccwangluo/ccim/listener/OnPushMsgListener.java
...n/java/com/ccwangluo/ccim/listener/OnPushMsgListener.java
+2
-0
ccim/src/main/java/com/ccwangluo/ccim/manage/MessageManager.java
...c/main/java/com/ccwangluo/ccim/manage/MessageManager.java
+11
-10
ccim/src/main/java/com/ccwangluo/ccim/modle/Dialog.java
ccim/src/main/java/com/ccwangluo/ccim/modle/Dialog.java
+1
-1
ccim/src/main/proto/chat.proto
ccim/src/main/proto/chat.proto
+3
-0
ccim/src/main/proto/push.proto
ccim/src/main/proto/push.proto
+4
-0
ccim/src/main/proto/user.proto
ccim/src/main/proto/user.proto
+0
-5
No files found.
.idea/deploymentTargetDropDown.xml
deleted
100644 → 0
View file @
4aae5817
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"deploymentTargetDropDown"
>
<targetSelectedWithDropDown>
<Target>
<type
value=
"QUICK_BOOT_TARGET"
/>
<deviceKey>
<Key>
<type
value=
"VIRTUAL_DEVICE_PATH"
/>
<value
value=
"C:\Users\she\.android\avd\Copy_of_Copy_of_Pixel_3_XL_API_26.avd"
/>
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown
value=
"2022-06-30T07:35:17.411815700Z"
/>
</component>
</project>
\ No newline at end of file
.idea/misc.xml
View file @
9aa23093
...
...
@@ -3,6 +3,7 @@
<component
name=
"DesignSurface"
>
<option
name=
"filePathToZoomLevelMap"
>
<map>
<entry
key=
"..\:/ccwangluo/ccim_sdk_android/app/src/main/res/layout/activity_connect.xml"
value=
"0.3328125"
/>
<entry
key=
"..\:/ccwangluo/ccim_sdk_android/app/src/main/res/layout/activity_connect_channel.xml"
value=
"0.3328125"
/>
<entry
key=
"..\:/ccwangluo/ccim_sdk_android/app/src/main/res/layout/activity_login.xml"
value=
"0.1612008072653885"
/>
<entry
key=
"..\:/ccwangluo/ccim_sdk_android/app/src/main/res/layout/activity_main2.xml"
value=
"0.1612008072653885"
/>
...
...
app/src/main/AndroidManifest.xml
View file @
9aa23093
...
...
@@ -24,20 +24,20 @@
android:exported=
"false"
/>
<activity
android:name=
".MainActivity2"
android:exported=
"
fals
e"
android:exported=
"
tru
e"
android:label=
"@string/title_activity_main2"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.login.LoginActivity"
android:label=
"@string/app_name"
android:screenOrientation=
"portrait"
android:theme=
"@style/Theme.CcwangluoIm.NoActionBar"
>
android:screenOrientation=
"fullSensor"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity
android:name=
".ui.login.LoginActivity"
android:label=
"@string/app_name"
android:screenOrientation=
"fullSensor"
android:theme=
"@style/Theme.CcwangluoIm.NoActionBar"
>
</activity>
</application>
</manifest>
\ No newline at end of file
app/src/main/java/com/ccwangluo/im/MainActivity2.java
View file @
9aa23093
...
...
@@ -2,7 +2,9 @@ package com.ccwangluo.im;
import
android.app.AlertDialog
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.text.format.DateUtils
;
import
android.view.MenuItem
;
import
android.widget.Toast
;
...
...
@@ -22,6 +24,8 @@ import com.ccwangluo.ccim.modle.NetStatus;
import
com.ccwangluo.ccim.modle.User
;
import
com.ccwangluo.im.data.LoginViewModel
;
import
com.ccwangluo.im.databinding.ActivityMain2Binding
;
import
com.ccwangluo.im.ui.login.LoginActivity
;
import
com.ccwangluo.im.util.ToastUtil
;
import
com.google.android.material.bottomnavigation.BottomNavigationView
;
import
org.greenrobot.eventbus.EventBus
;
...
...
@@ -127,7 +131,13 @@ public class MainActivity2 extends AppCompatActivity {
alertDialog
.
show
();
}
@Override
public
void
pushUserMutedRes
(
Long
mutedExpiredAt
)
{
ToastUtil
.
show
(
getApplicationContext
(),
"被禁言到"
+
mutedExpiredAt
);
}
});
startActivity
(
new
Intent
(
this
,
LoginActivity
.
class
));
}
@Override
...
...
app/src/main/java/com/ccwangluo/im/ui/dashboard/ConnectActivity.java
View file @
9aa23093
...
...
@@ -78,37 +78,19 @@ public class ConnectActivity extends AppCompatActivity {
}
});
binding
.
s
endVoice
.
setOnTouchListener
(
new
View
.
OnTouch
Listener
()
{
binding
.
s
tartVoice
.
setOnClickListener
(
new
View
.
OnClick
Listener
()
{
@Override
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
if
(
isSuccess
)
CCIMClient
.
getInstance
().
stopAndSendAudioMessage
(
contact
.
getContactUserId
(),
contact
.
getContactUserName
(),
new
ResultEventCallback
<
MessageContent
>()
{
@Override
public
void
onSuccess
(
MessageContent
message
)
{
binding
.
sendEdit
.
setText
(
""
);
loginViewModel
.
addPrivateMsg
(
message
);
ToastUtil
.
show
(
getApplication
(),
"send Success"
);
}
@Override
public
void
onFailed
(
int
errorCode
)
{
ToastUtil
.
show
(
getApplication
(),
"send onFailed :"
+
errorCode
);
}
});
}
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
)
{
public
void
onClick
(
View
v
)
{
CCIMClient
.
getInstance
().
startRecordAudioMessage
(
ConnectActivity
.
this
,
contact
.
getContactUserId
(),
contact
.
getContactUserName
(),
new
ResultEventCallback
<
Void
>()
{
@Override
public
void
onSuccess
(
Void
unused
)
{
isSuccess
=
true
;
}
@Override
public
void
onFailed
(
int
errorCode
)
{
isSuccess
=
false
;
ToastUtil
.
show
(
getApplication
()
,
errorCode
+
""
);
ToastUtil
.
show
(
ConnectActivity
.
this
,
errorCode
+
""
);
}
},
new
RecordAutoSendCallback
()
{
@Override
...
...
@@ -124,10 +106,28 @@ public class ConnectActivity extends AppCompatActivity {
}
});
}
});
return
false
;
binding
.
sendVoice
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(
isSuccess
)
CCIMClient
.
getInstance
().
stopAndSendAudioMessage
(
contact
.
getContactUserId
(),
contact
.
getContactUserName
(),
new
ResultEventCallback
<
MessageContent
>()
{
@Override
public
void
onSuccess
(
MessageContent
message
)
{
binding
.
sendEdit
.
setText
(
""
);
loginViewModel
.
addPrivateMsg
(
message
);
ToastUtil
.
show
(
getApplication
(),
"send Success"
);
}
@Override
public
void
onFailed
(
int
errorCode
)
{
ToastUtil
.
show
(
getApplication
(),
"send onFailed :"
+
errorCode
);
}
});
}
});
CCIMClient
.
getInstance
().
getPrivateMessage
(
contact
.
getContactUserId
(),
new
ResultEventCallback
<
List
<
MessageContent
>>()
{
@Override
public
void
onSuccess
(
List
<
MessageContent
>
messageContents
)
{
...
...
app/src/main/java/com/ccwangluo/im/ui/login/LoginActivity.java
View file @
9aa23093
...
...
@@ -40,9 +40,10 @@ public class LoginActivity extends AppCompatActivity {
@Override
public
void
onChanged
(
Boolean
aBoolean
)
{
if
(
aBoolean
)
{
Intent
intent
=
new
Intent
(
LoginActivity
.
this
,
MainActivity2
.
class
);
startActivity
(
intent
);
//
Intent intent = new Intent(LoginActivity.this, MainActivity2.class);
//
startActivity(intent);
finish
();
}
}
});
...
...
app/src/main/java/com/ccwangluo/im/ui/notifications/ConnectChannelActivity.java
View file @
9aa23093
...
...
@@ -44,7 +44,7 @@ public class ConnectChannelActivity extends AppCompatActivity {
binding
.
msgList
.
setAdapter
(
channelMsgAdapter
);
long
channelId
=
getIntent
().
getLongExtra
(
"channelId"
,
0
);
long
channelId
=
getIntent
().
getLongExtra
(
"channelId"
,
0
);
loginViewModel
.
channelMsgList
.
observe
(
this
,
new
Observer
<
MessageContent
>()
{
@Override
...
...
@@ -91,26 +91,9 @@ public class ConnectChannelActivity extends AppCompatActivity {
}
});
binding
.
s
endVoice
.
setOnTouchListener
(
new
View
.
OnTouch
Listener
()
{
binding
.
s
tartVoice
.
setOnClickListener
(
new
View
.
OnClick
Listener
()
{
@Override
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
if
(
isSuccess
)
CCIMClient
.
getInstance
().
stopAndSendChannelAudioMessage
(
channelId
,
new
ResultEventCallback
<
MessageContent
>()
{
@Override
public
void
onSuccess
(
MessageContent
message
)
{
binding
.
sendEdit
.
setText
(
""
);
loginViewModel
.
addChannelMsg
(
message
);
ToastUtil
.
show
(
ConnectChannelActivity
.
this
,
"send Success"
);
}
@Override
public
void
onFailed
(
int
errorCode
)
{
ToastUtil
.
show
(
ConnectChannelActivity
.
this
,
"send onFailed :"
+
errorCode
);
}
});
}
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
)
{
public
void
onClick
(
View
v
)
{
CCIMClient
.
getInstance
().
startRecordChannelAudioMessage
(
ConnectChannelActivity
.
this
,
channelId
,
new
ResultEventCallback
<
Void
>()
{
@Override
...
...
@@ -135,15 +118,32 @@ public class ConnectChannelActivity extends AppCompatActivity {
}
});
}
});
binding
.
sendVoice
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
return
false
;
@Override
public
void
onClick
(
View
v
)
{
if
(
isSuccess
)
CCIMClient
.
getInstance
().
stopAndSendChannelAudioMessage
(
channelId
,
new
ResultEventCallback
<
MessageContent
>()
{
@Override
public
void
onSuccess
(
MessageContent
message
)
{
binding
.
sendEdit
.
setText
(
""
);
loginViewModel
.
addChannelMsg
(
message
);
ToastUtil
.
show
(
ConnectChannelActivity
.
this
,
"send Success"
);
}
@Override
public
void
onFailed
(
int
errorCode
)
{
ToastUtil
.
show
(
ConnectChannelActivity
.
this
,
"send onFailed :"
+
errorCode
);
}
});
}
});
EventBus
.
getDefault
().
register
(
this
);
}
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
)
public
void
onGetMessage
(
MessageContent
message
)
{
loginViewModel
.
addChannelMsg
(
message
);
...
...
app/src/main/java/com/ccwangluo/im/ui/notifications/NotificationsFragment.java
View file @
9aa23093
...
...
@@ -86,6 +86,7 @@ public class NotificationsFragment extends Fragment {
@Override
public
void
onClick
(
View
v
)
{
final
EditText
inputServer
=
new
EditText
(
getContext
());
inputServer
.
requestFocus
();
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
getContext
());
builder
.
setTitle
(
"channel id"
).
setIcon
(
android
.
R
.
drawable
.
ic_dialog_info
).
setView
(
inputServer
)
.
setNegativeButton
(
"Cancel"
,
null
);
...
...
@@ -178,6 +179,7 @@ public class NotificationsFragment extends Fragment {
final
EditText
roomeId
=
new
EditText
(
getContext
());
roomeId
.
setHint
(
"room id"
);
roomeId
.
setInputType
(
InputType
.
TYPE_CLASS_NUMBER
);
roomeId
.
requestFocus
();
LinearLayout
linearLayout
=
new
LinearLayout
(
getContext
());
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
linearLayout
.
addView
(
roomeId
);
...
...
app/src/main/res/layout/activity_connect.xml
View file @
9aa23093
...
...
@@ -41,12 +41,16 @@
android:gravity=
"center"
android:layout_marginBottom=
"100dp"
android:orientation=
"horizontal"
>
<Button
android:id=
"@+id/start_voice"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"录音"
/>
<Button
android:id=
"@+id/send_voice"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"语音"
/>
android:text=
"
发送
语音"
/>
</LinearLayout>
...
...
app/src/main/res/layout/activity_connect_channel.xml
View file @
9aa23093
...
...
@@ -43,12 +43,16 @@
android:gravity=
"center"
android:layout_marginBottom=
"100dp"
android:orientation=
"horizontal"
>
<Button
android:id=
"@+id/start_voice"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"录音"
/>
<Button
android:id=
"@+id/send_voice"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"语音"
/>
android:text=
"
发送
语音"
/>
</LinearLayout>
...
...
app/src/main/res/layout/activity_login.xml
View file @
9aa23093
...
...
@@ -69,7 +69,7 @@
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:hint=
"ip"
android:text=
"10
6.15.237.6
7"
android:text=
"10
.17.4.20
7"
android:imeActionLabel=
"@string/action_sign_in_short"
android:imeOptions=
"actionDone"
android:selectAllOnFocus=
"true"
...
...
app/src/main/res/layout/fragment_first.xml
View file @
9aa23093
...
...
@@ -61,7 +61,7 @@
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:baselineAligned=
"false"
android:layout_height=
"match_parent"
>
<ScrollView
...
...
ccim/src/main/java/com/ccwangluo/ccim/CCIMClient.java
View file @
9aa23093
...
...
@@ -35,18 +35,10 @@ import com.ccwangluo.ccim.modle.User;
import
com.ccwangluo.ccim.util.ErrorCode
;
import
com.ccwangluo.ccim.util.MediaHelper
;
import
com.ccwangluo.ccim.util.PermissionUtils
;
import
com.github.helloiampau.janus.generated.Bundle
;
import
com.github.helloiampau.janus.generated.JanusEvent
;
import
com.github.helloiampau.janus.generated.JanusPlugins
;
import
com.github.helloiampau.janusclientsdk.JanusConfImpl
;
import
com.google.gson.Gson
;
import
com.google.protobuf.util.JsonFormat
;
import
com.karumi.dexter.Dexter
;
import
com.karumi.dexter.PermissionToken
;
import
com.karumi.dexter.listener.PermissionDeniedResponse
;
import
com.karumi.dexter.listener.PermissionGrantedResponse
;
import
com.karumi.dexter.listener.PermissionRequest
;
import
com.karumi.dexter.listener.single.PermissionListener
;
import
java.io.File
;
import
java.util.List
;
...
...
@@ -55,6 +47,7 @@ import java.util.concurrent.Executors;
import
java.util.logging.Logger
;
import
ccim.protocol.Chat
;
import
ccim.protocol.Common
;
import
ccim.protocol.MessageSpec
;
import
ccim.protocol.Push
;
...
...
@@ -75,6 +68,7 @@ public class CCIMClient {
private
final
int
minAudioDuration
=
500
;
public
String
downloadPrefix
;
public
String
cachePath
;
public
Long
mutedExpiredAt
=
0L
;
//禁言时间
public
Handler
handler
=
new
Handler
(
Looper
.
getMainLooper
());
private
ExecutorService
executor
=
Executors
.
newSingleThreadExecutor
();
...
...
@@ -145,6 +139,42 @@ public class CCIMClient {
});
initCachePath
(
context
);
registerMessageListener
(
new
OnPushMsgListener
()
{
@Override
public
void
pushPrivateMsg
(
MessageContent
msg
)
{
}
@Override
public
void
pushChannelMsg
(
MessageContent
msg
)
{
}
@Override
public
void
pushNewContact
(
Contact
contact
)
{
}
@Override
public
void
pushDeleteContact
(
Long
contactId
)
{
}
@Override
public
void
pushContactNetStatus
(
Long
contactId
,
NetStatus
status
)
{
}
@Override
public
void
pushContactNewReq
(
User
user
)
{
}
@Override
public
void
pushUserMutedRes
(
Long
mutedExpiredAt
)
{
}
});
}
/**
...
...
@@ -250,6 +280,16 @@ public class CCIMClient {
pushMsgListener
.
pushDeleteContact
(
userId
);
}
if
(
chatResponseMessage
.
hasPushUserMutedRes
())
{
Push
.
PushUserMutedResponse
pushUserMutedRes
=
chatResponseMessage
.
getPushUserMutedRes
();
mutedExpiredAt
=
pushUserMutedRes
.
getMutedExpiredAt
();
pushMsgListener
.
pushUserMutedRes
(
mutedExpiredAt
);
if
(!
checkMutedExpired
()
&&
janusService
!=
null
)
{
janusService
.
setLocalAudio
(
false
);
}
}
}
@Override
...
...
@@ -397,6 +437,17 @@ public class CCIMClient {
return
true
;
}
/**
* 校验被禁言时间
*/
public
boolean
checkMutedExpired
()
{
long
currentTimeMillis
=
System
.
currentTimeMillis
();
if
(
currentTimeMillis
<
mutedExpiredAt
)
{
return
false
;
}
return
true
;
}
/**
* 发送消息
*/
...
...
@@ -410,6 +461,12 @@ public class CCIMClient {
callback
.
onFailed
(
ErrorCode
.
SEND_MSG_INTERVAL
);
return
;
}
if
(!
checkMutedExpired
())
{
callback
.
onFailed
(
Common
.
StatusCode
.
STATUS_CODE_USER_MUTED_ERROR
.
getNumber
());
return
;
}
messageManager
.
sendPrivateMessage
(
content
,
receiveUserId
,
MessageSpec
.
MessageType
.
MESSAGE_TYPE_TEXT
,
new
ResultEventCallback
<
MessageContent
>()
{
@Override
...
...
@@ -438,6 +495,10 @@ public class CCIMClient {
callback
.
onFailed
(
ErrorCode
.
SEND_MSG_INTERVAL
);
return
;
}
if
(!
checkMutedExpired
())
{
callback
.
onFailed
(
Common
.
StatusCode
.
STATUS_CODE_USER_MUTED_ERROR
.
getNumber
());
return
;
}
messageManager
.
sendChannelMessage
(
content
,
channelId
,
MessageSpec
.
MessageType
.
MESSAGE_TYPE_TEXT
,
callback
);
}
...
...
@@ -486,6 +547,10 @@ public class CCIMClient {
* 开始录音
*/
public
void
startRecordAudioMessage
(
Context
context
,
Long
receiveUserId
,
String
receiveUserName
,
ResultEventCallback
<
Void
>
resultCallback
,
RecordAutoSendCallback
callback
)
{
if
(!
checkMutedExpired
())
{
resultCallback
.
onFailed
(
Common
.
StatusCode
.
STATUS_CODE_USER_MUTED_ERROR
.
getNumber
());
return
;
}
PermissionUtils
.
check
(
context
,
Manifest
.
permission
.
RECORD_AUDIO
,
new
ResultEventCallback
<
Void
>()
{
@Override
public
void
onSuccess
(
Void
o
)
{
...
...
@@ -563,6 +628,10 @@ public class CCIMClient {
* 开始录音
*/
public
void
startRecordChannelAudioMessage
(
Context
context
,
Long
channelID
,
ResultEventCallback
<
Void
>
resultCallback
,
RecordAutoSendCallback
callback
)
{
if
(!
checkMutedExpired
())
{
resultCallback
.
onFailed
(
Common
.
StatusCode
.
STATUS_CODE_USER_MUTED_ERROR
.
getNumber
());
return
;
}
PermissionUtils
.
check
(
context
,
Manifest
.
permission
.
RECORD_AUDIO
,
new
ResultEventCallback
<
Void
>()
{
@Override
public
void
onSuccess
(
Void
o
)
{
...
...
@@ -699,9 +768,13 @@ public class CCIMClient {
/**
* 是否禁言自己
*
* @param enable
*/
public
void
setLocalAudio
(
boolean
enable
)
{
if
(!
checkMutedExpired
())
{
return
;
}
if
(
janusService
!=
null
)
{
janusService
.
setLocalAudio
(
enable
);
}
...
...
ccim/src/main/java/com/ccwangluo/ccim/audio/JanusService.java
View file @
9aa23093
...
...
@@ -132,6 +132,9 @@ public class JanusService extends JanusDelegate {
public
void
onMediaChanged
(
MediaBundle
media
)
{
if
(
media
.
localAudioTrack
()
!=
null
)
{
audioTrack
=
media
.
localAudioTrack
();
if
(!
CCIMClient
.
getInstance
().
checkMutedExpired
()){
audioTrack
.
setEnabled
(
false
);
}
}
}
...
...
ccim/src/main/java/com/ccwangluo/ccim/database/MessageDao.java
View file @
9aa23093
...
...
@@ -23,9 +23,9 @@ public interface MessageDao {
@Query
(
"SELECT * FROM messagecontent where msgId = :msgId"
)
MessageContent
getMsgById
(
Long
msgId
);
@Query
(
"SELECT * FROM messagecontent order by msgId desc limit 1"
)
MessageContent
getLastMsgById
();
@Query
(
"SELECT * FROM messagecontent
where reciveUserId =:userId
order by msgId desc limit 1"
)
MessageContent
getLastMsgById
(
long
userId
);
@Query
(
"SELECT count(*) FROM messagecontent where senderUserId = :userId and msgId > :msgId"
)
Long
selectOfflineCount
(
Long
userId
,
Long
msgId
);
@Query
(
"SELECT count(*) FROM messagecontent where senderUserId = :userId and
reciveUserId=:myUserId and
msgId > :msgId"
)
Long
selectOfflineCount
(
Long
userId
,
Long
myUserId
,
Long
msgId
);
}
ccim/src/main/java/com/ccwangluo/ccim/listener/OnPushMsgListener.java
View file @
9aa23093
...
...
@@ -19,4 +19,6 @@ public interface OnPushMsgListener {
void
pushContactNewReq
(
User
user
);
void
pushUserMutedRes
(
Long
mutedExpiredAt
);
}
ccim/src/main/java/com/ccwangluo/ccim/manage/MessageManager.java
View file @
9aa23093
...
...
@@ -54,13 +54,14 @@ public class MessageManager {
private
List
<
MessageContent
>
messageContentList
=
new
ArrayList
<>();
/**
* 同步离线消息
*/
public
void
getOfflineMessage
(
ResultEventCallback
<
Void
>
resultEventCallback
)
{
executor
.
execute
(()
->
{
long
lastPullMsgId
=
0
;
MessageContent
lastMsgById
=
db
.
messageDao
().
getLastMsgById
();
MessageContent
lastMsgById
=
db
.
messageDao
().
getLastMsgById
(
userId
);
if
(
lastMsgById
!=
null
)
{
lastPullMsgId
=
lastMsgById
.
getMsgId
();
}
...
...
@@ -79,7 +80,7 @@ public class MessageManager {
});
}
public
void
getOfflineMessageOnce
(
Long
lastPullMsgId
,
ResultEventCallback
<
Void
>
callback
)
{
public
void
getOfflineMessageOnce
(
Long
lastPullMsgId
,
ResultEventCallback
<
Void
>
callback
)
{
Message
.
PullOfflineMessageRequest
offlineMessageRequest
=
Message
.
PullOfflineMessageRequest
.
newBuilder
()
.
setLastPulledMsgId
(
lastPullMsgId
)
.
build
();
...
...
@@ -96,7 +97,7 @@ public class MessageManager {
String
print
=
JsonFormat
.
printer
().
print
(
chatResponseMessage
.
getPullOfflineMsgRes
());
PullOffLineMessageRes
pullOffLineMessageRes
=
gson
.
fromJson
(
print
,
PullOffLineMessageRes
.
class
);
List
<
MessageContent
>
message
=
pullOffLineMessageRes
.
getOfflineMessages
();
if
(
message
==
null
){
if
(
message
==
null
)
{
callback
.
onSuccess
(
null
);
return
;
}
...
...
@@ -108,8 +109,8 @@ public class MessageManager {
messageContentList
.
addAll
(
message
);
pushNewMessageList
(
message
);
Long
msgId
=
message
.
get
(
message
.
size
()
-
1
).
getMsgId
();
if
(
message
.
size
()
>
0
&&
msgId
<=
lastPullMsgId
)
{
getOfflineMessageOnce
(
msgId
,
callback
);
if
(
message
.
size
()
>
0
&&
msgId
>=
lastPullMsgId
)
{
getOfflineMessageOnce
(
msgId
,
callback
);
}
else
{
callback
.
onSuccess
(
null
);
}
...
...
@@ -251,7 +252,7 @@ public class MessageManager {
}
public
void
playAudio
(
Long
msgId
,
String
downloadPrefix
,
String
cachePath
,
OnPlayAudioCallback
resultCallback
,
Float
volume
)
{
public
void
playAudio
(
Long
msgId
,
String
downloadPrefix
,
String
cachePath
,
OnPlayAudioCallback
resultCallback
,
Float
volume
)
{
executor
.
execute
(()
->
{
MessageContent
messageContent
=
db
.
messageDao
().
getMsgById
(
msgId
);
if
(
messageContent
==
null
)
{
...
...
@@ -268,7 +269,7 @@ public class MessageManager {
FileUtils
.
downLoadFile
(
url
,
file
,
new
ResultEventCallback
<
File
>()
{
@Override
public
void
onSuccess
(
File
file
)
{
MediaHelper
.
getInstance
().
play
(
file
.
getAbsolutePath
(),
resultCallback
,
volume
);
MediaHelper
.
getInstance
().
play
(
file
.
getAbsolutePath
(),
resultCallback
,
volume
);
}
@Override
...
...
@@ -277,7 +278,7 @@ public class MessageManager {
}
});
}
else
{
MediaHelper
.
getInstance
().
play
(
file
.
getAbsolutePath
(),
resultCallback
,
volume
);
MediaHelper
.
getInstance
().
play
(
file
.
getAbsolutePath
(),
resultCallback
,
volume
);
}
});
...
...
@@ -441,7 +442,7 @@ public class MessageManager {
});
}
public
Long
getOfflineMessageCountByUserId
(
Long
userId
,
Long
msgId
)
{
return
db
.
messageDao
().
selectOfflineCount
(
userId
,
msgId
);
public
Long
getOfflineMessageCountByUserId
(
Long
userId
,
Long
msgId
)
{
return
db
.
messageDao
().
selectOfflineCount
(
userId
,
this
.
userId
,
msgId
);
}
}
ccim/src/main/java/com/ccwangluo/ccim/modle/Dialog.java
View file @
9aa23093
...
...
@@ -10,7 +10,7 @@ public class Dialog {
private
DialogType
dialogType
;
private
NetStatus
netStatus
=
NetStatus
.
NET_STATUS_ONLINE
;
private
String
extData
;
private
Long
readMsgId
;
private
Long
readMsgId
=
0L
;
private
Long
unreadCount
=
0L
;
public
void
setUnreadCount
(
Long
unreadCount
)
{
...
...
ccim/src/main/proto/chat.proto
View file @
9aa23093
...
...
@@ -2,6 +2,8 @@ syntax = "proto3";
package
ccim
.
protocol
;
option
csharp_namespace
=
"CCIM.Protocol"
;
import
"channel.proto"
;
import
"common.proto"
;
import
"contact.proto"
;
...
...
@@ -88,6 +90,7 @@ message ChatResponseMessage {
PushContactNetStatusResponse
push_contact_net_status_res
=
73
;
// 推送联系人网络状态
PushContactNewReqResponse
push_contact_new_req_res
=
74
;
// 推送新的好友申请
PushUserDeletedResponse
push_user_deleted_res
=
76
;
// 推送与自己有关系(对话过的陌生人或好友)的用户已删除
PushUserMutedResponse
push_user_muted_res
=
77
;
// 推送用户被禁言
PullPrivateMessageResponse
pull_private_msg_res
=
81
;
// 拉取私聊消息
PullChannelMessageResponse
pull_channel_msg_res
=
82
;
// 拉取频道消息
...
...
ccim/src/main/proto/push.proto
View file @
9aa23093
...
...
@@ -52,3 +52,7 @@ message PushContactNewReqResponse {
message
PushUserDeletedResponse
{
int64
user_id
=
1
;
}
message
PushUserMutedResponse
{
int64
muted_expired_at
=
1
;
}
\ No newline at end of file
ccim/src/main/proto/user.proto
View file @
9aa23093
...
...
@@ -11,11 +11,6 @@ message BlockUserRequest {
message
BlockUserResponse
{
}
message
MuteUserEvent
{
int64
muted_user_id
=
1
;
int64
muted_expired_at
=
2
;
}
message
PreUploadSignRequest
{
}
...
...
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