Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
im-common
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈永峰
im-common
Commits
41f617c5
Unverified
Commit
41f617c5
authored
Oct 31, 2021
by
Yang Libin
Committed by
GitHub
Oct 31, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update IMClient and message entities (#43)
* feat: update message entities * feat: update imclient
parent
633c5b6a
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
60 additions
and
37 deletions
+60
-37
IMClient.java
src/main/java/io/github/doocs/im/IMClient.java
+10
-22
DeleteType.java
src/main/java/io/github/doocs/im/constant/DeleteType.java
+6
-0
TagSNS.java
src/main/java/io/github/doocs/im/constant/TagSNS.java
+29
-0
TIMCustomMsgElement.java
...io/github/doocs/im/model/message/TIMCustomMsgElement.java
+2
-2
TIMFaceMsgElement.java
...a/io/github/doocs/im/model/message/TIMFaceMsgElement.java
+2
-2
TIMFileMsgElement.java
...a/io/github/doocs/im/model/message/TIMFileMsgElement.java
+2
-2
TIMImageMsgElement.java
.../io/github/doocs/im/model/message/TIMImageMsgElement.java
+2
-2
TIMLocationMsgElement.java
.../github/doocs/im/model/message/TIMLocationMsgElement.java
+2
-2
TIMSoundMsgElement.java
.../io/github/doocs/im/model/message/TIMSoundMsgElement.java
+2
-2
TIMTextMsgElement.java
...a/io/github/doocs/im/model/message/TIMTextMsgElement.java
+1
-1
TIMVideoFileMsgElement.java
...github/doocs/im/model/message/TIMVideoFileMsgElement.java
+2
-2
No files found.
src/main/java/io/github/doocs/im/IMClient.java
View file @
41f617c5
...
@@ -12,11 +12,17 @@ import java.util.concurrent.ThreadLocalRandom;
...
@@ -12,11 +12,17 @@ import java.util.concurrent.ThreadLocalRandom;
* @since 2021/07/29 16:11
* @since 2021/07/29 16:11
*/
*/
public
class
IMClient
{
public
class
IMClient
{
private
final
Long
sdkAppId
;
private
final
String
userId
;
private
final
String
key
;
private
String
userSig
;
private
long
userSigExpireTs
;
private
static
final
String
VERSION
=
"v4"
;
private
static
final
long
EXPIRE_TIME
=
24
*
60
*
60L
;
private
static
final
ConcurrentHashMap
<
String
,
IMClient
>
IM_CLIENT
=
new
ConcurrentHashMap
<>();
private
static
final
ConcurrentHashMap
<
String
,
IMClient
>
IM_CLIENT
=
new
ConcurrentHashMap
<>();
private
static
final
String
FORMAT_URL
=
"https://console.tim.qq.com/%s/%s/%s?sdkappid=%d&identifier=%s&usersig=%s&random=%d&contenttype=json"
;
private
static
final
String
FORMAT_URL
=
"https://console.tim.qq.com/%s/%s/%s?sdkappid=%d&identifier=%s&usersig=%s&random=%d&contenttype=json"
;
/**
* core methods
*/
public
final
Account
account
;
public
final
Account
account
;
public
final
Message
message
;
public
final
Message
message
;
public
final
Member
member
;
public
final
Member
member
;
...
@@ -25,17 +31,6 @@ public class IMClient {
...
@@ -25,17 +31,6 @@ public class IMClient {
public
final
SNS
sns
;
public
final
SNS
sns
;
public
final
Operation
operation
;
public
final
Operation
operation
;
public
final
RecentContact
recentContact
;
public
final
RecentContact
recentContact
;
/**
* init property
*/
private
String
userSig
;
private
long
userSigExpireTs
;
private
final
Long
sdkAppId
;
private
final
String
userId
;
private
final
String
key
;
private
static
final
String
VERSION
=
"v4"
;
private
static
final
long
EXPIRE_TIME
=
24
*
60
*
60L
;
public
static
IMClient
getInstance
(
Long
sdkAppId
,
String
userId
,
String
key
)
{
public
static
IMClient
getInstance
(
Long
sdkAppId
,
String
userId
,
String
key
)
{
String
identify
=
sdkAppId
+
"_"
+
userId
;
String
identify
=
sdkAppId
+
"_"
+
userId
;
...
@@ -51,6 +46,7 @@ public class IMClient {
...
@@ -51,6 +46,7 @@ public class IMClient {
this
.
key
=
key
;
this
.
key
=
key
;
this
.
userSig
=
SigUtil
.
genUserSig
(
sdkAppId
,
key
,
userId
,
EXPIRE_TIME
);
this
.
userSig
=
SigUtil
.
genUserSig
(
sdkAppId
,
key
,
userId
,
EXPIRE_TIME
);
this
.
userSigExpireTs
=
System
.
currentTimeMillis
()
/
1000
+
EXPIRE_TIME
-
100
;
this
.
userSigExpireTs
=
System
.
currentTimeMillis
()
/
1000
+
EXPIRE_TIME
-
100
;
account
=
new
Account
(
this
);
account
=
new
Account
(
this
);
message
=
new
Message
(
this
);
message
=
new
Message
(
this
);
member
=
new
Member
(
this
);
member
=
new
Member
(
this
);
...
@@ -81,12 +77,4 @@ public class IMClient {
...
@@ -81,12 +77,4 @@ public class IMClient {
}
}
return
userSig
;
return
userSig
;
}
}
@Override
public
String
toString
()
{
return
"IMClient{"
+
"sdkAppId="
+
sdkAppId
+
", userId='"
+
userId
+
'\''
+
'}'
;
}
}
}
src/main/java/io/github/doocs/im/constant/DeleteType.java
View file @
41f617c5
...
@@ -7,8 +7,14 @@ package io.github.doocs.im.constant;
...
@@ -7,8 +7,14 @@ package io.github.doocs.im.constant;
* @since 2021/10/30 16:08
* @since 2021/10/30 16:08
*/
*/
public
class
DeleteType
{
public
class
DeleteType
{
/**
* 单向删除好友
*/
public
static
final
String
SINGLE
=
"Delete_Type_Single"
;
public
static
final
String
SINGLE
=
"Delete_Type_Single"
;
/**
* 双向删除好友
*/
public
static
final
String
BOTH
=
"Delete_Type_Both"
;
public
static
final
String
BOTH
=
"Delete_Type_Both"
;
private
DeleteType
()
{
private
DeleteType
()
{
...
...
src/main/java/io/github/doocs/im/constant/TagSNS.java
0 → 100644
View file @
41f617c5
package
io
.
github
.
doocs
.
im
.
constant
;
/**
* 关系链
*
* @author bingo
* @since 2021/10/31 10:14
*/
public
class
TagSNS
{
/**
* 好友分组
*/
public
static
final
String
IM_GROUP
=
"Tag_SNS_IM_Group"
;
/**
* 好友备注
*/
public
static
final
String
IM_REMARK
=
"Tag_SNS_IM_Remark"
;
/**
* 加好友来源
*/
public
static
final
String
IM_ADD_SOURCE
=
"Tag_SNS_IM_AddSource"
;
/**
* 加好友附言
*/
public
static
final
String
IM_ADD_WORDING
=
"Tag_SNS_IM_AddWording"
;
}
src/main/java/io/github/doocs/im/model/message/TIMCustomMsgElement.java
View file @
41f617c5
...
@@ -16,11 +16,11 @@ public class TIMCustomMsgElement extends TIMMsgElement {
...
@@ -16,11 +16,11 @@ public class TIMCustomMsgElement extends TIMMsgElement {
private
CustomMsgContent
msgContent
;
private
CustomMsgContent
msgContent
;
public
TIMCustomMsgElement
()
{
public
TIMCustomMsgElement
()
{
super
(
MsgType
.
TIM_CUSTOM_ELEM
);
this
(
null
);
}
}
public
TIMCustomMsgElement
(
CustomMsgContent
msgContent
)
{
public
TIMCustomMsgElement
(
CustomMsgContent
msgContent
)
{
this
(
);
super
(
MsgType
.
TIM_CUSTOM_ELEM
);
this
.
msgContent
=
msgContent
;
this
.
msgContent
=
msgContent
;
}
}
...
...
src/main/java/io/github/doocs/im/model/message/TIMFaceMsgElement.java
View file @
41f617c5
...
@@ -16,11 +16,11 @@ public class TIMFaceMsgElement extends TIMMsgElement {
...
@@ -16,11 +16,11 @@ public class TIMFaceMsgElement extends TIMMsgElement {
private
FaceMsgContent
msgContent
;
private
FaceMsgContent
msgContent
;
public
TIMFaceMsgElement
()
{
public
TIMFaceMsgElement
()
{
super
(
MsgType
.
TIM_FACE_ELEM
);
this
(
null
);
}
}
public
TIMFaceMsgElement
(
FaceMsgContent
msgContent
)
{
public
TIMFaceMsgElement
(
FaceMsgContent
msgContent
)
{
this
(
);
super
(
MsgType
.
TIM_FACE_ELEM
);
this
.
msgContent
=
msgContent
;
this
.
msgContent
=
msgContent
;
}
}
...
...
src/main/java/io/github/doocs/im/model/message/TIMFileMsgElement.java
View file @
41f617c5
...
@@ -16,11 +16,11 @@ public class TIMFileMsgElement extends TIMMsgElement {
...
@@ -16,11 +16,11 @@ public class TIMFileMsgElement extends TIMMsgElement {
private
FileMsgContent
msgContent
;
private
FileMsgContent
msgContent
;
public
TIMFileMsgElement
()
{
public
TIMFileMsgElement
()
{
super
(
MsgType
.
TIM_FILE_ELEM
);
this
(
null
);
}
}
public
TIMFileMsgElement
(
FileMsgContent
msgContent
)
{
public
TIMFileMsgElement
(
FileMsgContent
msgContent
)
{
this
(
);
super
(
MsgType
.
TIM_FILE_ELEM
);
this
.
msgContent
=
msgContent
;
this
.
msgContent
=
msgContent
;
}
}
...
...
src/main/java/io/github/doocs/im/model/message/TIMImageMsgElement.java
View file @
41f617c5
...
@@ -18,11 +18,11 @@ public class TIMImageMsgElement extends TIMMsgElement {
...
@@ -18,11 +18,11 @@ public class TIMImageMsgElement extends TIMMsgElement {
private
ImageMsgContent
msgContent
;
private
ImageMsgContent
msgContent
;
public
TIMImageMsgElement
()
{
public
TIMImageMsgElement
()
{
super
(
MsgType
.
TIM_IMAGE_ELEM
);
this
(
null
);
}
}
public
TIMImageMsgElement
(
ImageMsgContent
msgContent
)
{
public
TIMImageMsgElement
(
ImageMsgContent
msgContent
)
{
this
(
);
super
(
MsgType
.
TIM_IMAGE_ELEM
);
this
.
msgContent
=
msgContent
;
this
.
msgContent
=
msgContent
;
}
}
...
...
src/main/java/io/github/doocs/im/model/message/TIMLocationMsgElement.java
View file @
41f617c5
...
@@ -16,11 +16,11 @@ public class TIMLocationMsgElement extends TIMMsgElement {
...
@@ -16,11 +16,11 @@ public class TIMLocationMsgElement extends TIMMsgElement {
private
LocationMsgContent
msgContent
;
private
LocationMsgContent
msgContent
;
public
TIMLocationMsgElement
()
{
public
TIMLocationMsgElement
()
{
super
(
MsgType
.
TIM_LOCATION_ELEM
);
this
(
null
);
}
}
public
TIMLocationMsgElement
(
LocationMsgContent
msgContent
)
{
public
TIMLocationMsgElement
(
LocationMsgContent
msgContent
)
{
this
(
);
super
(
MsgType
.
TIM_LOCATION_ELEM
);
this
.
msgContent
=
msgContent
;
this
.
msgContent
=
msgContent
;
}
}
...
...
src/main/java/io/github/doocs/im/model/message/TIMSoundMsgElement.java
View file @
41f617c5
...
@@ -16,11 +16,11 @@ public class TIMSoundMsgElement extends TIMMsgElement {
...
@@ -16,11 +16,11 @@ public class TIMSoundMsgElement extends TIMMsgElement {
private
SoundMsgContent
msgContent
;
private
SoundMsgContent
msgContent
;
public
TIMSoundMsgElement
()
{
public
TIMSoundMsgElement
()
{
super
(
MsgType
.
TIM_SOUND_ELEM
);
this
(
null
);
}
}
public
TIMSoundMsgElement
(
SoundMsgContent
msgContent
)
{
public
TIMSoundMsgElement
(
SoundMsgContent
msgContent
)
{
this
(
);
super
(
MsgType
.
TIM_SOUND_ELEM
);
this
.
msgContent
=
msgContent
;
this
.
msgContent
=
msgContent
;
}
}
...
...
src/main/java/io/github/doocs/im/model/message/TIMTextMsgElement.java
View file @
41f617c5
...
@@ -20,7 +20,7 @@ public class TIMTextMsgElement extends TIMMsgElement {
...
@@ -20,7 +20,7 @@ public class TIMTextMsgElement extends TIMMsgElement {
}
}
public
TIMTextMsgElement
(
TextMsgContent
msgContent
)
{
public
TIMTextMsgElement
(
TextMsgContent
msgContent
)
{
this
(
);
super
(
MsgType
.
TIM_TEXT_ELEM
);
this
.
msgContent
=
msgContent
;
this
.
msgContent
=
msgContent
;
}
}
...
...
src/main/java/io/github/doocs/im/model/message/TIMVideoFileMsgElement.java
View file @
41f617c5
...
@@ -16,11 +16,11 @@ public class TIMVideoFileMsgElement extends TIMMsgElement {
...
@@ -16,11 +16,11 @@ public class TIMVideoFileMsgElement extends TIMMsgElement {
private
VideoFileMsgContent
msgContent
;
private
VideoFileMsgContent
msgContent
;
public
TIMVideoFileMsgElement
()
{
public
TIMVideoFileMsgElement
()
{
super
(
MsgType
.
TIM_VIDEO_FILE_ELEM
);
this
(
null
);
}
}
public
TIMVideoFileMsgElement
(
VideoFileMsgContent
msgContent
)
{
public
TIMVideoFileMsgElement
(
VideoFileMsgContent
msgContent
)
{
this
(
);
super
(
MsgType
.
TIM_VIDEO_FILE_ELEM
);
this
.
msgContent
=
msgContent
;
this
.
msgContent
=
msgContent
;
}
}
...
...
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