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
df78610d
Commit
df78610d
authored
Nov 11, 2021
by
sheteng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
a3d0a99c
Changes
23
Show whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
701 additions
and
543 deletions
+701
-543
.idea/jarRepositories.xml
.idea/jarRepositories.xml
+20
-0
.idea/misc.xml
.idea/misc.xml
+9
-0
app/build.gradle
app/build.gradle
+1
-0
app/src/main/java/com/ccwangluo/im/FirstFragment.java
app/src/main/java/com/ccwangluo/im/FirstFragment.java
+87
-61
app/src/main/java/com/ccwangluo/im/MainActivity.java
app/src/main/java/com/ccwangluo/im/MainActivity.java
+1
-7
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_main.xml
+0
-7
app/src/main/res/layout/fragment_first.xml
app/src/main/res/layout/fragment_first.xml
+195
-159
build.gradle
build.gradle
+8
-1
ccim/build.gradle
ccim/build.gradle
+5
-8
ccim/src/main/AndroidManifest.xml
ccim/src/main/AndroidManifest.xml
+2
-0
ccim/src/main/java/com/ccwangluo/ccim/CCIMClient.java
ccim/src/main/java/com/ccwangluo/ccim/CCIMClient.java
+53
-75
ccim/src/main/java/com/ccwangluo/ccim/listener/OnConnectListener.java
...n/java/com/ccwangluo/ccim/listener/OnConnectListener.java
+6
-0
ccim/src/main/java/com/ccwangluo/ccim/manage/CallBackManager.java
.../main/java/com/ccwangluo/ccim/manage/CallBackManager.java
+4
-4
ccim/src/main/java/com/ccwangluo/ccim/manage/SocketManageer.java
...c/main/java/com/ccwangluo/ccim/manage/SocketManageer.java
+44
-88
ccim/src/main/java/com/ccwangluo/ccim/util/HmacUtil.java
ccim/src/main/java/com/ccwangluo/ccim/util/HmacUtil.java
+58
-0
ccim/src/main/java/com/ccwangluo/ccim/util/MediaHelper.java
ccim/src/main/java/com/ccwangluo/ccim/util/MediaHelper.java
+42
-36
ccim/src/main/proto/channel.proto
ccim/src/main/proto/channel.proto
+34
-0
ccim/src/main/proto/chat.proto
ccim/src/main/proto/chat.proto
+57
-39
ccim/src/main/proto/common.proto
ccim/src/main/proto/common.proto
+37
-13
ccim/src/main/proto/message.proto
ccim/src/main/proto/message.proto
+26
-26
ccim/src/main/proto/message_spec.proto
ccim/src/main/proto/message_spec.proto
+12
-9
ccim/src/main/proto/push.proto
ccim/src/main/proto/push.proto
+0
-10
readme.md
readme.md
+0
-0
No files found.
.idea/jarRepositories.xml
View file @
df78610d
...
...
@@ -26,5 +26,25 @@
<option
name=
"name"
value=
"Google"
/>
<option
name=
"url"
value=
"https://dl.google.com/dl/android/maven2/"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"maven"
/>
<option
name=
"name"
value=
"maven"
/>
<option
name=
"url"
value=
"file:/$PROJECT_DIR$/%20https:/jitpack.io%20"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"maven"
/>
<option
name=
"name"
value=
"maven"
/>
<option
name=
"url"
value=
"file:/$PROJECT_DIR$/ccim/%20https:/jitpack.io%20"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"maven"
/>
<option
name=
"name"
value=
"maven"
/>
<option
name=
"url"
value=
"file:/$PROJECT_DIR$/app/%20https:/jitpack.io%20"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"maven"
/>
<option
name=
"name"
value=
"maven"
/>
<option
name=
"url"
value=
"https://nexus.sky-shark.com/repository/ccnet-group/"
/>
</remote-repository>
</component>
</project>
\ No newline at end of file
.idea/misc.xml
View file @
df78610d
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"DesignSurface"
>
<option
name=
"filePathToZoomLevelMap"
>
<map>
<entry
key=
"..\:/project/ccwangluoIm/app/src/main/res/layout/activity_main.xml"
value=
"0.20153985507246377"
/>
<entry
key=
"..\:/project/ccwangluoIm/app/src/main/res/layout/content_main.xml"
value=
"0.20153985507246377"
/>
<entry
key=
"..\:/project/ccwangluoIm/app/src/main/res/layout/fragment_first.xml"
value=
"0.4530812324929972"
/>
</map>
</option>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_8"
default=
"true"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
...
...
app/build.gradle
View file @
df78610d
...
...
@@ -46,4 +46,5 @@ dependencies {
compile
'com.google.protobuf:protobuf-java:3.5.1'
implementation
'com.google.protobuf:protobuf-java:3.8.0'
implementation
'com.google.protobuf:protobuf-java-util:3.8.0'
implementation
'com.guolindev.permissionx:permissionx:1.6.1'
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/im/FirstFragment.java
View file @
df78610d
package
com.ccwangluo.im
;
package
com.ccwangluo.im
;
import
android.os.Bundle
;
import
android.os.Handler
;
...
...
@@ -7,14 +7,15 @@ import android.util.Log;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.fragment.app.Fragment
;
import
com.ccwangluo.ccim.CCIMClient
;
import
com.ccwangluo.ccim.listener.OnConnectListener
;
import
com.ccwangluo.ccim.listener.ResultCallback
;
import
com.ccwangluo.ccim.listener.ResultEventCallback
;
import
com.ccwangluo.ccim.util.HmacUtil
;
import
com.ccwangluo.im.databinding.FragmentFirstBinding
;
import
java.util.ArrayList
;
...
...
@@ -40,35 +41,30 @@ public class FirstFragment extends Fragment {
public
void
onViewCreated
(
@NonNull
View
view
,
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
CCIMClient
.
getInstance
().
initSDK
();
CCIMClient
.
getInstance
().
registerMessageListener
(
new
ResultEventCallback
<
Chat
.
ChatResponseMessage
>()
{
@Override
public
void
onSuccess
(
Chat
.
ChatResponseMessage
chatResponseMessage
)
{
new
Handler
(
Looper
.
getMainLooper
()).
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
Toast
.
makeText
(
getContext
(),
chatResponseMessage
.
toString
(),
Toast
.
LENGTH_SHORT
).
show
();
}
});
String
appKey
=
"c981adfde9c4000"
;
String
userName
=
"user100"
;
Long
userId
=
100L
;
Long
ts
=
System
.
currentTimeMillis
();
String
data
=
appKey
+
"&"
+
userId
+
"&"
+
userName
+
"&"
+
ts
+
"&wW7cR31PwJseIoZMOs311nljHpwUmujs"
;
}
});
String
sign
=
HmacUtil
.
stringToSign
(
"wW7cR31PwJseIoZMOs311nljHpwUmujs"
,
data
);
binding
.
buttonLogin
.
setOnClickListener
(
new
View
.
OnClick
Listener
()
{
CCIMClient
.
getInstance
().
initSDK
(
appKey
,
userName
,
100L
,
ts
,
sign
,
new
OnConnect
Listener
()
{
@Override
public
void
onClick
(
View
v
)
{
CCIMClient
.
getInstance
().
login
(
"user1"
,
"123456"
,
1L
,
new
ResultCallback
(){
public
void
onSocketConnection
()
{
refreshLogView
(
"connect success"
);
}
@Override
public
void
onSuccess
()
{
public
void
onSocketDisconnection
()
{
refreshLogView
(
"disconnect"
);
}
// @Override
// public void onFailed(int errorCode) {
//
// }
});
CCIMClient
.
getInstance
().
registerMessageListener
(
new
ResultEventCallback
<
Chat
.
ChatResponseMessage
>()
{
@Override
public
void
onSuccess
(
Chat
.
ChatResponseMessage
chatResponseMessage
)
{
refreshLogView
(
chatResponseMessage
.
toString
());
}
});
...
...
@@ -76,15 +72,18 @@ public class FirstFragment extends Fragment {
@Override
public
void
onClick
(
View
v
)
{
CCIMClient
.
getInstance
().
getC
ha
tList
(
new
ResultEventCallback
<
Chat
.
PullContactsResponse
>()
{
CCIMClient
.
getInstance
().
getC
ontac
tList
(
new
ResultEventCallback
<
Chat
.
PullContactsResponse
>()
{
@Override
public
void
onSuccess
(
Chat
.
PullContactsResponse
pullContactsResponse
)
{
List
<
Chat
.
PullContactsResponse
.
Channel
>
channelsList
=
pullContactsResponse
.
getChannelsList
();
Log
.
d
(
TAG
,
"channelsList: "
+
channelsList
.
toString
());
refreshLogView
(
"channelsList: "
+
channelsList
.
toString
());
List
<
Chat
.
PullContactsResponse
.
ContactGroup
>
contactGroupsList
=
pullContactsResponse
.
getContactGroupsList
();
Log
.
d
(
TAG
,
"contactGroupsList: "
+
contactGroupsList
.
toString
());
refreshLogView
(
"contactGroupsList: "
+
contactGroupsList
.
toString
());
List
<
Chat
.
PullContactsResponse
.
Contact
>
contactsList
=
pullContactsResponse
.
getContactsList
();
Log
.
d
(
TAG
,
"contactsList: "
+
contactsList
.
toString
());
refreshLogView
(
"contactsList: "
+
contactsList
.
toString
());
}
});
}
...
...
@@ -93,10 +92,11 @@ public class FirstFragment extends Fragment {
binding
.
getOfflineMessage
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
CCIMClient
.
getInstance
().
getOfflineMessage
(
new
ResultEventCallback
<
Array
List
<
Message
.
PullOfflineMessageResponse
.
OfflineMessage
>>()
{
CCIMClient
.
getInstance
().
getOfflineMessage
(
0L
,
new
ResultEventCallback
<
List
<
Message
.
PullOfflineMessageResponse
.
OfflineMessage
>>()
{
@Override
public
void
onSuccess
(
Array
List
<
Message
.
PullOfflineMessageResponse
.
OfflineMessage
>
offlineMessages
)
{
public
void
onSuccess
(
List
<
Message
.
PullOfflineMessageResponse
.
OfflineMessage
>
offlineMessages
)
{
Log
.
d
(
TAG
,
"offlineMessages: "
+
offlineMessages
.
toString
());
refreshLogView
(
"offlineMessages: "
+
offlineMessages
.
toString
());
}
});
}
...
...
@@ -105,10 +105,11 @@ public class FirstFragment extends Fragment {
binding
.
searchUser
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
CCIMClient
.
getInstance
().
searchUser
(
"
user2
"
,
new
ResultEventCallback
<
List
<
Chat
.
SearchResponse
.
User
>>()
{
CCIMClient
.
getInstance
().
searchUser
(
"
feng
"
,
new
ResultEventCallback
<
List
<
Chat
.
SearchResponse
.
User
>>()
{
@Override
public
void
onSuccess
(
List
<
Chat
.
SearchResponse
.
User
>
users
)
{
Log
.
d
(
TAG
,
"onSuccess: "
+
users
);
refreshLogView
(
"searchUser: "
+
users
);
}
});
}
...
...
@@ -120,7 +121,7 @@ public class FirstFragment extends Fragment {
CCIMClient
.
getInstance
().
addContact
(
Long
.
parseLong
(
binding
.
userId
.
getText
().
toString
()),
new
ResultEventCallback
<
Chat
.
AddContactResponse
.
AddResult
>()
{
@Override
public
void
onSuccess
(
Chat
.
AddContactResponse
.
AddResult
addResult
)
{
refreshLogView
(
"addUser : "
+
addResult
.
toString
());
}
});
}
...
...
@@ -132,7 +133,7 @@ public class FirstFragment extends Fragment {
CCIMClient
.
getInstance
().
sendTextMessage
(
"你好"
,
Long
.
parseLong
(
binding
.
userId
.
getText
().
toString
()),
new
ResultCallback
()
{
@Override
public
void
onSuccess
()
{
refreshLogView
(
"sendTextMessage success"
);
}
});
}
...
...
@@ -141,10 +142,10 @@ public class FirstFragment extends Fragment {
binding
.
getContactRequests
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
CCIMClient
.
getInstance
().
getContactReq
uests
(
new
ResultEventCallback
<
Chat
.
ContactRequestsResponse
>()
{
CCIMClient
.
getInstance
().
getContactReq
List
(
new
ResultEventCallback
<
Chat
.
ContactRequestsResponse
>()
{
@Override
public
void
onSuccess
(
Chat
.
ContactRequestsResponse
contactRequestsResponse
)
{
refreshLogView
(
"getContactRequests: "
+
contactRequestsResponse
.
toString
());
}
});
}
...
...
@@ -156,7 +157,7 @@ public class FirstFragment extends Fragment {
CCIMClient
.
getInstance
().
checkContactReq
(
Long
.
parseLong
(
binding
.
userId
.
getText
().
toString
()),
true
,
new
ResultCallback
()
{
@Override
public
void
onSuccess
()
{
refreshLogView
(
"checkContactRequests success"
);
}
});
}
...
...
@@ -164,26 +165,26 @@ public class FirstFragment extends Fragment {
binding
.
createContactGroupRequest
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
CCIMClient
.
getInstance
().
createContactGroup
(
"zhangsan"
,
new
ResultEventCallback
<
Long
>()
{
CCIMClient
.
getInstance
().
createContactGroup
(
"zhangsan"
,
new
ResultEventCallback
<
Chat
.
CreateContactGroupResponse
>()
{
@Override
public
void
onSuccess
(
Long
aLong
)
{
public
void
onSuccess
(
Chat
.
CreateContactGroupResponse
aLong
)
{
refreshLogView
(
"createContactGroupRequest : "
+
aLong
);
}
});
}
});
binding
.
moveContactGroupRequest
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
CCIMClient
.
getInstance
().
moveContactGroup
(
Long
.
parseLong
(
binding
.
groupId
.
getText
().
toString
()),
Long
.
parseLong
(
binding
.
userId
.
getText
().
toString
()),
new
ResultCallback
()
{
@Override
public
void
onSuccess
()
{
}
});
}
});
//
binding.moveContactGroupRequest.setOnClickListener(new View.OnClickListener() {
//
@Override
//
public void onClick(View v) {
//
CCIMClient.getInstance().moveContactGroup(Long.parseLong(binding.groupId.getText().toString()), Long.parseLong(binding.userId.getText().toString()), new ResultCallback() {
//
@Override
//
public void onSuccess() {
// refreshLogView("moveContactGroupRequest success " );
//
}
//
});
//
}
//
});
binding
.
deleteContact
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
...
...
@@ -191,7 +192,7 @@ public class FirstFragment extends Fragment {
CCIMClient
.
getInstance
().
deleteContact
(
Long
.
parseLong
(
binding
.
userId
.
getText
().
toString
()),
new
ResultCallback
()
{
@Override
public
void
onSuccess
()
{
refreshLogView
(
"deleteContact success "
);
}
});
}
...
...
@@ -203,7 +204,7 @@ public class FirstFragment extends Fragment {
CCIMClient
.
getInstance
().
blockContact
(
Long
.
parseLong
(
binding
.
userId
.
getText
().
toString
()),
true
,
new
ResultCallback
()
{
@Override
public
void
onSuccess
()
{
refreshLogView
(
"blockContact success "
);
}
});
}
...
...
@@ -215,33 +216,58 @@ public class FirstFragment extends Fragment {
CCIMClient
.
getInstance
().
reportIllegalUser
(
"搞黄色"
,
"搞黄色"
,
Long
.
parseLong
(
binding
.
userId
.
getText
().
toString
()),
new
ResultCallback
()
{
@Override
public
void
onSuccess
()
{
refreshLogView
(
"reportIllegalUser success "
);
}
});
}
});
binding
.
sendGroupMessage
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
binding
.
sendChannelMessage
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
CCIMClient
.
getInstance
().
send
GroupMessage
(
"搞黄色"
,
Long
.
parseLong
(
binding
.
group
Id
.
getText
().
toString
()),
new
ResultCallback
()
{
CCIMClient
.
getInstance
().
send
ChannelMessage
(
"搞黄色"
,
Long
.
parseLong
(
binding
.
channel
Id
.
getText
().
toString
()),
new
ResultCallback
()
{
@Override
public
void
onSuccess
()
{
refreshLogView
(
"sendChannelMessage success"
);
}
});
}
});
binding
.
s
endChannel
Message
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
binding
.
s
tartRecordAudio
Message
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
CCIMClient
.
getInstance
().
sendChannelMessage
(
"搞黄色"
,
Long
.
parseLong
(
binding
.
channelId
.
getText
().
toString
()),
new
ResultCallback
()
{
CCIMClient
.
getInstance
().
startRecordAudioMessage
(
getActivity
());
}
});
binding
.
stopAndSendAudioMessage
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onSuccess
()
{
public
void
onClick
(
View
v
)
{
CCIMClient
.
getInstance
().
stopAndSendAudioMessage
();
}
});
binding
.
cancleAudioMessage
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
CCIMClient
.
getInstance
().
cancleAudioMessage
();
}
});
}
public
void
refreshLogView
(
String
msg
)
{
new
Handler
(
Looper
.
getMainLooper
()).
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
binding
.
txLog
.
append
(
msg
);
int
offset
=
binding
.
txLog
.
getLineCount
()
*
binding
.
txLog
.
getLineHeight
();
if
(
offset
>
binding
.
txLog
.
getHeight
())
{
binding
.
txLog
.
scrollTo
(
0
,
offset
-
binding
.
txLog
.
getHeight
()
+
binding
.
txLog
.
getLineHeight
()
*
2
);
}
}
});
...
...
app/src/main/java/com/ccwangluo/im/MainActivity.java
View file @
df78610d
...
...
@@ -2,6 +2,7 @@ package com.ccwangluo.im;
import
android.os.Bundle
;
import
com.ccwangluo.ccim.util.HmacUtil
;
import
com.google.android.material.snackbar.Snackbar
;
import
androidx.appcompat.app.AppCompatActivity
;
...
...
@@ -36,13 +37,6 @@ public class MainActivity extends AppCompatActivity {
appBarConfiguration
=
new
AppBarConfiguration
.
Builder
(
navController
.
getGraph
()).
build
();
NavigationUI
.
setupActionBarWithNavController
(
this
,
navController
,
appBarConfiguration
);
binding
.
fab
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
Snackbar
.
make
(
view
,
"Replace with your own action"
,
Snackbar
.
LENGTH_LONG
)
.
setAction
(
"Action"
,
null
).
show
();
}
});
}
@Override
...
...
app/src/main/res/layout/activity_main.xml
View file @
df78610d
...
...
@@ -22,12 +22,5 @@
<include
layout=
"@layout/content_main"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id=
"@+id/fab"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom|end"
android:layout_margin=
"@dimen/fab_margin"
app:srcCompat=
"@android:drawable/ic_dialog_email"
/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_first.xml
View file @
df78610d
...
...
@@ -3,173 +3,209 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:orientation=
"horizontal"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
tools:context=
".FirstFragment"
>
<LinearLayout
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<TextView
android:layout_width=
"match_parent"
android:id=
"@+id/tx_log"
android:layout_height=
"100dp"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:orientation=
"horizontal"
android:layout_height=
"wrap_content"
>
<TextView
android:layout_width=
"wrap_content"
android:text=
"userId"
android:layout_height=
"wrap_content"
/>
<EditText
android:id=
"@+id/userId"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:hint=
"userId"
android:text=
"2"
/>
<TextView
android:layout_width=
"wrap_content"
android:text=
"channelId"
android:layout_height=
"wrap_content"
/>
<EditText
android:id=
"@+id/channelId"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:hint=
"channelId"
android:text=
"1"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
android:layout_width=
"0dp"
android:layout_weight=
"1
"
android:layout_height=
"match_parent
"
>
android:layout_height=
"match_parent
"
android:layout_weight=
"1
"
>
<LinearLayout
<LinearLayout
android:layout_width=
"match_parent"
android:orientation=
"vertical
"
android:layout_height=
"match_parent
"
>
android:layout_height=
"match_parent
"
android:orientation=
"vertical
"
>
<Button
android:layout_marginTop=
"50dp"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/button_login"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"登录"
/>
<Button
android:layout_marginTop=
"20dp"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/getChatList"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:text=
"获取联系人列表"
/>
<Button
android:layout_marginTop=
"20dp"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/getOfflineMessage"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:text=
"同步离线消息"
/>
<Button
android:layout_marginTop=
"20dp"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/searchUser"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:text=
"查找好友"
/>
<Button
android:layout_marginTop=
"20dp"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/addUser"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:text=
"添加好友"
/>
<Button
android:layout_marginTop=
"20dp"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/getContactRequests"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:text=
"联系人申请列表"
/>
<Button
android:layout_marginTop=
"20dp"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/checkContactRequests"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:text=
"验证联系人申请"
/>
<Button
android:layout_marginTop=
"20dp"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/sendTextMessage"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:text=
"发送消息"
/>
<Button
android:layout_marginTop=
"20dp"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/createContactGroupRequest"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:text=
"创建联系人组"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<ScrollView
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
android:layout_weight=
"1"
>
<LinearLayout
android:layout_width=
"match_parent"
android:orientation=
"vertical"
android:layout_height=
"match_parent"
>
<EditText
android:id=
"@+id/userId"
android:layout_width=
"match_parent"
android:text=
"2"
android:hint=
"userId"
android:layout_height=
"wrap_content"
/>
<EditText
android:id=
"@+id/groupId"
android:layout_width=
"match_parent"
android:hint=
"groupId"
android:text=
"1"
android:layout_height=
"wrap_content"
/>
<EditText
android:id=
"@+id/channelId"
android:text=
"1"
android:layout_width=
"match_parent"
android:hint=
"channelId"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<Button
android:layout_marginTop=
"20dp"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/moveContactGroupRequest"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:text=
"移动联系人所在群组"
/>
<Button
android:layout_marginTop=
"20dp"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/deleteContact"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:text=
"删除联系人"
/>
<Button
android:layout_marginTop=
"20dp"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/blockContact"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:text=
"拉黑联系人"
/>
<Button
android:layout_marginTop=
"20dp"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/reportIllegalUser"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:text=
"举报违规用户"
/>
<Button
android:layout_marginTop=
"20dp"
android:id=
"@+id/sendChannelMessage"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/sendGroupMessage"
android:layout_marginTop=
"10dp"
android:text=
"发送频道消息"
/>
<Button
android:id=
"@+id/startRecordAudioMessage"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"发送群组消息"
/>
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:text=
"开始录音"
/>
<Button
android:layout_marginTop=
"20dp"
android:id=
"@+id/stopAndSendAudioMessage"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/sendChannelMessage"
android:layout_marginTop=
"10dp"
android:text=
"录音上传"
/>
<Button
android:id=
"@+id/cancleAudioMessage"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"发送频道消息"
/>
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:text=
"取消上传"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
build.gradle
View file @
df78610d
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript
{
repositories
{
maven
{
url
"https://nexus.sky-shark.com/repository/ccnet-group/"
}
google
()
mavenCentral
()
maven
{
url
' https://jitpack.io '
}
}
dependencies
{
classpath
"com.android.tools.build:gradle:4.2.2"
...
...
@@ -14,9 +18,12 @@ buildscript {
allprojects
{
repositories
{
maven
{
url
"https://nexus.sky-shark.com/repository/ccnet-group/"
}
google
()
mavenCentral
()
jcenter
()
// Warning: this repository is going to shut down soon
maven
{
url
' https://jitpack.io '
}
}
}
...
...
ccim/build.gradle
View file @
df78610d
...
...
@@ -57,15 +57,12 @@ protobuf {
}
}
}
dependencies
{
implementation
'androidx.appcompat:appcompat:1.3.1'
implementation
'com.google.android.material:material:1.4.0'
testImplementation
'junit:junit:4.+'
androidTestImplementation
'androidx.test.ext:junit:1.1.2'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.3.0'
implementation
'com.google.protobuf:protobuf-java:3.8.0'
implementation
'com.google.protobuf:protobuf-java-util:3.8.0'
api
'com.tonystark.android:socket:latest.release'
api
'com.tonystark.android:socket-server:latest.release'
implementation
'com.google.protobuf:protobuf-java:3.13.0'
implementation
'com.google.protobuf:protobuf-java-util:3.12.0'
implementation
'com.tonystark.android:socket:latest.release'
implementation
'com.tonystark.android:socket-server:latest.release'
implementation
'com.guolindev.permissionx:permissionx:1.6.1'
}
\ No newline at end of file
ccim/src/main/AndroidManifest.xml
View file @
df78610d
...
...
@@ -3,5 +3,7 @@
package=
"com.ccwangluo.ccim"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.RECORD_AUDIO"
/>
</manifest>
\ No newline at end of file
ccim/src/main/java/com/ccwangluo/ccim/CCIMClient.java
View file @
df78610d
package
com.ccwangluo.ccim
;
import
android.Manifest
;
import
android.media.MediaPlayer
;
import
androidx.fragment.app.FragmentActivity
;
import
com.ccwangluo.ccim.listener.OnConnectListener
;
import
com.ccwangluo.ccim.listener.ResultCallback
;
import
com.ccwangluo.ccim.listener.ResultEventCallback
;
import
com.ccwangluo.ccim.manage.CallBackManager
;
import
com.ccwangluo.ccim.manage.SocketManageer
;
import
com.ccwangluo.ccim.util.MediaHelper
;
import
com.google.protobuf.RepeatedFieldBuilder
;
import
com.permissionx.guolindev.PermissionX
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.logging.Logger
;
import
ccim.protocol.Chat
;
import
ccim.protocol.Message
;
import
ccim.protocol.MessageSpec
;
...
...
@@ -38,10 +44,10 @@ public class CCIMClient {
return
mInstance
;
}
public
void
initSDK
()
{
public
void
initSDK
(
String
appKey
,
String
userName
,
Long
userId
,
Long
ts
,
String
sign
,
OnConnectListener
resultCallback
)
{
callBackManager
=
new
CallBackManager
<>();
socketManageer
=
new
SocketManageer
(
callBackManager
);
socketManageer
.
init
Auth
(
);
socketManageer
.
init
Chat
(
appKey
,
userName
,
userId
,
ts
,
sign
,
resultCallback
);
}
...
...
@@ -52,10 +58,6 @@ public class CCIMClient {
MessageSpec
.
ChatMessage
pushPrivateMsgRes
=
chatResponseMessage
.
getPushPrivateMsgRes
().
getMessage
();
pushPrivateMessageAck
(
pushPrivateMsgRes
.
getSenderUserId
(),
pushPrivateMsgRes
.
getMsgId
());
}
if
(
chatResponseMessage
.
hasPushGroupMsgRes
())
{
Push
.
PushGroupMessageResponse
message
=
chatResponseMessage
.
getPushGroupMsgRes
();
pushGroupMessageAck
(
message
.
getGroupId
(),
message
.
getMessage
().
getMsgId
());
}
if
(
chatResponseMessage
.
hasPushChannelMsgRes
())
{
Push
.
PushChannelMessageResponse
channelMsgRes
=
chatResponseMessage
.
getPushChannelMsgRes
();
pushChannelMessage
(
channelMsgRes
.
getChannelId
(),
channelMsgRes
.
getMessage
().
getMsgId
());
...
...
@@ -65,25 +67,10 @@ public class CCIMClient {
}
public
void
login
(
String
username
,
String
password
,
Long
appId
,
ResultCallback
resultEventCallback
)
{
socketManageer
.
login
(
username
,
password
,
appId
,
new
ResultEventCallback
<
String
>()
{
@Override
public
void
onSuccess
(
String
s
)
{
resultEventCallback
.
onSuccess
();
}
@Override
public
void
onFailed
(
int
errorCode
)
{
resultEventCallback
.
onFailed
(
errorCode
);
}
});
}
/**
* 获取联系人列表
*/
public
synchronized
void
getCha
tList
(
ResultEventCallback
<
Chat
.
PullContactsResponse
>
resultEventCallback
)
{
public
void
getContac
tList
(
ResultEventCallback
<
Chat
.
PullContactsResponse
>
resultEventCallback
)
{
Chat
.
PullContactsRequest
builder
=
Chat
.
PullContactsRequest
.
newBuilder
()
.
build
();
int
id
=
socketManageer
.
sendRequest
(
builder
);
...
...
@@ -109,21 +96,18 @@ public class CCIMClient {
/**
* 同步离线消息
*/
public
void
getOfflineMessage
(
ResultEventCallback
<
ArrayList
<
Message
.
PullOfflineMessageResponse
.
OfflineMessage
>>
resultEventCallback
)
{
ArrayList
<
Message
.
PullOfflineMessageResponse
.
OfflineMessage
>
offlineMessages
=
new
ArrayList
<>();
Message
.
PullOfflineMessageRequest
offlineMessageRequest
=
Message
.
PullOfflineMessageRequest
.
newBuilder
().
build
();
int
id
=
socketManageer
.
sendRequest
(
offlineMessageRequest
);
public
void
getOfflineMessage
(
Long
lastPullMsgId
,
ResultEventCallback
<
List
<
Message
.
PullOfflineMessageResponse
.
OfflineMessage
>>
resultEventCallback
)
{
Message
.
PullOfflineMessageRequest
offlineMessageRequest
=
Message
.
PullOfflineMessageRequest
.
newBuilder
()
.
setLastPulledMsgId
(
lastPullMsgId
)
.
build
();
int
id
=
socketManageer
.
sendRequest
(
offlineMessageRequest
);
callBackManager
.
addCallBack
(
id
,
new
ResultEventCallback
<
Chat
.
ChatResponseMessage
>()
{
@Override
public
void
onSuccess
(
Chat
.
ChatResponseMessage
chatResponseMessage
)
{
if
(
chatResponseMessage
.
hasPullOfflineMsgRes
())
{
logger
.
info
(
String
.
valueOf
(
chatResponseMessage
));
List
<
Message
.
PullOfflineMessageResponse
.
OfflineMessage
>
offlineMsgsList
=
chatResponseMessage
.
getPullOfflineMsgRes
().
getOfflineMsgsList
();
offlineMessages
.
addAll
(
offlineMsgsList
);
if
(
offlineMsgsList
.
isEmpty
())
{
resultEventCallback
.
onSuccess
(
offlineMessages
);
callBackManager
.
removeCallBack
(
chatResponseMessage
.
getHeader
().
getSeq
());
}
resultEventCallback
.
onSuccess
(
offlineMsgsList
);
}
}
...
...
@@ -186,7 +170,7 @@ public class CCIMClient {
/**
* 联系人申请列表
*/
public
void
getContactReq
uests
(
ResultEventCallback
<
Chat
.
ContactRequestsResponse
>
callback
)
{
public
void
getContactReq
List
(
ResultEventCallback
<
Chat
.
ContactRequestsResponse
>
callback
)
{
Chat
.
ContactRequestsRequest
contactRequestsRequest
=
Chat
.
ContactRequestsRequest
.
newBuilder
().
build
();
int
id
=
socketManageer
.
sendRequest
(
contactRequestsRequest
);
callBackManager
.
addCallBack
(
id
,
new
ResultEventCallback
<
Chat
.
ChatResponseMessage
>()
{
...
...
@@ -235,7 +219,7 @@ public class CCIMClient {
/**
* 创建联系人群组
*/
public
void
createContactGroup
(
String
name
,
ResultEventCallback
<
Long
>
callback
)
{
public
void
createContactGroup
(
String
name
,
ResultEventCallback
<
Chat
.
CreateContactGroupResponse
>
callback
)
{
Chat
.
CreateContactGroupRequest
createContactGroupRequest
=
Chat
.
CreateContactGroupRequest
.
newBuilder
()
.
setName
(
name
)
.
build
();
...
...
@@ -246,7 +230,7 @@ public class CCIMClient {
if
(
chatResponseMessage
.
hasCreateContactGroupRes
())
{
logger
.
info
(
String
.
valueOf
(
chatResponseMessage
));
Chat
.
CreateContactGroupResponse
createContactGroupRes
=
chatResponseMessage
.
getCreateContactGroupRes
();
callback
.
onSuccess
(
createContactGroupRes
.
getGroupId
()
);
callback
.
onSuccess
(
createContactGroupRes
);
}
}
...
...
@@ -364,7 +348,7 @@ public class CCIMClient {
public
void
sendTextMessage
(
String
content
,
Long
reciveUserId
,
ResultCallback
callback
)
{
Message
.
SendMessageRequest
messageRequest
=
Message
.
SendMessageRequest
.
newBuilder
()
.
setContent
(
content
)
.
setMsgType
(
MessageSpec
.
MessageType
.
TEXT
)
.
setMsgType
(
MessageSpec
.
MessageType
.
MESSAGE_TYPE_
TEXT
)
.
setReceiverUserId
(
reciveUserId
).
build
();
int
id
=
socketManageer
.
sendRequest
(
messageRequest
);
callBackManager
.
addCallBack
(
id
,
new
ResultEventCallback
<
Chat
.
ChatResponseMessage
>()
{
...
...
@@ -383,39 +367,13 @@ public class CCIMClient {
});
}
/**
* 发送群组消息
*/
public
void
sendGroupMessage
(
String
content
,
Long
groupId
,
ResultCallback
callback
)
{
Message
.
SendGroupMessageRequest
sendGroupMessageRequest
=
Message
.
SendGroupMessageRequest
.
newBuilder
()
.
setContent
(
content
)
.
setMsgType
(
MessageSpec
.
MessageType
.
TEXT
)
.
setGroupId
(
groupId
)
.
build
();
int
id
=
socketManageer
.
sendRequest
(
sendGroupMessageRequest
);
callBackManager
.
addCallBack
(
id
,
new
ResultEventCallback
<
Chat
.
ChatResponseMessage
>()
{
@Override
public
void
onSuccess
(
Chat
.
ChatResponseMessage
chatResponseMessage
)
{
if
(
chatResponseMessage
.
hasSendGroupMsgRes
())
{
logger
.
info
(
String
.
valueOf
(
chatResponseMessage
));
callback
.
onSuccess
();
}
}
@Override
public
void
onFailed
(
int
errorCode
)
{
callback
.
onFailed
(
errorCode
);
}
});
}
/**
* 发送群组消息
*/
public
void
sendChannelMessage
(
String
content
,
Long
channelId
,
ResultCallback
callback
)
{
Message
.
SendChannelMessageRequest
sendChannelMessageRequest
=
Message
.
SendChannelMessageRequest
.
newBuilder
()
.
setContent
(
content
)
.
setMsgType
(
MessageSpec
.
MessageType
.
TEXT
)
.
setMsgType
(
MessageSpec
.
MessageType
.
MESSAGE_TYPE_
TEXT
)
.
setChannelId
(
channelId
)
.
build
();
int
id
=
socketManageer
.
sendRequest
(
sendChannelMessageRequest
);
...
...
@@ -447,17 +405,6 @@ public class CCIMClient {
callBackManager
.
addCallBack
(
id
,
chatResponseMessage
->
logger
.
info
(
String
.
valueOf
(
chatResponseMessage
)));
}
/**
* 推送渠道消息成功ack
*/
public
void
pushGroupMessageAck
(
Long
groupId
,
Long
msgId
)
{
Push
.
PushGroupMessageAckRequest
groupMessageAckRequest
=
Push
.
PushGroupMessageAckRequest
.
newBuilder
()
.
setGroupId
(
groupId
)
.
setMsgId
(
msgId
)
.
build
();
int
id
=
socketManageer
.
sendRequest
(
groupMessageAckRequest
);
callBackManager
.
addCallBack
(
id
,
chatResponseMessage
->
logger
.
info
(
String
.
valueOf
(
chatResponseMessage
)));
}
/**
* 推送渠道消息成功ack
...
...
@@ -471,4 +418,35 @@ public class CCIMClient {
callBackManager
.
addCallBack
(
id
,
chatResponseMessage
->
logger
.
info
(
String
.
valueOf
(
chatResponseMessage
)));
}
/**
* 开始录音
*/
public
void
startRecordAudioMessage
(
FragmentActivity
activity
)
{
PermissionX
.
init
(
activity
)
.
permissions
(
Manifest
.
permission
.
RECORD_AUDIO
)
.
onExplainRequestReason
((
scope
,
deniedList
,
beforeRequest
)
->
scope
.
showRequestReasonDialog
(
deniedList
,
"即将申请的权限是程序必须依赖的权限"
,
"我已明白"
))
.
onForwardToSettings
((
scope
,
deniedList
)
->
scope
.
showForwardToSettingsDialog
(
deniedList
,
"您需要去应用程序设置当中手动开启权限"
,
"我已明白"
))
.
request
((
allGranted
,
grantedList
,
deniedList
)
->
{
if
(
allGranted
)
{
MediaHelper
.
getInstance
().
prepare
(
activity
);
}
});
}
public
void
stopAndSendAudioMessage
(){
MediaHelper
.
getInstance
().
release
();
String
filePath
=
MediaHelper
.
getInstance
().
getFilePath
();
}
public
void
cancleAudioMessage
(){
MediaHelper
.
getInstance
().
cancel
();
}
public
void
startPlayAudio
(
String
filePath
){
MediaHelper
.
getInstance
().
play
(
filePath
);
}
}
ccim/src/main/java/com/ccwangluo/ccim/listener/OnConnectListener.java
0 → 100644
View file @
df78610d
package
com.ccwangluo.ccim.listener
;
public
interface
OnConnectListener
{
void
onSocketConnection
();
void
onSocketDisconnection
();
}
ccim/src/main/java/com/ccwangluo/ccim/manage/CallBackManager.java
View file @
df78610d
...
...
@@ -10,10 +10,10 @@ import java.util.HashMap;
public
class
CallBackManager
<
T
>
{
private
final
HashMap
<
Integer
,
ResultEventCallback
<
T
>>
callbackHashMap
=
new
HashMap
<>();
private
final
int
time_out
=
60
*
1000
;
private
static
final
int
time_out
=
60
*
1000
;
public
synchronized
void
addCallBack
(
int
id
,
ResultEventCallback
<
T
>
resultEventCallback
)
{
public
void
addCallBack
(
int
id
,
ResultEventCallback
<
T
>
resultEventCallback
)
{
callbackHashMap
.
put
(
id
,
resultEventCallback
);
//设置60秒超时
new
Handler
(
Looper
.
getMainLooper
()).
postDelayed
(()
->
{
...
...
@@ -25,11 +25,11 @@ public class CallBackManager<T> {
},
time_out
);
}
public
synchronized
ResultEventCallback
<
T
>
getCallBack
(
int
id
)
{
public
ResultEventCallback
<
T
>
getCallBack
(
int
id
)
{
return
callbackHashMap
.
get
(
id
);
}
public
synchronized
void
removeCallBack
(
int
id
)
{
public
void
removeCallBack
(
int
id
)
{
callbackHashMap
.
remove
(
id
);
}
...
...
ccim/src/main/java/com/ccwangluo/ccim/manage/SocketManageer.java
View file @
df78610d
package
com.ccwangluo.ccim.manage
;
import
android.text.TextUtils
;
import
com.ccwangluo.ccim.CCIMClient
;
import
com.ccwangluo.ccim.listener.OnConnectListener
;
import
com.ccwangluo.ccim.modle.IrequestData
;
import
com.ccwangluo.ccim.modle.MyIReaderProtocol
;
import
com.ccwangluo.ccim.listener.MessageListener
;
import
com.ccwangluo.ccim.listener.ResultEventCallback
;
import
com.ccwangluo.ccim.util.HmacUtil
;
import
com.xuhao.didi.core.pojo.OriginalData
;
import
com.xuhao.didi.socket.client.sdk.OkSocket
;
import
com.xuhao.didi.socket.client.sdk.client.ConnectionInfo
;
import
com.xuhao.didi.socket.client.sdk.client.OkSocketOptions
;
import
com.xuhao.didi.socket.client.sdk.client.action.SocketActionAdapter
;
import
com.xuhao.didi.socket.client.sdk.client.connection.IConnectionManager
;
import
java.util.logging.Logger
;
import
ccim.protocol.Auth
;
import
ccim.protocol.Chat
;
import
ccim.protocol.Common
;
import
ccim.protocol.Message
;
import
ccim.protocol.Push
;
public
class
SocketManageer
{
private
final
Logger
logger
=
Logger
.
getLogger
(
CCIMClient
.
class
.
getName
());
private
final
int
version
=
1
;
private
static
final
String
SERVER_IP
=
"117.144.156.2"
;
private
static
final
int
SERVER_PORT
=
8000
;
private
static
final
int
version
=
1
;
private
volatile
int
id
=
1
;
...
...
@@ -34,23 +34,9 @@ public class SocketManageer {
this
.
callBackManager
=
callBackManager
;
}
private
ConnectionInfo
authInfo
;
private
ConnectionInfo
chatInfo
;
private
String
token
;
private
ResultEventCallback
<
String
>
loginCallBack
;
private
OnConnectListener
onConnectListener
;
public
String
getToken
()
{
return
token
;
}
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
public
ConnectionInfo
getAuthInfo
()
{
return
authInfo
;
}
private
ConnectionInfo
chatInfo
;
public
ConnectionInfo
getChatInfo
()
{
...
...
@@ -58,58 +44,32 @@ public class SocketManageer {
}
public
void
initAuth
()
{
//连接参数设置(IP,端口号),这也是一个连接的唯一标识,不同连接,该参数中的两个值至少有其一不一样
this
.
authInfo
=
initServer
(
"117.144.156.2"
,
9000
,
data
->
{
try
{
Auth
.
AuthResponseMessage
chatResponseMessage
=
Auth
.
AuthResponseMessage
.
parseFrom
(
data
.
getBodyBytes
());
logger
.
info
(
String
.
valueOf
(
chatResponseMessage
));
if
(
chatResponseMessage
.
getHeader
().
getCode
()
==
0
)
{
token
=
chatResponseMessage
.
getLoginRes
().
getToken
();
String
server
=
chatResponseMessage
.
getLoginRes
().
getServer
();
initChat
(
server
);
OkSocket
.
open
(
authInfo
).
disconnect
();
if
(
loginCallBack
!=
null
){
loginCallBack
.
onSuccess
(
token
);
}
}
else
{
if
(
loginCallBack
!=
null
){
loginCallBack
.
onFailed
(
chatResponseMessage
.
getHeader
().
getCode
());
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
});
}
public
void
login
(
String
username
,
String
password
,
Long
appId
,
ResultEventCallback
<
String
>
resultEventCallback
)
{
Auth
.
LoginRequest
.
Builder
builder
=
Auth
.
LoginRequest
.
newBuilder
().
setUsername
(
username
).
setPassword
(
password
).
setAppId
(
appId
);
Auth
.
AuthRequestMessage
build
=
Auth
.
AuthRequestMessage
.
newBuilder
().
setLoginReq
(
builder
.
build
()).
build
();
OkSocket
.
open
(
getAuthInfo
())
.
send
(
new
IrequestData
(
build
.
toByteArray
()));
this
.
loginCallBack
=
resultEventCallback
;
}
public
void
connectChatServer
()
{
if
(
TextUtils
.
isEmpty
(
getToken
()))
{
return
;
}
Chat
.
ConnectRequest
builder
=
Chat
.
ConnectRequest
.
newBuilder
().
setToken
(
getToken
()).
build
();
public
void
connectChatServer
(
String
appKey
,
String
userName
,
Long
userId
,
Long
ts
,
String
sign
)
{
Chat
.
ConnectRequest
builder
=
Chat
.
ConnectRequest
.
newBuilder
()
.
setUsername
(
userName
)
.
setAppKey
(
appKey
)
.
setUserId
(
userId
)
.
setTs
(
ts
)
.
setSign
(
sign
)
.
build
();
Common
.
RequestMessageHeader
header
=
Common
.
RequestMessageHeader
.
newBuilder
().
setVersion
(
1
).
setSeq
(
1
).
build
();
Chat
.
ChatRequestMessage
build
=
Chat
.
ChatRequestMessage
.
newBuilder
().
setConnectReq
(
builder
).
setHeader
(
header
).
build
();
OkSocket
.
open
(
getChatInfo
())
.
send
(
new
IrequestData
(
build
.
toByteArray
()));
callBackManager
.
addCallBack
(
idPlus
(),
new
ResultEventCallback
<
Chat
.
ChatResponseMessage
>()
{
@Override
public
void
onSuccess
(
Chat
.
ChatResponseMessage
chatResponseMessage
)
{
onConnectListener
.
onSocketConnection
();
}
});
}
private
void
initChat
(
String
server
)
{
//连接参数设置(IP,端口号),这也是一个连接的唯一标识,不同连接,该参数中的两个值至少有其一不一样
String
[]
split
=
server
.
split
(
":"
);
this
.
chatInfo
=
initServer
(
split
[
0
],
Integer
.
parseInt
(
split
[
1
]),
new
MessageListener
()
{
public
void
initChat
(
String
appKey
,
String
userName
,
Long
userId
,
Long
ts
,
String
sign
,
OnConnectListener
resultCallback
)
{
onConnectListener
=
resultCallback
;
this
.
chatInfo
=
initServer
(
SERVER_IP
,
SERVER_PORT
,
new
MessageListener
()
{
@Override
public
void
onServerConnect
()
{
connectChatServer
();
connectChatServer
(
appKey
,
userName
,
userId
,
ts
,
sign
);
}
@Override
...
...
@@ -120,10 +80,10 @@ public class SocketManageer {
ResultEventCallback
<
Chat
.
ChatResponseMessage
>
callBack
=
callBackManager
.
getCallBack
(
seq
);
if
(
callBack
!=
null
)
{
if
(
seq
>
0
)
{
if
(
chatResponseMessage
.
getHeader
().
getCode
()
==
0
)
{
if
(
chatResponseMessage
.
getHeader
().
getCode
()
==
Common
.
StatusCode
.
STATUS_CODE_OK
)
{
callBack
.
onSuccess
(
chatResponseMessage
);
}
else
{
callBack
.
onFailed
(
chatResponseMessage
.
getHeader
().
getCode
());
callBack
.
onFailed
(
chatResponseMessage
.
getHeader
().
getCode
()
.
getNumber
()
);
}
if
(!
chatResponseMessage
.
hasPullOfflineMsgRes
())
{
callBackManager
.
removeCallBack
(
seq
);
...
...
@@ -146,35 +106,27 @@ public class SocketManageer {
//调用OkSocket,开启这次连接的通道,拿到通道Manager
IConnectionManager
manager
=
OkSocket
.
open
(
authInfo
);
//获得当前连接通道的参配对象
OkSocketOptions
options
=
manager
.
getOption
();
//基于当前参配对象构建一个参配建造者类
OkSocketOptions
.
Builder
builder
=
new
OkSocketOptions
.
Builder
(
options
);
//修改参配设置(其他参配请参阅类文档)
// builder.setSinglePackageBytes(size);
//建造一个新的参配对象并且付给通道
manager
.
option
(
builder
.
build
());
//调用通道进行连接
manager
.
connect
();
//设置自定义解析头
OkSocketOptions
.
Builder
okOptionsBuilder
=
new
OkSocketOptions
.
Builder
();
okOptionsBuilder
.
setReaderProtocol
(
new
MyIReaderProtocol
());
okOptionsBuilder
.
setConnectionHolden
(
false
);
//将新的修改后的参配设置给连接管理器
manager
.
option
(
okOptionsBuilder
.
build
());
//调用通道进行连接
manager
.
connect
();
manager
.
registerReceiver
(
new
SocketActionAdapter
()
{
@Override
public
void
onSocketConnectionSuccess
(
ConnectionInfo
info
,
String
action
)
{
super
.
onSocketConnectionSuccess
(
info
,
action
);
logger
.
info
(
"connect success"
);
messageListener
.
onServerConnect
();
}
@Override
public
void
onSocketDisconnection
(
ConnectionInfo
info
,
String
action
,
Exception
e
)
{
super
.
onSocketDisconnection
(
info
,
action
,
e
);
logger
.
info
(
"disconnect success"
);
if
(
onConnectListener
!=
null
)
{
onConnectListener
.
onSocketDisconnection
();
}
}
@Override
...
...
@@ -186,8 +138,9 @@ public class SocketManageer {
return
authInfo
;
}
public
synchronized
int
sendRequest
(
Object
request
)
{
Common
.
RequestMessageHeader
header
=
Common
.
RequestMessageHeader
.
newBuilder
().
setVersion
(
version
).
setSeq
(
id
).
build
();
public
int
sendRequest
(
Object
request
)
{
int
idPlus
=
idPlus
();
Common
.
RequestMessageHeader
header
=
Common
.
RequestMessageHeader
.
newBuilder
().
setVersion
(
version
).
setSeq
(
idPlus
).
build
();
Chat
.
ChatRequestMessage
.
Builder
builder
=
Chat
.
ChatRequestMessage
.
newBuilder
();
builder
.
setHeader
(
header
);
if
(
request
instanceof
Chat
.
PullContactsRequest
){
...
...
@@ -212,14 +165,10 @@ public class SocketManageer {
builder
.
setReportIllegalUserReq
((
Chat
.
ReportIllegalUserRequest
)
request
);
}
else
if
(
request
instanceof
Message
.
SendMessageRequest
){
builder
.
setSendMsgReq
((
Message
.
SendMessageRequest
)
request
);
}
else
if
(
request
instanceof
Message
.
SendGroupMessageRequest
){
builder
.
setSendGroupMsgReq
((
Message
.
SendGroupMessageRequest
)
request
);
}
else
if
(
request
instanceof
Message
.
SendChannelMessageRequest
){
builder
.
setSendChannelMsgReq
((
Message
.
SendChannelMessageRequest
)
request
);
}
else
if
(
request
instanceof
Push
.
PushPrivateMessageAckRequest
){
builder
.
setPushPrivateMsgAckReq
((
Push
.
PushPrivateMessageAckRequest
)
request
);
}
else
if
(
request
instanceof
Push
.
PushGroupMessageAckRequest
){
builder
.
setPushGroupMsgAckReq
((
Push
.
PushGroupMessageAckRequest
)
request
);
}
else
if
(
request
instanceof
Push
.
PushChannelMessageAckRequest
){
builder
.
setPushChannelMsgAckReq
((
Push
.
PushChannelMessageAckRequest
)
request
);
}
else
if
(
request
instanceof
Message
.
PullOfflineMessageRequest
){
...
...
@@ -229,6 +178,13 @@ public class SocketManageer {
OkSocket
.
open
(
getChatInfo
())
.
send
(
new
IrequestData
(
builder
.
build
().
toByteArray
()));
return
idPlus
;
}
public
synchronized
int
idPlus
()
{
if
(
id
==
Integer
.
MAX_VALUE
){
id
=
1
;
}
return
id
++;
}
...
...
ccim/src/main/java/com/ccwangluo/ccim/util/HmacUtil.java
0 → 100644
View file @
df78610d
package
com.ccwangluo.ccim.util
;
import
android.util.Base64
;
import
android.util.Log
;
import
javax.crypto.KeyGenerator
;
import
javax.crypto.Mac
;
import
javax.crypto.SecretKey
;
import
javax.crypto.spec.SecretKeySpec
;
import
com.google.common.base.Strings
;
import
javax.crypto.KeyGenerator
;
import
javax.crypto.Mac
;
import
javax.crypto.SecretKey
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.io.UnsupportedEncodingException
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
/**
* Created by xiang.li on 2015/2/27.
*/
public
class
HmacUtil
{
private
final
static
String
LOG_TAG
=
HmacUtil
.
class
.
getName
();
public
static
String
stringToSign
(
String
appSecret
,
String
data
)
{
try
{
Mac
mac
=
Mac
.
getInstance
(
"hmacSHA256"
);
SecretKeySpec
secret
=
new
SecretKeySpec
(
appSecret
.
getBytes
(
"UTF-8"
),
mac
.
getAlgorithm
());
mac
.
init
(
secret
);
byte
[]
bytes
=
mac
.
doFinal
(
data
.
getBytes
());
return
bytesToHex
(
bytes
);
}
catch
(
NoSuchAlgorithmException
e
)
{
Log
.
e
(
LOG_TAG
,
"Hash algorithm SHA-1 is not supported"
,
e
);
}
catch
(
UnsupportedEncodingException
e
)
{
Log
.
e
(
LOG_TAG
,
"Encoding UTF-8 is not supported"
,
e
);
}
catch
(
InvalidKeyException
e
)
{
Log
.
e
(
LOG_TAG
,
"Invalid key"
,
e
);
}
return
""
;
}
public
static
String
bytesToHex
(
byte
[]
bytes
)
{
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
bytes
.
length
;
i
++)
{
String
hex
=
Integer
.
toHexString
(
bytes
[
i
]
&
0xFF
);
if
(
hex
.
length
()
<
2
){
sb
.
append
(
0
);
}
sb
.
append
(
hex
);
}
return
sb
.
toString
();
}
}
ccim/src/main/java/com/ccwangluo/ccim/util/MediaHelper.java
View file @
df78610d
package
com.ccwangluo.ccim.util
;
import
android.app.Activity
;
import
android.media.MediaPlayer
;
import
android.media.MediaRecorder
;
import
android.os.Build
;
import
android.os.Environment
;
import
java.io.File
;
import
java.io.IOException
;
public
class
MediaHelper
{
private
MediaRecorder
mMediaRecorder
;
private
String
mPath
;
//文件夹
private
String
mFilePath
;
//文件
private
static
MediaHelper
mInstance
;
private
MediaHelper
(
String
path
)
{
mPath
=
path
;
}
/**
* 准备播放后的回调
* 这个时候文件夹里已经有文件生成了
* 如果不去释放资源将会一直进行录音
*/
public
interface
MediaStateListener
{
void
preparedDone
();
}
public
MediaStateListener
mMediaStateListener
;
public
void
setMediaStateListener
(
MediaStateListener
mediaStateListener
)
{
mMediaStateListener
=
mediaStateListener
;
}
/**
* 单例模式获取 MediaHelper
* 双检锁/双重校验锁
*
* @param path
* @return
*/
public
static
MediaHelper
getInstance
(
String
path
)
{
public
static
MediaHelper
getInstance
()
{
if
(
mInstance
==
null
)
{
synchronized
(
MediaHelper
.
class
)
{
if
(
mInstance
==
null
)
{
mInstance
=
new
MediaHelper
(
path
);
mInstance
=
new
MediaHelper
();
}
}
}
...
...
@@ -52,9 +32,18 @@ public class MediaHelper {
/**
* 准备录音
*/
public
void
prepare
()
{
public
void
prepare
(
Activity
activity
)
{
try
{
File
fileDir
=
new
File
(
mPath
);
if
(
mMediaRecorder
!=
null
){
cancel
();
}
String
path
;
if
(
Environment
.
getExternalStorageState
().
equals
(
Environment
.
MEDIA_MOUNTED
))
{
path
=
activity
.
getExternalFilesDir
(
"test"
).
getAbsolutePath
();
}
else
{
path
=
activity
.
getCacheDir
().
getAbsolutePath
();
}
File
fileDir
=
new
File
(
path
);
boolean
b
=
!
fileDir
.
exists
();
if
(
b
)
{
fileDir
.
mkdirs
();
...
...
@@ -72,13 +61,10 @@ public class MediaHelper {
mMediaRecorder
.
setOutputFile
(
new
File
(
file
.
getAbsolutePath
()));
}
mMediaRecorder
.
setAudioSource
(
MediaRecorder
.
AudioSource
.
MIC
);
// 设置MediaRecorder的音频源为麦克风
mMediaRecorder
.
setOutputFormat
(
MediaRecorder
.
OutputFormat
.
A
MR_NB
);
// 设置音频的格式
mMediaRecorder
.
setAudioEncoder
(
MediaRecorder
.
AudioEncoder
.
A
MR_NB
);
// 设置音频的编码为AMR_NB
mMediaRecorder
.
setOutputFormat
(
MediaRecorder
.
OutputFormat
.
A
AC_ADTS
);
// 设置音频的格式
mMediaRecorder
.
setAudioEncoder
(
MediaRecorder
.
AudioEncoder
.
A
AC
);
// 设置音频的编码为AMR_NB
mMediaRecorder
.
prepare
();
mMediaRecorder
.
start
();
if
(
mMediaStateListener
!=
null
)
{
mMediaStateListener
.
preparedDone
();
}
}
catch
(
IllegalStateException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
...
...
@@ -89,10 +75,12 @@ public class MediaHelper {
* 释放资源
*/
public
void
release
()
{
if
(
mMediaRecorder
!=
null
)
{
mMediaRecorder
.
stop
();
mMediaRecorder
.
release
();
mMediaRecorder
=
null
;
}
}
/**
* 取消
*/
...
...
@@ -107,6 +95,24 @@ public class MediaHelper {
mFilePath
=
null
;
}
}
/**
* 播放
* @param filePath
*/
public
void
play
(
String
filePath
)
{
MediaPlayer
mediaPlayer
=
new
MediaPlayer
();
try
{
mediaPlayer
.
setDataSource
(
filePath
);
mediaPlayer
.
prepare
();
//播放
mediaPlayer
.
start
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
//获取生成的文件路径
public
String
getFilePath
()
{
return
mFilePath
;
...
...
ccim/src/main/proto/channel.proto
0 → 100644
View file @
df78610d
syntax
=
"proto3"
;
package
ccim
.
protocol
;
message
CreateChannelRequest
{
string
name
=
1
;
bool
open
=
2
;
repeated
int64
user_ids
=
3
;
}
message
CreateChannelResponse
{
int64
channel_id
=
1
;
}
message
JoinChannelRequest
{
int64
channel_id
=
1
;
}
message
JoinChannelResponse
{
}
message
RemoveMemberRequest
{
int64
channel_id
=
1
;
int64
user_id
=
2
;
}
message
RemoveMemberResponse
{}
message
ExitChannelRequest
{
int64
channel_id
=
1
;
}
message
ExitChannelResponse
{
}
ccim/src/main/proto/chat.proto
View file @
df78610d
...
...
@@ -2,6 +2,7 @@ syntax = "proto3";
package
ccim
.
protocol
;
import
"channel.proto"
;
import
"common.proto"
;
import
"message.proto"
;
import
"push.proto"
;
...
...
@@ -10,24 +11,29 @@ message ChatRequestMessage {
RequestMessageHeader
header
=
1
;
oneof
payload
{
ConnectRequest
connect_req
=
2
;
PullContactsRequest
pull_contacts_req
=
3
;
SearchRequest
search_req
=
4
;
AddContactRequest
add_contact_req
=
5
;
ContactRequestsRequest
contact_requests_req
=
6
;
CheckContactReqRequest
check_contact_req_req
=
7
;
CreateContactGroupRequest
create_contact_group_req
=
8
;
MoveContactGroupRequest
move_contact_group_req
=
9
;
DeleteContactRequest
delete_contact_req
=
10
;
BlockContactRequest
block_contact_req
=
11
;
ReportIllegalUserRequest
report_illegal_user_req
=
12
;
SendMessageRequest
send_msg_req
=
13
;
SendGroupMessageRequest
send_group_msg_req
=
14
;
SendChannelMessageRequest
send_channel_msg_req
=
15
;
PushPrivateMessageAckRequest
push_private_msg_ack_req
=
16
;
PushGroupMessageAckRequest
push_group_msg_ack_req
=
17
;
PushChannelMessageAckRequest
push_channel_msg_ack_req
=
18
;
PullOfflineMessageRequest
pull_offline_msg_req
=
19
;
ConnectRequest
connect_req
=
2
;
// 连接
PullContactsRequest
pull_contacts_req
=
3
;
// 拉联系人
SearchRequest
search_req
=
4
;
// 查找用户
AddContactRequest
add_contact_req
=
5
;
// 添加联系人
ContactRequestsRequest
contact_requests_req
=
6
;
// 联系人申请列表
CheckContactReqRequest
check_contact_req_req
=
7
;
// 验证联系人申请
CreateContactGroupRequest
create_contact_group_req
=
8
;
// 创建联系人群组
MoveContactGroupRequest
move_contact_group_req
=
9
;
// 移动联系人所在群组
DeleteContactRequest
delete_contact_req
=
10
;
// 删除联系人
BlockContactRequest
block_contact_req
=
11
;
// 联系人拉入黑名单
ReportIllegalUserRequest
report_illegal_user_req
=
12
;
// 举报违规用户
PullOfflineMessageRequest
pull_offline_msg_req
=
13
;
// 拉取离线消息
CreateChannelRequest
create_channel_req
=
21
;
// 创建频道
JoinChannelRequest
join_channel_req
=
22
;
// 加入频道
RemoveMemberRequest
remove_member_req
=
23
;
// 移除成员
ExitChannelRequest
exit_channel_req
=
24
;
// 退出频道
SendMessageRequest
send_msg_req
=
42
;
// 发送消息
SendChannelMessageRequest
send_channel_msg_req
=
43
;
// 发送频道消息
PushPrivateMessageAckRequest
push_private_msg_ack_req
=
61
;
// 推送私人消息成功ack
PushChannelMessageAckRequest
push_channel_msg_ack_req
=
62
;
// 推送频道消息ack
}
};
...
...
@@ -45,19 +51,31 @@ message ChatResponseMessage {
MoveContactGroupResponse
move_contact_group_res
=
9
;
DeleteContactResponse
delete_contact_res
=
10
;
BlockContactResponse
block_contact_res
=
11
;
ReportIllegalUserResponse
report_illegal_user_res
=
12
;
SendMessageResponse
send_msg_res
=
13
;
SendGroupMessageResponse
send_group_msg_res
=
14
;
SendChannelMessageResponse
send_channel_msg_res
=
15
;
PushPrivateMessageResponse
push_private_msg_res
=
16
;
PushGroupMessageResponse
push_group_msg_res
=
17
;
PushChannelMessageResponse
push_channel_msg_res
=
18
;
PullOfflineMessageResponse
pull_offline_msg_res
=
19
;
PullOfflineMessageResponse
pull_offline_msg_res
=
12
;
CreateChannelResponse
create_channel_res
=
21
;
JoinChannelResponse
join_channel_res
=
22
;
RemoveMemberResponse
remove_member_res
=
23
;
ExitChannelResponse
exit_channel_res
=
24
;
ReportIllegalUserResponse
report_illegal_user_res
=
41
;
SendMessageResponse
send_msg_res
=
42
;
SendChannelMessageResponse
send_channel_msg_res
=
43
;
PushPrivateMessageResponse
push_private_msg_res
=
61
;
PushChannelMessageResponse
push_channel_msg_res
=
62
;
}
};
message
ConnectRequest
{
string
token
=
1
;
string
app_key
=
1
;
int64
user_id
=
2
;
string
username
=
3
;
int64
ts
=
4
;
string
sign
=
5
;
// sign使用HMAC加密算法,由接入端的服务端计算完成传给接入端的客户端
// sign = HMAC(app_secret).digestToHex(app_key&user_id&username&ts&app_secret)
// ts=CurrentTimeMillis (毫秒)
}
message
ConnectResponse
{
...
...
@@ -88,15 +106,15 @@ message PullContactsResponse {
Status
status
=
8
;
// 联系人状态
string
ext_data
=
9
;
// 扩展数据
}
message
Group
{
int64
group_id
=
1
;
int64
app_id
=
2
;
int64
owner_user_id
=
3
;
int32
limited
=
4
;
bool
muted
=
5
;
string
name
=
6
;
string
ext_data
=
7
;
}
//
message Group {
//
int64 group_id = 1;
//
int64 app_id = 2;
//
int64 owner_user_id = 3;
//
int32 limited = 4;
//
bool muted = 5;
//
string name = 6;
//
string ext_data = 7;
//
}
message
Channel
{
int64
channel_id
=
1
;
int64
app_id
=
2
;
...
...
@@ -108,8 +126,8 @@ message PullContactsResponse {
}
repeated
ContactGroup
contact_groups
=
2
;
// 联系人群组列表
repeated
Contact
contacts
=
3
;
// 联系人列表
repeated
Group
groups
=
4
;
// 群组
repeated
Channel
channels
=
5
;
// 频道
// repeated Group groups = 4;
// 群组
repeated
Channel
channels
=
4
;
// 频道
}
message
SearchRequest
{
...
...
@@ -134,7 +152,7 @@ message AddContactResponse {
ALREADY_SENT
=
1
;
NO_AUTHORITY
=
2
;
ALREADY_CONTACT
=
3
;
ACCEPT_REQ
=
4
;
ACCEPT_REQ
=
4
;
// 接受对方的好友申请(对方已经发送申请,自己不必申请直接同意)
}
AddResult
result
=
1
;
}
...
...
ccim/src/main/proto/common.proto
View file @
df78610d
...
...
@@ -2,14 +2,38 @@ syntax = "proto3";
package
ccim
.
protocol
;
//enum StatusCode {
// OK = 0;
// UNKNOWN_SERVER_ERROR = 100;
// AUTH_ERROR = 101;
// AUTH_INCORRECT_INPUT_ERROR = 102;
//
// CHAT_SERVICE_ERROR = 201;
//}
enum
StatusCode
{
STATUS_CODE_OK
=
0
;
// 正常
STATUS_CODE_SERVER_INTERNAL_ERROR
=
10000
;
// 服务器内部未知错误
STATUS_CODE_TOO_FREQUENTLY_ERROR
=
10001
;
// 调用过于频繁
STATUS_CODE_UNKNOWN_REQUEST_ERROR
=
10002
;
// 未知请求
STATUS_CODE_INVALID_ARGUMENTS_ERROR
=
10003
;
// 无效参数
// AUTH_ERROR = 20000;
STATUS_CODE_AUTH_INCORRECT_INPUT_ERROR
=
20001
;
// 认证无效输入
STATUS_CODE_NO_AUTH_ERROR
=
20002
;
// 未认证
STATUS_CODE_INVALID_APP_KEY
=
20003
;
// 无效app_key
STATUS_CODE_SIGN_EXPIRED
=
20004
;
// 签名过期
STATUS_CODE_INVALID_SIGN
=
20005
;
// 无效签名
// CHAT_SERVICE_ERROR = 30000;
STATUS_CODE_CHECK_CONTACT_UPDATED_ERROR
=
30001
;
// 好友请求已同意或拒绝
STATUS_CODE_CONTACT_GROUP_EXCEEDED_LIMIT_ERROR
=
30002
;
// 群组成员到达上限
STATUS_CODE_NOT_CONTACT_ERROR
=
30101
;
// 非好友不能调用该api
STATUS_CODE_USER_MUTED_ERROR
=
30102
;
// 用户被禁言
STATUS_CODE_CONTACT_BLOCKED_ERROR
=
30103
;
// 联系人已被拉入黑名单
STATUS_CODE_CONTACT_BLOCKED_ME_ERROR
=
30104
;
// 联系人已把我拉入黑名单
// STATUS_CODE_GROUP_NOT_MEMBER_ERROR = 30201;
// STATUS_CODE_GROUP_MUTED_ME_ERROR = 30202;
STATUS_CODE_CHANNEL_NOT_MEMBER_ERROR
=
30302
;
// 非频道成员不能调用该api
STATUS_CODE_CHANNEL_MUTED_ME_ERROR
=
30303
;
// 频道对我禁言
STATUS_CODE_CHANNEL_NOT_EXISTS
=
30304
;
// 频道不存在
STATUS_CODE_CHANNEL_NOT_PERMITTED
=
30305
;
// 频道不允许该用户加入
}
message
RequestMessageHeader
{
int32
version
=
1
;
...
...
@@ -19,5 +43,5 @@ message RequestMessageHeader {
message
ResponseMessageHeader
{
int32
version
=
1
;
int32
seq
=
2
;
int32
code
=
3
;
StatusCode
code
=
3
;
}
\ No newline at end of file
ccim/src/main/proto/message.proto
View file @
df78610d
...
...
@@ -14,15 +14,15 @@ message SendMessageResponse {
int64
msg_id
=
1
;
}
message
SendGroupMessageRequest
{
int64
group_id
=
1
;
string
content
=
2
;
MessageType
msg_type
=
3
;
}
message
SendGroupMessageResponse
{
int64
msg_id
=
1
;
}
//
message SendGroupMessageRequest {
//
int64 group_id = 1;
//
string content = 2;
//
MessageType msg_type = 3;
//
}
//
//
message SendGroupMessageResponse {
//
int64 msg_id = 1;
//
}
message
SendChannelMessageRequest
{
int64
channel_id
=
1
;
...
...
ccim/src/main/proto/message_spec.proto
View file @
df78610d
...
...
@@ -3,19 +3,22 @@ syntax = "proto3";
package
ccim
.
protocol
;
enum
MessageType
{
TEXT
=
0
;
VOICE
=
1
;
MESSAGE_TYPE_
TEXT
=
0
;
MESSAGE_TYPE_
VOICE
=
1
;
}
enum
MessageSourceType
{
PRIVATE
=
0
;
GROUP
=
1
;
CHANNEL
=
2
;
MESSAGE_SOURCE_TYPE_PRIVATE
=
0
;
MESSAGE_SOURCE_TYPE_CHANNEL
=
1
;
}
message
ChatMessage
{
int64
msg_id
=
1
;
int64
sender_user_id
=
2
;
MessageType
msg_type
=
3
;
string
content
=
4
;
int64
msg_src_id
=
3
;
MessageSourceType
msg_src_type
=
4
;
MessageType
msg_type
=
5
;
string
content
=
6
;
int64
created_date
=
7
;
int64
modified_date
=
8
;
}
\ No newline at end of file
ccim/src/main/proto/push.proto
View file @
df78610d
...
...
@@ -13,16 +13,6 @@ message PushPrivateMessageAckRequest {
int64
contact_user_id
=
2
;
}
message
PushGroupMessageResponse
{
int64
group_id
=
1
;
ChatMessage
message
=
2
;
}
message
PushGroupMessageAckRequest
{
int64
msg_id
=
1
;
int64
group_id
=
2
;
}
message
PushChannelMessageResponse
{
int64
channel_id
=
1
;
ChatMessage
message
=
2
;
...
...
readme.md
0 → 100644
View file @
df78610d
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