Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
OffcnIMSDKiOS
Overview
Overview
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
opensource
OffcnIMSDKiOS
Commits
e9673ded
Commit
e9673ded
authored
Aug 27, 2020
by
zhangyunjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去重
parent
465ce70b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
19 deletions
+58
-19
project.pbxproj
OffcnIMSDKiOS.xcodeproj/project.pbxproj
+4
-4
OffcnIMSocketManager.h
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSocketManager.h
+3
-2
OffcnIMSocketManager.m
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSocketManager.m
+34
-4
Info.plist
OffcnIMSDKiOS/Info.plist
+6
-6
ViewController.mm
OffcnIMSDKiOS/ViewController.mm
+11
-3
No files found.
OffcnIMSDKiOS.xcodeproj/project.pbxproj
View file @
e9673ded
...
...
@@ -1918,9 +1918,9 @@
"-ObjC"
,
"$(inherited)"
,
);
PRODUCT_BUNDLE_IDENTIFIER
=
com.eoffcn.
classonline
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.eoffcn.
questions
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
PROVISIONING_PROFILE_SPECIFIER
=
Classonline
Dev
;
PROVISIONING_PROFILE_SPECIFIER
=
WXQuestion
Dev
;
TARGETED_DEVICE_FAMILY
=
"1,2"
;
};
name
=
Debug
;
...
...
@@ -1953,9 +1953,9 @@
"-ObjC"
,
"$(inherited)"
,
);
PRODUCT_BUNDLE_IDENTIFIER
=
com.eoffcn.
classonline
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.eoffcn.
questions
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
PROVISIONING_PROFILE_SPECIFIER
=
Classonline
Dev
;
PROVISIONING_PROFILE_SPECIFIER
=
WXQuestion
Dev
;
TARGETED_DEVICE_FAMILY
=
"1,2"
;
};
name
=
Release
;
...
...
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSocketManager.h
View file @
e9673ded
//
//
...
...
@@ -7,6 +7,7 @@
//
#import <Foundation/Foundation.h>
#import "OffcnIMModel.h"
NS_ASSUME_NONNULL_BEGIN
...
...
@@ -18,7 +19,7 @@ typedef NS_ENUM(NSUInteger, OffcnIMConnectStatus) {
};
//收到消息回调
typedef
void
(
^
OffcnIMConnectReceiveMessage
)(
NSString
*
message
);
typedef
void
(
^
OffcnIMConnectReceiveMessage
)(
OffcnIMModel
*
IMModel
);
//连接状态回调
typedef
void
(
^
OffcnIMReceiveConnectStatus
)(
OffcnIMConnectStatus
status
,
NSString
*
errorMessage
);
...
...
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSocketManager.m
View file @
e9673ded
//
//
...
...
@@ -8,14 +8,24 @@
#import "OffcnIMSocketManager.h"
#import <oimcore/oimcoreAdapter.h>
#import "ZYJMJExtension.h"
#import "DataSafe.h"
@interface
OffcnIMSocketManager
()
<
OIMCoreDelegate
>
@property
(
nonatomic
,
strong
)
OIMCoreAdapter
*
adapter
;
@property
(
nonatomic
,
strong
)
NSMutableArray
*
msgArr
;
@end
@implementation
OffcnIMSocketManager
-
(
NSMutableArray
*
)
msgArr
{
if
(
!
_msgArr
)
{
_msgArr
=
[
NSMutableArray
array
];
}
return
_msgArr
;
}
static
OffcnIMSocketManager
*
socketManager
;
+
(
OffcnIMSocketManager
*
)
defaultService
{
static
dispatch_once_t
onceToken
;
...
...
@@ -48,9 +58,29 @@ static OffcnIMSocketManager *socketManager;
-
(
void
)
OnOImCoreMessageWithMessage
:
(
const
char
*
_Nonnull
)
message
msgLength
:
(
int
)
len
{
// "{\"type\":1,\"body\":{\"session_id\":\"a05517f0-ddec-11ea-88a4-4a5555fb6ab4\",\"msg_id\":\"d5f9b600-e28f-11ea-88a4-4a5555fb6ab4\",\"version\":1,\"send_time\":\"2020-08-20 10:49:58\",\"msg_seq\":1597891798,\"msg_from\":\"jfdfjei0343\",\"msg_scope\":1,\"msg_type\":1,\"msg_content\":{\"msg\":\"随机数298\"}}}"
if
(
self
.
connectReceiveMessage
)
{
NSString
*
revStr
=
[
NSString
stringWithUTF8String
:
message
];
self
.
connectReceiveMessage
(
revStr
);
NSString
*
revStr
=
[
NSString
stringWithUTF8String
:
message
];
OffcnIMModel
*
IMModel
=
[
OffcnIMModel
mj_ZYJobjectWithKeyValues
:
revStr
];
NSString
*
msg_id
=
IMModel
.
body
.
msg_id
;
if
(
self
.
msgArr
.
count
)
{
if
([
self
.
msgArr
containsObject
:
msg_id
])
{
//消息重复,丢弃
}
else
{
if
(
self
.
msgArr
.
count
>=
100
)
{
[
self
.
msgArr
removeObjectAtIndex
:
0
];
}
[
self
.
msgArr
addObject
:
msg_id
];
if
(
self
.
connectReceiveMessage
)
{
self
.
connectReceiveMessage
(
IMModel
);
}
}
}
else
{
[
self
.
msgArr
addObject
:
msg_id
];
if
(
self
.
connectReceiveMessage
)
{
self
.
connectReceiveMessage
(
IMModel
);
}
}
}
...
...
OffcnIMSDKiOS/Info.plist
View file @
e9673ded
...
...
@@ -2,14 +2,8 @@
<
!
D
O
C
TYP
E
plist
PU
B
LI
C
"-//
A
ppl
e
//
D
T
D
PLIST
1
.
0
//
E
N"
"http://www.
a
ppl
e
.
c
om/
D
T
D
s/Prop
e
rtyList-
1
.
0
.
d
t
d
"
>
<
plist
v
e
rsion="
1
.
0
"
>
<
d
i
c
t
>
<
k
e
y
>
NSMicrophoneUsageDescription
<
/k
e
y
>
<
string
>
App
需要您的同意,才能访问麦克风
<
/string
>
<
k
e
y
>
NSPhotoLibraryUsageDescription
<
/k
e
y
>
<
string
>
App
需要您的同意,才能访问相册
<
/string
>
<
k
e
y
>
CFBundleDevelopmentRegion
<
/k
e
y
>
<
string
>
$
(
DEVELOPMENT_LANGUAGE
)<
/string
>
<
k
e
y
>
NSCameraUsageDescription
<
/k
e
y
>
<
string
>
App
需要您的同意,才能访问相机
<
/string
>
<
k
e
y
>
CFBundleExecutable
<
/k
e
y
>
<
string
>
$
(
EXECUTABLE_NAME
)<
/string
>
<
k
e
y
>
CFBundleIdentifier
<
/k
e
y
>
...
...
@@ -31,6 +25,12 @@
<
k
e
y
>
NSAllowsArbitraryLoads
<
/k
e
y
>
<
tru
e
/
>
<
/
d
i
c
t
>
<
k
e
y
>
NSCameraUsageDescription
<
/k
e
y
>
<
string
>
App
需要您的同意,才能访问相机
<
/string
>
<
k
e
y
>
NSMicrophoneUsageDescription
<
/k
e
y
>
<
string
>
App
需要您的同意,才能访问麦克风
<
/string
>
<
k
e
y
>
NSPhotoLibraryUsageDescription
<
/k
e
y
>
<
string
>
App
需要您的同意,才能访问相册
<
/string
>
<
k
e
y
>
UIBackgroundModes
<
/k
e
y
>
<
a
rr
a
y
>
<
string
>
remote-notification
<
/string
>
...
...
OffcnIMSDKiOS/ViewController.mm
View file @
e9673ded
...
...
@@ -11,6 +11,7 @@
#import "OffcnIMSocketManager.h"
#import "OffcnNetworkExecutor.h"
#import "SDGeneralTool.h"
@interface
ViewController
()
<
UINavigationControllerDelegate
,
UIImagePickerControllerDelegate
>
...
...
@@ -45,8 +46,14 @@
NSString
*
paramStr
=
@"{
\"
server_ip
\"
:
\"
39.102.42.185
\"
,
\"
server_port
\"
:6000,
\"
user_id
\"
:
\"
ce0819db8391f1e7258a71cc9e2c3235
\"
,
\"
app_id
\"
:
\"
offcn_live
\"
,
\"
device_type
\"
:
\"
ios
\"
,
\"
token
\"
:
\"
fadbce3f4929b6bdee0617fee34e32ae
\"
}"
;
[[
OffcnIMSocketManager
defaultService
]
connectIMServerWithParam
:
paramStr
];
[
OffcnIMSocketManager
defaultService
].
connectReceiveMessage
=
^
(
NSString
*
_Nonnull
message
)
{
NSLog
(
@"收到消息---%@"
,
message
);
[
OffcnIMSocketManager
defaultService
].
connectReceiveMessage
=
^
(
OffcnIMModel
*
IMModel
)
{
NSLog
(
@"收到消息---%@"
,
IMModel
.
body
.
msg
.
msg
);
dispatch_async
(
dispatch_get_main_queue
(),
^
{
UIAlertView
*
alert
=
[[
UIAlertView
alloc
]
initWithTitle
:
@"收到消息"
message
:
IMModel
.
body
.
msg
.
msg
delegate
:
self
cancelButtonTitle
:
@"取消"
otherButtonTitles
:
@"确定"
,
nil
];
[
alert
show
];
});
};
[
OffcnIMSocketManager
defaultService
].
connectStatus
=
^
(
OffcnIMConnectStatus
status
,
NSString
*
_Nonnull
errorMessage
)
{
...
...
@@ -69,7 +76,8 @@
-
(
IBAction
)
sendMeg
:(
UIButton
*
)
sender
{
//发送消息
[[
OffcnIMSDKiOS
defaultService
]
sendMsgWithMsg_fromID
:
self
.
fromId
msg_toID
:
self
.
toId
tid
:
@"13e266f3-e139-11ea-88a4-4a5555fb6ab4"
msg_type
:
OffcnSDKMsgTypeText
text
:
@"你好"
filePath
:
nil
Finished
:^
(
BOOL
success
,
OffcnIMSendMsgModel
*
sendMsgModel
,
NSString
*
errorMessage
)
{
NSString
*
tidStr
=
[
NSString
stringWithFormat
:
@"%@_%@"
,
self
.
toId
,[
SDGeneralTool
getNowSSSTimeTimestamp
]];
[[
OffcnIMSDKiOS
defaultService
]
sendMsgWithMsg_fromID
:
self
.
fromId
msg_toID
:
self
.
toId
tid
:
tidStr
msg_type
:
OffcnSDKMsgTypeText
text
:
@"你好"
filePath
:
nil
Finished
:^
(
BOOL
success
,
OffcnIMSendMsgModel
*
sendMsgModel
,
NSString
*
errorMessage
)
{
}];
}
...
...
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